{"metadata":{"image":[],"title":"","description":""},"api":{"url":"","auth":"required","results":{"codes":[]},"settings":"","params":[]},"next":{"description":"","pages":[]},"title":"Pulsate React SDK Methods","type":"basic","slug":"pulsate-react-sdk-methods","excerpt":"","body":"All Pulsate methods can be used directly from JavaScript. All that you need to do is add the following code directly under your imports\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"var PulsateManager = require('pulsate-react-native-sdk');\\nvar { Pulsate } = PulsateManager;\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]\nYou can now use all methods by simply calling *Pulsate.methodToUse*. For example this method starts a Pulsate Session and sets the users data. You must always first start a session before doing any other actions.\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"<TouchableOpacity style={.....}\\n\\tonPress={() => \\n  {\\n  \\tPulsate.startPulsateSessionForAlias(\\\"ALIAS\\\",\\n    \\t(msg) => {\\n      \\tAlert.alert(\\n        \\t'Session Status',\\n          'Session Success',\\n          [\\n          \\t{ text: 'OK', onPress: () => console.log('OK Pressed') },\\n          ],\\n          { cancelable: false })\\n\\n          this.requestLocationPermission();\\n          Pulsate.updateFirstName(\\\"FirstName\\\");\\n          Pulsate.updateLastName(\\\"LastName\\\");\\n          Pulsate.updateEmail(\\\"Email\\\");\\n          Pulsate.forceAttributeSync();\\n\\t\\t\\t\\t},\\n      \\t(err) => {\\n      \\t\\tconsole.log(err);\\n      \\t});\\n  \\t}\\n\\t}>\\n\\t<Text style={.....}>START SESSION</Text>\\n</TouchableOpacity>\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"title\": \"Asking for permissions from JavaScript\"\n}\n[/block]\nThe Pulsate SDK requires the location permission for Geofencing and Beacon Scanning. To ask the user for this permission you can use the following code\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"async requestLocationPermission() {\\n    const chckLocationPermission = PermissionsAndroid.check(PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION);\\n    if (chckLocationPermission === PermissionsAndroid.RESULTS.GRANTED) {\\n\\n    } else {\\n      try {\\n        const granted = await PermissionsAndroid.request(PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION,\\n          {\\n            'title': 'Location permission',\\n            'message': 'We use this to provide the best experience possible inside our store. We also send relevant communications based on your location.'\\n          }\\n        )\\n        if (granted === PermissionsAndroid.RESULTS.GRANTED) {\\n\\n        } else {\\n\\n        }\\n      } catch (err) {\\n        alert(err)\\n      }\\n    }\\n  };\\n\\n<TouchableOpacity style={.....}\\n\\tonPress={() => \\n  {\\n  \\tthis.requestLocationPermission();\\n\\t}>\\n\\t<Text style={.....}>SHOW LOCATION PROMPT</Text>\\n</TouchableOpacity>\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"title\": \"All Methods\"\n}\n[/block]\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"Pulsate: \\n{\\n  setAuthData(appid: string, appkey: string, gcmid: string): void;\\n  startPulsateSession(successCallback: () => string, errorCallback: () => string): void;\\n  startPulsateSessionForAlias(alias: string, successCallback: () => string, errorCallback: () => string): void;\\n  logoutCurrentAlias(successCallback: () => string, errorCallback: () => string): void;\\n  setNewThreadButtonEnabled(buttonEnabled: boolean): void;\\n  sendLocationWithBeaconEvents(sendLocation: boolean): void;\\n  setLocationUpdatesEnabled(enabled: boolean): void;\\n  setInAppNotificationEnabled(enabled: boolean): void;\\n  showLastInAppNotification(): void;\\n  setPushNotificationEnabled(enabled: boolean): void;\\n  isPushNotificationEnabled(successCallback: () => string, errorCallback: () => string): void;\\n  setUserAuthorized(authorized: boolean): void;\\n  showLastUnauthorizedMessage(): void;\\n  updateFirstName(firstName: string): void;\\n  updateLastName(lastName: string): void;\\n  updateEmail(email: string): void;\\n  updateGender(gender: integer): void;\\n  updateAge(age: string): void;\\n  setPrivacy(privacy: integer): void;\\n  createAttributeWithString(attributeName: string, value: string): void;\\n  createAttributeWithFloat(attributeName: string, value: float): void;\\n  createAttributeWithInt(attributeName: string, value: integer): void;\\n  createAttributeWithBool(attributeName: string, value: boolean): void;\\n  createAttributeWithDate(attributeName: string, value: Date): void;\\n  incrementCounter(counterName: string, value: integer): void;\\n  decrementCounter(counterName: string, value: integer): void;\\n  createEvent(eventName: string): void;\\n  forceAttributeSync(): void;\\n  showFeed(): void;\\n  useInitialsForUserAvatar(useInitials: boolean): void;\\n\\n  setOnInboxRightButtonClickListenerAndroid(): void;\\n  removeOnInboxRightButtonClickListenerAndroid(): void;\\n  setUserUnauthorizedListenerAndroid(): void;\\n  setUnreadCountUpdateListenerAndroid(): void;\\n  showNetworkAndroid(): void;\\n\\n  isUserAuthorizedIOS(successCallback: () => string, errorCallback: () => string): void;\\n  getDeviceGuidIOS(successCallback: () => string): void;\\n  startLocationIOS(): void;\\n  startRemoteNotificationsIOS(): void;\\n  getBadgeCountIOS(): void;\\n}        \",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]","updates":[],"order":3,"isReference":false,"hidden":false,"sync_unique":"","link_url":"","link_external":false,"_id":"5e4ffc2c9cdd19004b87877e","project":"54aa7f773b56130b0056c86e","version":{"version":"2.3","version_clean":"2.3.0","codename":"React-Native SDK","is_stable":false,"is_beta":false,"is_hidden":false,"is_deprecated":false,"categories":["5e4feaa9bca78600237fcefc","55781fe35129590d003ff4f9","55781fe35129590d003ff4fa","5e4feaa9bca78600237fcefd","5e4feaa9bca78600237fcefe","5e4ffc2c9cdd19004b87876d","5e4ffc2c9cdd19004b87876e","5e4feaa9bca78600237fcf01","565b66c446118c0d00dcb0bb","56898269f8dc340d00308c13","5e4ffc2c9cdd19004b87876f","5e4feaa9bca78600237fcf03","5c73dd27e8fdc000572a206a","5e4ffc2c9cdd19004b878770","5e4ffc2c9cdd19004b878771","5e53efa85c3d6e0066ff69ab"],"_id":"5e4ffc2c9cdd19004b878788","project":"54aa7f773b56130b0056c86e","forked_from":"5e4feaa9bca78600237fcf93","__v":1,"createdAt":"2015-06-10T11:30:42.700Z","releaseDate":"2015-06-10T11:30:42.700Z"},"category":{"sync":{"isSync":false,"url":""},"pages":[],"title":"React Native SDK","slug":"react","order":1,"from_sync":false,"reference":false,"_id":"5e4ffc2c9cdd19004b878770","project":"54aa7f773b56130b0056c86e","version":"5e4ffc2c9cdd19004b878788","createdAt":"2019-02-28T09:39:38.102Z","__v":0},"user":"57bc3654b9c7f0220009c77b","createdAt":"2019-02-25T14:13:10.173Z","__v":0,"parentDoc":null}

