{"_id":"583ea7634ced340f00b05a70","user":"567bb6833241c20d00b730db","__v":0,"category":{"_id":"57595bbb18760817001e8bbe","project":"5540ce1b31827a0d007ab1cc","__v":0,"version":"5540ce1c31827a0d007ab1cf","sync":{"url":"","isSync":false},"reference":false,"createdAt":"2016-06-09T12:06:19.325Z","from_sync":false,"order":24,"slug":"react-native","title":"React Native"},"project":"5540ce1b31827a0d007ab1cc","version":{"_id":"5540ce1c31827a0d007ab1cf","project":"5540ce1b31827a0d007ab1cc","__v":31,"createdAt":"2015-04-29T12:27:08.390Z","releaseDate":"2015-04-29T12:27:08.390Z","categories":["5540ce1c31827a0d007ab1d0","5540d91bbb9e762d00f594ad","5540e5f131827a0d007ab212","5540e5febb9e762d00f594d3","5540e61331827a0d007ab213","5540e6195cf9682100d61afa","5540e62631827a0d007ab214","5540e63031827a0d007ab215","5540e63531827a0d007ab216","5540e63e5cf9682100d61afc","5540e6445cf9682100d61afd","5540e64a5cf9682100d61afe","55a4ff5b2e70c0250038050f","55acb28318eefd0d0071d504","55ae1abe8576b92300291c80","55ae453ef302af23000ac109","55af586d555b900d0036d296","55af91dac8a85321007a53c3","55b9fee204775a2f00628071","55b9ff0e04775a2f00628072","55b9ff4604775a2f00628073","55b9ff5fd72d1e1900276a38","55b9ff7f04775a2f00628074","55b9ff90eb08801900f833e5","55b9ffa5d72d1e1900276a39","55b9ffca04775a2f00628075","55b9fffdd72d1e1900276a3a","56bc2f033ee9e70d008b46af","56c2f6efbbf9ec2d00e0fe4f","57595bbb18760817001e8bbe","57d8d9793916800e003dde53"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"1.0.0","version":"1.0"},"parentDoc":null,"updates":[],"next":{"pages":[],"description":""},"createdAt":"2016-11-30T10:18:11.213Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":3,"body":"[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"var Pushwoosh = require('pushwoosh-react-native-plugin');\\n\\nDeviceEventEmitter.addListener('pushOpened', (e: Event) => {\\n  console.warn(\\\"pushOpened: \\\" + JSON.stringify(e));\\n  alert(JSON.stringify(e));\\n});\\n\\nPushwoosh.init({ \\\"pw_appid\\\" : \\\"PUSHWOOSH_APP_ID\\\" , \\\"project_number\\\" : \\\"GOOGLE_PROJECT_NUMBER\\\" });\\n\\nPushwoosh.register(\\n  (token) => {\\n    console.warn(\\\"Registered for push notifications with token: \\\" + token);\\n  },\\n  (error) => {\\n    console.warn(\\\"Failed to register for push notifications: \\\" + error);\\n  }\\n);\",\n      \"language\": \"javascript\",\n      \"name\": \"Example\"\n    }\n  ]\n}\n[/block]\n## Functions\n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"Functions\",\n    \"0-0\": \"[init](#section-init)(config, success, fail)\",\n    \"1-0\": \"[register](#section-register)(success, fail)\",\n    \"2-0\": \"[unregister](#section-unregister)(success, fail)\",\n    \"3-0\": \"[setTags](#section-settags)(tags, success, fail)\",\n    \"4-0\": \"[getTags](#section-gettags)(success, fail)\",\n    \"5-0\": \"[getPushToken](#section-getpushtoken)(success)\",\n    \"6-0\": \"[getHwid](#section-gethwid)(success)\",\n    \"7-0\": \"[setUserId](#section-setuserid)(userId)\",\n    \"8-0\": \"[postEvent](#section-postevent)(event, attributes)\",\n    \"0-1\": \"**[android, ios]** \\nInitializes Pushwoosh module with application ID and Google project number.\",\n    \"1-1\": \"**[android, ios]** \\nRegisters current device to receive push notifications.\",\n    \"2-1\": \"**[android, ios]** \\nUnregisters current deivce from receiving push notifications.\",\n    \"3-1\": \"**[android, ios]** \\nSets tags associated with current device and application.\",\n    \"4-1\": \"**[android, ios]** \\nGets tags associated with current device and application.\",\n    \"5-1\": \"**[android, ios]**\\nReturns push token or null if device is not registered to receive push notifications.\",\n    \"6-1\": \"**[android, ios]** \\nReturns Pushwoosh HWID used for communications with Pushwoosh API.\",\n    \"7-1\": \"**[android, ios]** \\nSets User Indentifier – a Facebook ID, username, email, or any other user ID. This allows data and events to be matched across multiple user devices.\",\n    \"8-1\": \"**[android, ios]** \\nPosts events for In-App Messages. This can trigger In-App message displayed as specified in Pushwoosh Control Panel.\",\n    \"9-0\": \"[startLocationTracking](#section-startlocationtracking)()\",\n    \"10-0\": \"[stopLocationTracking](#section-stoplocationtracking)()\",\n    \"11-0\": \"[setApplicationIconBadgeNumber](#section-setapplicationiconbadgenumber)(badgeNumber)\",\n    \"12-0\": \"[getApplicationIconBadgeNumber](#section-getapplicationiconbadgenumber)(callback)\",\n    \"13-0\": \"[addToApplicationIconBadgeNumber](#section-addtoapplicationiconbadgenumber)(badgeNumber)\",\n    \"14-0\": \"[setMultiNotificationMode](#section-setmultinotificationmode)(on)\",\n    \"15-0\": \"[setLightScreenOnNotification](#section-setlightscreenonnotification)(on)\",\n    \"16-0\": \"[setEnableLED](#section-setenableled)(on)\",\n    \"17-0\": \"[setColorLED](#section-setcolorled)(color)\",\n    \"18-0\": \"[setSoundType](#section-setsoundtype)(type)\",\n    \"19-0\": \"[setVibrateType](#section-setvibratetype)(type)\",\n    \"9-1\": \"**[android, ios]**\\nStarts geolocation-based push notifications. Geozones are configured in Pushwoosh Control panel.\",\n    \"10-1\": \"**[android, ios]**\\nStops geolocation-based push notifications.\",\n    \"11-1\": \"**[android, ios]**\\nSet application icon badge number.\",\n    \"12-1\": \"**[android, ios]**\\nReturns application icon badge number.\",\n    \"13-1\": \"**[android, ios]**\\nAdds value to application icon badge.\",\n    \"14-1\": \"**[android]**\\nAllows multiple notifications to be displayed in the Android Notification Center.\",\n    \"15-1\": \"**[android]**\\nTurns screen on if notification arrives.\",\n    \"16-1\": \"**[android]**\\nEnables LED blinking when notification arrives and display is off.\",\n    \"17-1\": \"**[android]**\\nSet LED color. Use with <setEnableLED>.\",\n    \"18-1\": \"**[android]**\\nSets default sound for incoming push notifications.\",\n    \"19-1\": \"**[android]**\\nSets default vibration mode for incoming push notifications.\"\n  },\n  \"cols\": 2,\n  \"rows\": 20\n}\n[/block]\n## Events\n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"Event\",\n    \"0-0\": \"[pushOpened](#section-pushopened)\",\n    \"0-1\": \"Push notification accept event.\"\n  },\n  \"cols\": 2,\n  \"rows\": 1\n}\n[/block]\n### init\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"init(config: Object, success: ?Function, fail: ?Function)\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]\n**[android, ios]** \nInitializes Pushwoosh module with application ID and Google project number.\n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"Parameter\",\n    \"h-1\": \"Description\",\n    \"0-0\": \"`config`\",\n    \"0-1\": \"Pushwoosh initialization config\",\n    \"1-0\": \"`config.pw_appid`\",\n    \"1-1\": \"Pushwoosh application ID\",\n    \"2-0\": \"`config.project_number`\",\n    \"3-0\": \"`success`\",\n    \"4-0\": \"`fail`\",\n    \"2-1\": \"GCM project number (for Android push notifications)\",\n    \"3-1\": \"(optional) initialization success callback\",\n    \"4-1\": \"(optional) initialization failure callback\"\n  },\n  \"cols\": 2,\n  \"rows\": 5\n}\n[/block]\n### register\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"register(success: ?Function, fail: ?Function)\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]\n**[android, ios]** \nRegisters current device to receive push notifications.\n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"Parameter\",\n    \"h-1\": \"Description\",\n    \"0-0\": \"`success`\",\n    \"1-0\": \"`fail`\",\n    \"0-1\": \"(optional) registration success callback. Receives push token as parameter\",\n    \"1-1\": \"(optional) registration failure callback\"\n  },\n  \"cols\": 2,\n  \"rows\": 2\n}\n[/block]\nNOTE: if the user does not allow the application to receive push notifications, and UIBackgroundModes remote-notificaion is not set in Info.plist, none of these callbacks will be called.\n\n### unregister\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"unregister(success: ?Function, fail: ?Function)\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]\n**[android, ios]** \nUnregisters current deivce from receiving push notifications.\n[block:parameters]\n{\n  \"data\": {\n    \"0-0\": \"`success`\",\n    \"1-0\": \"`fail`\",\n    \"0-1\": \"(optional) deregistration success callback\",\n    \"1-1\": \"(optional) deregistration failure callback\",\n    \"h-0\": \"Parameter\",\n    \"h-1\": \"Description\"\n  },\n  \"cols\": 2,\n  \"rows\": 2\n}\n[/block]\n### setTags\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"setTags(tags: Object, success: ?Function, fail: ?Function)\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]\n**[android, ios]** \nSets tags associated with current device and application.\n[block:parameters]\n{\n  \"data\": {\n    \"h-1\": \"Description\",\n    \"h-0\": \"Parameter\",\n    \"1-0\": \"`success`\",\n    \"2-0\": \"`fail`\",\n    \"0-0\": \"`tags`\",\n    \"0-1\": \"Tags associated with current device\",\n    \"1-1\": \"(optional) method success callback\",\n    \"2-1\": \"(optional) method failure callback\"\n  },\n  \"cols\": 2,\n  \"rows\": 3\n}\n[/block]\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"pushNotification.setTags({ \\\"string_tag\\\" : \\\"Hello world\\\", \\\"int_tag\\\" : 42, \\\"list_tag\\\":[\\\"hello\\\", \\\"world\\\"]});\",\n      \"language\": \"javascript\",\n      \"name\": \"Example\"\n    }\n  ]\n}\n[/block]\n### getTags\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"getTags(success: Function, fail: ?Function)\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]\n**[android, ios]** \nGets tags associated with current device and application.\n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"Parameter\",\n    \"h-1\": \"Description\",\n    \"0-0\": \"`success`\",\n    \"1-0\": \"`fail`\",\n    \"0-1\": \"(optional) method success callback. Receives object containing tags as parameter\",\n    \"1-1\": \"(optional) method failure callback\"\n  },\n  \"cols\": 2,\n  \"rows\": 2\n}\n[/block]\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"Pushwoosh.getTags(\\n    function(tags)\\n    {\\n        console.warn('tags for the device: ' + JSON.stringify(tags));\\n    },\\n    function(error)\\n    {\\n        console.warn('get tags error: ' + JSON.stringify(error));\\n    }\\n);\",\n      \"language\": \"javascript\",\n      \"name\": \"Example\"\n    }\n  ]\n}\n[/block]\n### getPushToken\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"getPushToken(success: Function)\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]\n**[android, ios]**\nReturns push token or null if device is not registered to receive push notifications.\n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"Parameter\",\n    \"h-1\": \"Description\",\n    \"0-0\": \"`success`\",\n    \"0-1\": \"Method success callback. Receives push token as a parameter\"\n  },\n  \"cols\": 2,\n  \"rows\": 1\n}\n[/block]\n### getHwid\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"getHwid(success: Function)\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]\n**[android, ios]** \nReturns Pushwoosh HWID used for communications with Pushwoosh API.\n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"Parameter\",\n    \"h-1\": \"Description\",\n    \"0-0\": \"`success`\",\n    \"0-1\": \"Method success callback. Receives Pushwoosh HWID as a parameter\"\n  },\n  \"cols\": 2,\n  \"rows\": 1\n}\n[/block]\n### setUserId\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"setUserId(userId: string)\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]\n**[android, ios]** \nSets User Indentifier – a Facebook ID, username, email, or any other user ID. This allows data and events to be matched across multiple user devices.\n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"Parameter\",\n    \"h-1\": \"Description\",\n    \"0-0\": \"`userId`\",\n    \"0-1\": \"Identifier of the currently logged user\"\n  },\n  \"cols\": 2,\n  \"rows\": 1\n}\n[/block]\n### postEvent\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"postEvent(event: string, attributes: ?Object)\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]\n**[android, ios]** \nPosts events for In-App Messages. This triggers displaying of In-App message as specified in Pushwoosh Control Panel.\n[block:parameters]\n{\n  \"data\": {\n    \"0-0\": \"`event`\",\n    \"1-0\": \"`attributes`\",\n    \"0-1\": \"Event name\",\n    \"1-1\": \"Additional event data\",\n    \"h-0\": \"Parameter\",\n    \"h-1\": \"Description\"\n  },\n  \"cols\": 2,\n  \"rows\": 2\n}\n[/block]\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"Pushwoosh.postEvent(\\\"buttonPressed\\\", { \\\"buttonNumber\\\" : \\\"4\\\", \\\"buttonLabel\\\" : \\\"Banner\\\" })\",\n      \"language\": \"javascript\",\n      \"name\": \"Example\"\n    }\n  ]\n}\n[/block]\n### startLocationTracking\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"startLocationTracking()\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]\n**[android, ios]** \nStarts geolocation-based push notifications. Geozones are configured in Pushwoosh Control panel.\nRequires geolocation permissions http://docs.pushwoosh.com/docs/androidmanifestxml-modifications#geozones-push-notifications, http://docs.pushwoosh.com/docs/customizing-ios-sdk#geozones-push-notifications.\n\n### stopLocationTracking\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"stopLocationTracking()\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]\n**[android, ios]**\nStops geolocation-based push notifications.\n\n### setApplicationIconBadgeNumber\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"setApplicationIconBadgeNumber(badgeNumber: number)\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]\n**[android, ios]** \nSet application icon badge number. Requires badge permissions http://docs.pushwoosh.com/docs/androidmanifestxml-modifications#using-badge-number-on-android.\n[block:parameters]\n{\n  \"data\": {\n    \"0-0\": \"`badgeNumber`\",\n    \"0-1\": \"Icon badge number\",\n    \"h-0\": \"Parameter\",\n    \"h-1\": \"Description\"\n  },\n  \"cols\": 2,\n  \"rows\": 1\n}\n[/block]\n### getApplicationIconBadgeNumber\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"getApplicationIconBadgeNumber(callback: Function)\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]\n**[android, ios]**\nReturns application icon badge number.\n[block:parameters]\n{\n  \"data\": {\n    \"0-0\": \"`callback`\",\n    \"0-1\": \"Success callback\",\n    \"h-0\": \"Parameter\",\n    \"h-1\": \"Description\"\n  },\n  \"cols\": 2,\n  \"rows\": 1\n}\n[/block]\n### addToApplicationIconBadgeNumber\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"addToApplicationIconBadgeNumber(badgeNumber: number)\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]\n**[android, ios]**\nAdds value to application icon badge. Requires badge permissions http://docs.pushwoosh.com/docs/androidmanifestxml-modifications#using-badge-number-on-android.\n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"Parameter\",\n    \"h-1\": \"Description\",\n    \"0-0\": \"`badgeNumber`\",\n    \"0-1\": \"Incremental icon badge number\"\n  },\n  \"cols\": 2,\n  \"rows\": 1\n}\n[/block]\n### setMultiNotificationMode\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"setMultiNotificationMode(on: boolean)\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]\n**[android]**\nAllows multiple notifications to be displayed in the Android Notification Center.\n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"Parameter\",\n    \"h-1\": \"Description\",\n    \"0-0\": \"`on`\",\n    \"0-1\": \"Enable/disable multiple notifications (is disabled by default)\"\n  },\n  \"cols\": 2,\n  \"rows\": 1\n}\n[/block]\n### setLightScreenOnNotification\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"setLightScreenOnNotification(on: boolean)\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]\n**[android]**\nTurns screen on when notification arrives.\n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"Parameter\",\n    \"h-1\": \"Description\",\n    \"0-0\": \"`on`\",\n    \"0-1\": \"Enable/disable screen unlock (is disabled by default)\"\n  },\n  \"cols\": 2,\n  \"rows\": 1\n}\n[/block]\n### setEnableLED\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"setEnableLED(on: boolean)\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]\n**[android]**\nEnables LED blinking when notification arrives and display is off.\n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"Parameter\",\n    \"h-1\": \"Description\",\n    \"0-0\": \"`on`\",\n    \"0-1\": \"Enable/disable LED blink (disabled by default)\"\n  },\n  \"cols\": 2,\n  \"rows\": 1\n}\n[/block]\n### setColorLED\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"setColorLED(color: number)\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]\n**[android]**\nSet led color. Use with [setEnableLED](#section-setenableled).\n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"Parameter\",\n    \"h-1\": \"Description\",\n    \"0-0\": \"`color`\",\n    \"0-1\": \"LED color in ARGB integer format\"\n  },\n  \"cols\": 2,\n  \"rows\": 1\n}\n[/block]\n### setSoundType\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"setSoundType(type: number)\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]\n**[android]** \nSets default sound for incoming push notifications.\n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"Parameter\",\n    \"h-1\": \"Description\",\n    \"0-1\": \"Sound type (0 – default, 1 – no sound, 2 – always)\",\n    \"0-0\": \"`type`\"\n  },\n  \"cols\": 2,\n  \"rows\": 1\n}\n[/block]\n### setVibrateType\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"setVibrateType(type: number)\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]\n**[android]** \nSets default vibration mode for incoming push notifications.\n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"Parameter\",\n    \"h-1\": \"Description\",\n    \"0-0\": \"`type`\",\n    \"0-1\": \"Vibration type (0 – default, 1 – no vibration, 2 – always)\"\n  },\n  \"cols\": 2,\n  \"rows\": 1\n}\n[/block]\n### pushOpened\n\n**[android, ios]**\nPush notification accept event launched when user clicks on push notification. \n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"DeviceEventEmitter.addListener('pushOpened', (e: Event) => {\\n  console.warn(\\\"pushOpened: \\\" + JSON.stringify(e));\\n  alert(JSON.stringify(e));\\n});\",\n      \"language\": \"javascript\",\n      \"name\": \"Example\"\n    }\n  ]\n}\n[/block]","excerpt":"","slug":"reactnative-api-reference","type":"basic","title":"Plugin API Reference"}

Plugin API Reference


[block:code] { "codes": [ { "code": "var Pushwoosh = require('pushwoosh-react-native-plugin');\n\nDeviceEventEmitter.addListener('pushOpened', (e: Event) => {\n console.warn(\"pushOpened: \" + JSON.stringify(e));\n alert(JSON.stringify(e));\n});\n\nPushwoosh.init({ \"pw_appid\" : \"PUSHWOOSH_APP_ID\" , \"project_number\" : \"GOOGLE_PROJECT_NUMBER\" });\n\nPushwoosh.register(\n (token) => {\n console.warn(\"Registered for push notifications with token: \" + token);\n },\n (error) => {\n console.warn(\"Failed to register for push notifications: \" + error);\n }\n);", "language": "javascript", "name": "Example" } ] } [/block] ## Functions [block:parameters] { "data": { "h-0": "Functions", "0-0": "[init](#section-init)(config, success, fail)", "1-0": "[register](#section-register)(success, fail)", "2-0": "[unregister](#section-unregister)(success, fail)", "3-0": "[setTags](#section-settags)(tags, success, fail)", "4-0": "[getTags](#section-gettags)(success, fail)", "5-0": "[getPushToken](#section-getpushtoken)(success)", "6-0": "[getHwid](#section-gethwid)(success)", "7-0": "[setUserId](#section-setuserid)(userId)", "8-0": "[postEvent](#section-postevent)(event, attributes)", "0-1": "**[android, ios]** \nInitializes Pushwoosh module with application ID and Google project number.", "1-1": "**[android, ios]** \nRegisters current device to receive push notifications.", "2-1": "**[android, ios]** \nUnregisters current deivce from receiving push notifications.", "3-1": "**[android, ios]** \nSets tags associated with current device and application.", "4-1": "**[android, ios]** \nGets tags associated with current device and application.", "5-1": "**[android, ios]**\nReturns push token or null if device is not registered to receive push notifications.", "6-1": "**[android, ios]** \nReturns Pushwoosh HWID used for communications with Pushwoosh API.", "7-1": "**[android, ios]** \nSets User Indentifier – a Facebook ID, username, email, or any other user ID. This allows data and events to be matched across multiple user devices.", "8-1": "**[android, ios]** \nPosts events for In-App Messages. This can trigger In-App message displayed as specified in Pushwoosh Control Panel.", "9-0": "[startLocationTracking](#section-startlocationtracking)()", "10-0": "[stopLocationTracking](#section-stoplocationtracking)()", "11-0": "[setApplicationIconBadgeNumber](#section-setapplicationiconbadgenumber)(badgeNumber)", "12-0": "[getApplicationIconBadgeNumber](#section-getapplicationiconbadgenumber)(callback)", "13-0": "[addToApplicationIconBadgeNumber](#section-addtoapplicationiconbadgenumber)(badgeNumber)", "14-0": "[setMultiNotificationMode](#section-setmultinotificationmode)(on)", "15-0": "[setLightScreenOnNotification](#section-setlightscreenonnotification)(on)", "16-0": "[setEnableLED](#section-setenableled)(on)", "17-0": "[setColorLED](#section-setcolorled)(color)", "18-0": "[setSoundType](#section-setsoundtype)(type)", "19-0": "[setVibrateType](#section-setvibratetype)(type)", "9-1": "**[android, ios]**\nStarts geolocation-based push notifications. Geozones are configured in Pushwoosh Control panel.", "10-1": "**[android, ios]**\nStops geolocation-based push notifications.", "11-1": "**[android, ios]**\nSet application icon badge number.", "12-1": "**[android, ios]**\nReturns application icon badge number.", "13-1": "**[android, ios]**\nAdds value to application icon badge.", "14-1": "**[android]**\nAllows multiple notifications to be displayed in the Android Notification Center.", "15-1": "**[android]**\nTurns screen on if notification arrives.", "16-1": "**[android]**\nEnables LED blinking when notification arrives and display is off.", "17-1": "**[android]**\nSet LED color. Use with <setEnableLED>.", "18-1": "**[android]**\nSets default sound for incoming push notifications.", "19-1": "**[android]**\nSets default vibration mode for incoming push notifications." }, "cols": 2, "rows": 20 } [/block] ## Events [block:parameters] { "data": { "h-0": "Event", "0-0": "[pushOpened](#section-pushopened)", "0-1": "Push notification accept event." }, "cols": 2, "rows": 1 } [/block] ### init [block:code] { "codes": [ { "code": "init(config: Object, success: ?Function, fail: ?Function)", "language": "javascript" } ] } [/block] **[android, ios]** Initializes Pushwoosh module with application ID and Google project number. [block:parameters] { "data": { "h-0": "Parameter", "h-1": "Description", "0-0": "`config`", "0-1": "Pushwoosh initialization config", "1-0": "`config.pw_appid`", "1-1": "Pushwoosh application ID", "2-0": "`config.project_number`", "3-0": "`success`", "4-0": "`fail`", "2-1": "GCM project number (for Android push notifications)", "3-1": "(optional) initialization success callback", "4-1": "(optional) initialization failure callback" }, "cols": 2, "rows": 5 } [/block] ### register [block:code] { "codes": [ { "code": "register(success: ?Function, fail: ?Function)", "language": "javascript" } ] } [/block] **[android, ios]** Registers current device to receive push notifications. [block:parameters] { "data": { "h-0": "Parameter", "h-1": "Description", "0-0": "`success`", "1-0": "`fail`", "0-1": "(optional) registration success callback. Receives push token as parameter", "1-1": "(optional) registration failure callback" }, "cols": 2, "rows": 2 } [/block] NOTE: if the user does not allow the application to receive push notifications, and UIBackgroundModes remote-notificaion is not set in Info.plist, none of these callbacks will be called. ### unregister [block:code] { "codes": [ { "code": "unregister(success: ?Function, fail: ?Function)", "language": "javascript" } ] } [/block] **[android, ios]** Unregisters current deivce from receiving push notifications. [block:parameters] { "data": { "0-0": "`success`", "1-0": "`fail`", "0-1": "(optional) deregistration success callback", "1-1": "(optional) deregistration failure callback", "h-0": "Parameter", "h-1": "Description" }, "cols": 2, "rows": 2 } [/block] ### setTags [block:code] { "codes": [ { "code": "setTags(tags: Object, success: ?Function, fail: ?Function)", "language": "javascript" } ] } [/block] **[android, ios]** Sets tags associated with current device and application. [block:parameters] { "data": { "h-1": "Description", "h-0": "Parameter", "1-0": "`success`", "2-0": "`fail`", "0-0": "`tags`", "0-1": "Tags associated with current device", "1-1": "(optional) method success callback", "2-1": "(optional) method failure callback" }, "cols": 2, "rows": 3 } [/block] [block:code] { "codes": [ { "code": "pushNotification.setTags({ \"string_tag\" : \"Hello world\", \"int_tag\" : 42, \"list_tag\":[\"hello\", \"world\"]});", "language": "javascript", "name": "Example" } ] } [/block] ### getTags [block:code] { "codes": [ { "code": "getTags(success: Function, fail: ?Function)", "language": "javascript" } ] } [/block] **[android, ios]** Gets tags associated with current device and application. [block:parameters] { "data": { "h-0": "Parameter", "h-1": "Description", "0-0": "`success`", "1-0": "`fail`", "0-1": "(optional) method success callback. Receives object containing tags as parameter", "1-1": "(optional) method failure callback" }, "cols": 2, "rows": 2 } [/block] [block:code] { "codes": [ { "code": "Pushwoosh.getTags(\n function(tags)\n {\n console.warn('tags for the device: ' + JSON.stringify(tags));\n },\n function(error)\n {\n console.warn('get tags error: ' + JSON.stringify(error));\n }\n);", "language": "javascript", "name": "Example" } ] } [/block] ### getPushToken [block:code] { "codes": [ { "code": "getPushToken(success: Function)", "language": "javascript" } ] } [/block] **[android, ios]** Returns push token or null if device is not registered to receive push notifications. [block:parameters] { "data": { "h-0": "Parameter", "h-1": "Description", "0-0": "`success`", "0-1": "Method success callback. Receives push token as a parameter" }, "cols": 2, "rows": 1 } [/block] ### getHwid [block:code] { "codes": [ { "code": "getHwid(success: Function)", "language": "javascript" } ] } [/block] **[android, ios]** Returns Pushwoosh HWID used for communications with Pushwoosh API. [block:parameters] { "data": { "h-0": "Parameter", "h-1": "Description", "0-0": "`success`", "0-1": "Method success callback. Receives Pushwoosh HWID as a parameter" }, "cols": 2, "rows": 1 } [/block] ### setUserId [block:code] { "codes": [ { "code": "setUserId(userId: string)", "language": "javascript" } ] } [/block] **[android, ios]** Sets User Indentifier – a Facebook ID, username, email, or any other user ID. This allows data and events to be matched across multiple user devices. [block:parameters] { "data": { "h-0": "Parameter", "h-1": "Description", "0-0": "`userId`", "0-1": "Identifier of the currently logged user" }, "cols": 2, "rows": 1 } [/block] ### postEvent [block:code] { "codes": [ { "code": "postEvent(event: string, attributes: ?Object)", "language": "javascript" } ] } [/block] **[android, ios]** Posts events for In-App Messages. This triggers displaying of In-App message as specified in Pushwoosh Control Panel. [block:parameters] { "data": { "0-0": "`event`", "1-0": "`attributes`", "0-1": "Event name", "1-1": "Additional event data", "h-0": "Parameter", "h-1": "Description" }, "cols": 2, "rows": 2 } [/block] [block:code] { "codes": [ { "code": "Pushwoosh.postEvent(\"buttonPressed\", { \"buttonNumber\" : \"4\", \"buttonLabel\" : \"Banner\" })", "language": "javascript", "name": "Example" } ] } [/block] ### startLocationTracking [block:code] { "codes": [ { "code": "startLocationTracking()", "language": "javascript" } ] } [/block] **[android, ios]** Starts geolocation-based push notifications. Geozones are configured in Pushwoosh Control panel. Requires geolocation permissions http://docs.pushwoosh.com/docs/androidmanifestxml-modifications#geozones-push-notifications, http://docs.pushwoosh.com/docs/customizing-ios-sdk#geozones-push-notifications. ### stopLocationTracking [block:code] { "codes": [ { "code": "stopLocationTracking()", "language": "javascript" } ] } [/block] **[android, ios]** Stops geolocation-based push notifications. ### setApplicationIconBadgeNumber [block:code] { "codes": [ { "code": "setApplicationIconBadgeNumber(badgeNumber: number)", "language": "javascript" } ] } [/block] **[android, ios]** Set application icon badge number. Requires badge permissions http://docs.pushwoosh.com/docs/androidmanifestxml-modifications#using-badge-number-on-android. [block:parameters] { "data": { "0-0": "`badgeNumber`", "0-1": "Icon badge number", "h-0": "Parameter", "h-1": "Description" }, "cols": 2, "rows": 1 } [/block] ### getApplicationIconBadgeNumber [block:code] { "codes": [ { "code": "getApplicationIconBadgeNumber(callback: Function)", "language": "javascript" } ] } [/block] **[android, ios]** Returns application icon badge number. [block:parameters] { "data": { "0-0": "`callback`", "0-1": "Success callback", "h-0": "Parameter", "h-1": "Description" }, "cols": 2, "rows": 1 } [/block] ### addToApplicationIconBadgeNumber [block:code] { "codes": [ { "code": "addToApplicationIconBadgeNumber(badgeNumber: number)", "language": "javascript" } ] } [/block] **[android, ios]** Adds value to application icon badge. Requires badge permissions http://docs.pushwoosh.com/docs/androidmanifestxml-modifications#using-badge-number-on-android. [block:parameters] { "data": { "h-0": "Parameter", "h-1": "Description", "0-0": "`badgeNumber`", "0-1": "Incremental icon badge number" }, "cols": 2, "rows": 1 } [/block] ### setMultiNotificationMode [block:code] { "codes": [ { "code": "setMultiNotificationMode(on: boolean)", "language": "javascript" } ] } [/block] **[android]** Allows multiple notifications to be displayed in the Android Notification Center. [block:parameters] { "data": { "h-0": "Parameter", "h-1": "Description", "0-0": "`on`", "0-1": "Enable/disable multiple notifications (is disabled by default)" }, "cols": 2, "rows": 1 } [/block] ### setLightScreenOnNotification [block:code] { "codes": [ { "code": "setLightScreenOnNotification(on: boolean)", "language": "javascript" } ] } [/block] **[android]** Turns screen on when notification arrives. [block:parameters] { "data": { "h-0": "Parameter", "h-1": "Description", "0-0": "`on`", "0-1": "Enable/disable screen unlock (is disabled by default)" }, "cols": 2, "rows": 1 } [/block] ### setEnableLED [block:code] { "codes": [ { "code": "setEnableLED(on: boolean)", "language": "javascript" } ] } [/block] **[android]** Enables LED blinking when notification arrives and display is off. [block:parameters] { "data": { "h-0": "Parameter", "h-1": "Description", "0-0": "`on`", "0-1": "Enable/disable LED blink (disabled by default)" }, "cols": 2, "rows": 1 } [/block] ### setColorLED [block:code] { "codes": [ { "code": "setColorLED(color: number)", "language": "javascript" } ] } [/block] **[android]** Set led color. Use with [setEnableLED](#section-setenableled). [block:parameters] { "data": { "h-0": "Parameter", "h-1": "Description", "0-0": "`color`", "0-1": "LED color in ARGB integer format" }, "cols": 2, "rows": 1 } [/block] ### setSoundType [block:code] { "codes": [ { "code": "setSoundType(type: number)", "language": "javascript" } ] } [/block] **[android]** Sets default sound for incoming push notifications. [block:parameters] { "data": { "h-0": "Parameter", "h-1": "Description", "0-1": "Sound type (0 – default, 1 – no sound, 2 – always)", "0-0": "`type`" }, "cols": 2, "rows": 1 } [/block] ### setVibrateType [block:code] { "codes": [ { "code": "setVibrateType(type: number)", "language": "javascript" } ] } [/block] **[android]** Sets default vibration mode for incoming push notifications. [block:parameters] { "data": { "h-0": "Parameter", "h-1": "Description", "0-0": "`type`", "0-1": "Vibration type (0 – default, 1 – no vibration, 2 – always)" }, "cols": 2, "rows": 1 } [/block] ### pushOpened **[android, ios]** Push notification accept event launched when user clicks on push notification. [block:code] { "codes": [ { "code": "DeviceEventEmitter.addListener('pushOpened', (e: Event) => {\n console.warn(\"pushOpened: \" + JSON.stringify(e));\n alert(JSON.stringify(e));\n});", "language": "javascript", "name": "Example" } ] } [/block]