{"_id":"5c73f7f6bf61d001e2ee12b2","project":"54aa7f773b56130b0056c86e","version":{"_id":"55781fe25129590d003ff4f7","project":"54aa7f773b56130b0056c86e","forked_from":"54aa7f773b56130b0056c871","__v":8,"createdAt":"2015-06-10T11:30:42.700Z","releaseDate":"2015-06-10T11:30:42.700Z","categories":["55781fe35129590d003ff4f8","55781fe35129590d003ff4f9","55781fe35129590d003ff4fa","55781fe35129590d003ff4fb","55781fe35129590d003ff4fc","55781fe35129590d003ff4fd","55781fe35129590d003ff4fe","564bbc7e8841060d00abb2ee","565b66c446118c0d00dcb0bb","56898269f8dc340d00308c13","582318b23b961a0f009516a1","594a848c9f4771001a43c959","5c73dd27e8fdc000572a206a","5c77ac5af94a920045cb80ca"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"Developers","version_clean":"2.0.0","version":"2.0"},"category":{"_id":"5c77ac5af94a920045cb80ca","project":"54aa7f773b56130b0056c86e","version":"55781fe25129590d003ff4f7","__v":0,"sync":{"url":"","isSync":false},"reference":false,"createdAt":"2019-02-28T09:39:38.102Z","from_sync":false,"order":5,"slug":"react","title":"React Native SDK"},"user":"57bc3654b9c7f0220009c77b","__v":0,"parentDoc":null,"updates":[],"next":{"pages":[],"description":""},"createdAt":"2019-02-25T14:13:10.173Z","link_external":false,"link_url":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":3,"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]","excerpt":"","slug":"pulsate-react-sdk-methods","type":"basic","title":"Pulsate React SDK Methods"}

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]