Pulsate React SDK Methods


All Pulsate methods can be used directly from JavaScript. All that you need to do is add the following code directly under your imports [block:code] { "codes": [ { "code": "var PulsateManager = require('pulsate-react-native-sdk');\nvar { Pulsate } = PulsateManager;", "language": "javascript" } ] } [/block] You can now use all methods by simply calling *Pulsate.methodToUse*. For example this method starts a Pulsate Session and sets the users data. You must always first start a session before doing any other actions. [block:code] { "codes": [ { "code": "<TouchableOpacity style={.....}\n\tonPress={() => \n {\n \tPulsate.startPulsateSessionForAlias(\"ALIAS\",\n \t(msg) => {\n \tAlert.alert(\n \t'Session Status',\n 'Session Success',\n [\n \t{ text: 'OK', onPress: () => console.log('OK Pressed') },\n ],\n { cancelable: false })\n\n this.requestLocationPermission();\n Pulsate.updateFirstName(\"FirstName\");\n Pulsate.updateLastName(\"LastName\");\n Pulsate.updateEmail(\"Email\");\n Pulsate.forceAttributeSync();\n\t\t\t\t},\n \t(err) => {\n \t\tconsole.log(err);\n \t});\n \t}\n\t}>\n\t<Text style={.....}>START SESSION</Text>\n</TouchableOpacity>", "language": "javascript" } ] } [/block] [block:api-header] { "title": "Asking for permissions from JavaScript" } [/block] The Pulsate SDK requires the location permission for Geofencing and Beacon Scanning. To ask the user for this permission you can use the following code [block:code] { "codes": [ { "code": "async requestLocationPermission() {\n const chckLocationPermission = PermissionsAndroid.check(PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION);\n if (chckLocationPermission === PermissionsAndroid.RESULTS.GRANTED) {\n\n } else {\n try {\n const granted = await PermissionsAndroid.request(PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION,\n {\n 'title': 'Location permission',\n 'message': 'We use this to provide the best experience possible inside our store. We also send relevant communications based on your location.'\n }\n )\n if (granted === PermissionsAndroid.RESULTS.GRANTED) {\n\n } else {\n\n }\n } catch (err) {\n alert(err)\n }\n }\n };\n\n<TouchableOpacity style={.....}\n\tonPress={() => \n {\n \tthis.requestLocationPermission();\n\t}>\n\t<Text style={.....}>SHOW LOCATION PROMPT</Text>\n</TouchableOpacity>", "language": "javascript" } ] } [/block] [block:api-header] { "title": "All Methods" } [/block] [block:code] { "codes": [ { "code": "Pulsate: \n{\n setAuthData(appid: string, appkey: string, gcmid: string): void;\n startPulsateSession(successCallback: () => string, errorCallback: () => string): void;\n startPulsateSessionForAlias(alias: string, successCallback: () => string, errorCallback: () => string): void;\n logoutCurrentAlias(successCallback: () => string, errorCallback: () => string): void;\n setNewThreadButtonEnabled(buttonEnabled: boolean): void;\n sendLocationWithBeaconEvents(sendLocation: boolean): void;\n setLocationUpdatesEnabled(enabled: boolean): void;\n setInAppNotificationEnabled(enabled: boolean): void;\n showLastInAppNotification(): void;\n setPushNotificationEnabled(enabled: boolean): void;\n isPushNotificationEnabled(successCallback: () => string, errorCallback: () => string): void;\n setUserAuthorized(authorized: boolean): void;\n showLastUnauthorizedMessage(): void;\n updateFirstName(firstName: string): void;\n updateLastName(lastName: string): void;\n updateEmail(email: string): void;\n updateGender(gender: integer): void;\n updateAge(age: string): void;\n setPrivacy(privacy: integer): void;\n createAttributeWithString(attributeName: string, value: string): void;\n createAttributeWithFloat(attributeName: string, value: float): void;\n createAttributeWithInt(attributeName: string, value: integer): void;\n createAttributeWithBool(attributeName: string, value: boolean): void;\n createAttributeWithDate(attributeName: string, value: Date): void;\n incrementCounter(counterName: string, value: integer): void;\n decrementCounter(counterName: string, value: integer): void;\n createEvent(eventName: string): void;\n forceAttributeSync(): void;\n showFeed(): void;\n useInitialsForUserAvatar(useInitials: boolean): void;\n\n setOnInboxRightButtonClickListenerAndroid(): void;\n removeOnInboxRightButtonClickListenerAndroid(): void;\n setUserUnauthorizedListenerAndroid(): void;\n setUnreadCountUpdateListenerAndroid(): void;\n showNetworkAndroid(): void;\n\n isUserAuthorizedIOS(successCallback: () => string, errorCallback: () => string): void;\n getDeviceGuidIOS(successCallback: () => string): void;\n startLocationIOS(): void;\n startRemoteNotificationsIOS(): void;\n getBadgeCountIOS(): void;\n} ", "language": "javascript" } ] } [/block]