{"__v":0,"_id":"581b1cc35798c01b0030d632","category":{"__v":0,"_id":"55b9ffa5d72d1e1900276a39","pages":[],"project":"5540ce1b31827a0d007ab1cc","version":"5540ce1c31827a0d007ab1cf","sync":{"url":"","isSync":false},"reference":false,"createdAt":"2015-07-30T10:42:45.253Z","from_sync":false,"order":15,"slug":"cordova-phonegap","title":"Cordova (PhoneGap)"},"parentDoc":null,"project":"5540ce1b31827a0d007ab1cc","user":"567bb6833241c20d00b730db","version":{"__v":31,"_id":"5540ce1c31827a0d007ab1cf","project":"5540ce1b31827a0d007ab1cc","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"},"updates":[],"next":{"pages":[],"description":""},"createdAt":"2016-11-03T11:17:23.637Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":2,"body":"[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"var pushwoosh = cordova.require(\\\"pushwoosh-cordova-plugin.PushNotification\\\");\\n\\n// Should be called before pushwoosh.onDeviceReady\\ndocument.addEventListener('push-notification', function(event) {\\n\\tvar notification = event.notification;\\n\\t// handle push open here\\n});\\n\\n// Initialize Pushwoosh. This will trigger all pending push notifications on start.\\npushwoosh.onDeviceReady({\\n\\tappid: \\\"XXXXX-XXXXX\\\",\\n\\tprojectid: \\\"XXXXXXXXXXXXXXX\\\",\\n\\tserviceName: \\\"XXXX\\\"\\n});\\n\\npushwoosh.registerDevice(\\n\\tfunction(status) {\\n\\t\\tvar pushToken = status.pushToken;\\n    \\t// handle successful registration here\\n  },\\n  function(status) {\\n    // handle registration error here\\n  }\\n);\",\n      \"language\": \"javascript\",\n      \"name\": \"Example\"\n    }\n  ]\n}\n[/block]\n\n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"Functions\",\n    \"h-1\": \"\",\n    \"0-0\": \"[onDeviceReady](#section-ondeviceready)(config)\",\n    \"1-0\": \"[registerDevice](#section-registerdevice)(success, fail)\",\n    \"2-0\": \"[unregisterDevice](#section-unregisterdevice)(success, fail)\",\n    \"3-0\": \"[setTags](#section-settags)(config, success, fail)\",\n    \"4-0\": \"[getTags](#section-gettags)(success, fail)\",\n    \"5-0\": \"[getPushToken](#section-getpushtoken)(success)\",\n    \"6-0\": \"[getPushwooshHWID](#section-getpushwooshhwid)(success)\",\n    \"7-0\": \"[startLocationTracking](#section-startlocationtracking)()\",\n    \"8-0\": \"[stopLocationTracking](#section-stoplocationtracking)()\",\n    \"9-0\": \"[getRemoteNotificationStatus](#section-getremotenotificationstatus)(callback, error)\",\n    \"10-0\": \"[setApplicationIconBadgeNumber](#section-setapplicationiconbadgenumber)(badgeNumber)\",\n    \"11-0\": \"[getApplicationIconBadgeNumber](#section-getapplicationiconbadgenumber)(callback)\",\n    \"12-0\": \"[addToApplicationIconBadgeNumber](#section-addtoapplicationiconbadgenumber)(badgeNumber)\",\n    \"13-0\": \"[getLaunchNotification](#section-getlaunchnotification)(callback)\",\n    \"14-0\": \"[clearLaunchNotification](#section-clearlaunchnotification)()\",\n    \"15-0\": \"[setUserId](#section-setuserid)(userId)\",\n    \"16-0\": \"[postEvent](#section-postevent)(event, attributes)\",\n    \"17-0\": \"[createLocalNotification](#section-createlocalnotification)(config, success, fail)\",\n    \"18-0\": \"[clearLocalNotification](#section-clearlocalnotification)()\",\n    \"19-0\": \"[clearNotificationCenter](#section-clearnotificationcenter)()\",\n    \"20-0\": \"[startBeaconPushes](#section-startbeaconpushes)()\",\n    \"21-0\": \"[stopBeaconPushes](#section-stopbeaconpushes)()\",\n    \"22-0\": \"[setBeaconBackgroundMode](#section-setbeaconbackgroundmode)(on)\",\n    \"23-0\": \"[setMultiNotificationMode](#section-setmultinotificationmode)()\",\n    \"24-0\": \"[setSingleNotificationMode](#section-setsinglenotificationmode)()\",\n    \"25-0\": \"[setSoundType](#section-setsoundtype)(type)\",\n    \"26-0\": \"[setVibrateType](#section-setvibratetype)(type)\",\n    \"27-0\": \"[setLightScreenOnNotification](#section-setlightscreenonnotification)(on)\",\n    \"28-0\": \"[setEnableLED](#section-setenableled)(on)\",\n    \"29-0\": \"[setColorLED](#section-setcolorled)(color)\",\n    \"30-0\": \"[getPushHistory](#section-getpushhistory)(callback)\",\n    \"31-0\": \"[clearPushHistory](#section-clearpushhistory)()\",\n    \"32-0\": \"[cancelAllLocalNotifications](#section-cancelalllocalnotifications)()\",\n    \"0-1\": \"**[android, ios, wp8, windows]** \\nInitializes Pushwoosh plugin and triggers a start push message. Should be called on every app launch.\",\n    \"1-1\": \"**[android, ios, wp8, windows]** \\nRegisters device for push notifications and retreives a push Token.\",\n    \"2-1\": \"**[android, ios, wp8, windows]** \\nUnregisters device from receiving push notifications.\",\n    \"3-1\": \"**[android, ios, wp8, windows]** \\nSets tags for the device.\",\n    \"4-1\": \"**[android, ios, wp8, windows]** \\nReturns tags for the device including default tags.\",\n    \"5-1\": \"**[android, ios, wp8, windows]** \\nReturns push token if it is available.\",\n    \"6-1\": \"**[android, ios, wp8, windows]** \\nReturns Pushwoosh HWID used for communications with Pushwoosh API.\",\n    \"7-1\": \"**[android, ios, wp8, windows]** \\nStarts geolocation-based push notifications.\",\n    \"8-1\": \"**[android, ios, wp8, windows]** \\nStops geolocation-based push notifications.\",\n    \"9-1\": \"**[android, ios]** \\nReturns a detailed status of push notification permissions.\",\n    \"10-1\": \"**[android, ios]** \\nSets the application icon badge number.\",\n    \"11-1\": \"**[android, ios]** \\nReturns the application icon badge number.\",\n    \"12-1\": \"**[android, ios]** \\nAdds value to the application icon badge.\",\n    \"13-1\": \"**[android, ios]** \\nReturns push notification payload if the app has been started in response to push notification or null.\",\n    \"14-1\": \"**[android, ios]** \\nClears launch notification, getLaunchNotification() will return null after this call.\",\n    \"15-1\": \"**[android, ios]** \\nSets User indentifier.\",\n    \"16-1\": \"**[android, ios]** \\nPosts events for In-App Messages.\",\n    \"17-1\": \"**[android]** \\nSchedules local notification.\",\n    \"18-1\": \"**[android]** \\nClears all pending local notifications created by /createLocalNotification.\",\n    \"19-1\": \"**[android]** \\nClears all notifications presented in Android Notification Center.\",\n    \"20-1\": \"**[android]** \\nStarts beacon tracking.\",\n    \"21-1\": \"**[android]** \\nStops beacon tracking.\",\n    \"22-1\": \"**[android]** \\nInforms plugin that app went to background mode (or vise versa).\",\n    \"23-1\": \"**[android]** \\nAllows multiple notifications to be displayed in the Android Notification Center.\",\n    \"24-1\": \"**[android]** \\nAllows only the last notification to be displayed in Android Notification Center.\",\n    \"25-1\": \"**[android]** \\nSets default sound as incoming notification chime.\",\n    \"26-1\": \"**[android]** \\nSets default vibration mode for incoming push. notifications.\",\n    \"27-1\": \"**[android]** \\nTurns screen on if notification arrives.\",\n    \"28-1\": \"**[android]** \\nEnables LED blinking when notification arrives and display is off.\",\n    \"29-1\": \"**[android]** \\nSets LED color.\",\n    \"30-1\": \"**[android]** \\nReturns array of push notifications received.\",\n    \"31-1\": \"**[android]** \\nClears push history.\",\n    \"32-1\": \"**[ios]** \\nClears all local notifications from notification center.\"\n  },\n  \"cols\": 2,\n  \"rows\": 33\n}\n[/block]\n\n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"Events\",\n    \"0-0\": \"[push-receive](#section-push-receive)\",\n    \"1-0\": \"[push-notification](#section-push-notification)\",\n    \"0-1\": \"**[android, ios]**\\nPush notification receive event.\",\n    \"1-1\": \"**[android, ios, wp8, windows]**\\nPush notification accept event.\"\n  },\n  \"cols\": 2,\n  \"rows\": 2\n}\n[/block]\n### onDeviceReady\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"PushNotification.prototype.onDeviceReady = function( config )\\n\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]\n*[android, ios, wp8, windows]*\nInitializes Pushwoosh plugin and triggers a start push message. Should be called on every app launch.\n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"Parameter\",\n    \"h-1\": \"Description\",\n    \"0-0\": \"`config.appid`\",\n    \"1-0\": \"`config.projectid`\",\n    \"2-0\": \"`config.serviceName`\",\n    \"0-1\": \"Pushwoosh application code.\",\n    \"1-1\": \"GCM project number for Android platform.\",\n    \"2-1\": \"MPNS service name for wp8 platform.\"\n  },\n  \"cols\": 2,\n  \"rows\": 3\n}\n[/block]\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"// initialize Pushwoosh with projectid: \\\"GOOGLE_PROJECT_NUMBER\\\", appid : \\\"PUSHWOOSH_APP_ID\\\", serviceName : \\\"WINDOWS_PHONE_SERVICE\\\". This will trigger all pending push notifications on start.\\npushwoosh.onDeviceReady({\\n    appid : \\\"XXXXX-XXXXX\\\",\\n    projectid: \\\"XXXXXXXXXXXXXXX\\\",\\n    serviceName: \\\"XXXX\\\"\\n});\",\n      \"language\": \"javascript\",\n      \"name\": \"Example\"\n    }\n  ]\n}\n[/block]\n### registerDevice\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"PushNotification.prototype.registerDevice = function( success, fail )\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]\n*[android, ios, wp8, windows]*\nRegisters device for push notifications and retreives a push Token.\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\": \"success callback.  Push token is passed as “status.pushToken” parameter to this callback\",\n    \"1-1\": \"error callback\"\n  },\n  \"cols\": 2,\n  \"rows\": 2\n}\n[/block]\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"pushwoosh.registerDevice(\\n    function(status) {\\n        alert(\\\"Registered with push token: \\\" + status.pushToken);\\n    },\\n    function(error) {\\n        alert(\\\"Failed to register: \\\" +  error);\\n    }\\n);\",\n      \"language\": \"javascript\",\n      \"name\": \"Example\"\n    }\n  ]\n}\n[/block]\n### unregisterDevice\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"PushNotification.prototype.unregisterDevice = function(\\tsuccess, fail\\t)\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]\n*[android, ios, wp8, windows]*\nUnregisters device from receiving push notifications.\n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"Parameter\",\n    \"h-1\": \"Description\",\n    \"0-0\": \"`success`\",\n    \"0-1\": \"success callback\",\n    \"1-0\": \"`fail`\",\n    \"1-1\": \"error callback\"\n  },\n  \"cols\": 2,\n  \"rows\": 2\n}\n[/block]\n### setTags\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"PushNotification.prototype.setTags = function(\\tconfig, success, fail\\t)\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]\n*[android, ios, wp8, windows]* \nSets tags for the device.\n\n**Parameters**\n[block:parameters]\n{\n  \"data\": {\n    \"0-0\": \"`config`\",\n    \"1-0\": \"`success`\",\n    \"2-0\": \"`fail`\",\n    \"0-1\": \"object with custom device tags\",\n    \"1-1\": \"success callback\",\n    \"2-1\": \"error callback\",\n    \"h-0\": \"Parameter\",\n    \"h-1\": \"Description\"\n  },\n  \"cols\": 2,\n  \"rows\": 3\n}\n[/block]\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"// sets tags: “deviceName” with value “hello” and “deviceId” with value 10\\npushwoosh.setTags({deviceName:\\\"hello\\\", deviceId:10},\\n    function() {\\n        console.warn('setTags success');\\n    },\\n    function(error) {\\n        console.warn('setTags failed');\\n    }\\n);\\n\\n// sets list tags \\\"MyTag\\\" with values (array) \\\"hello\\\", \\\"world\\\"\\npushwoosh.setTags({\\\"MyTag\\\":[\\\"hello\\\", \\\"world\\\"]});\",\n      \"language\": \"javascript\",\n      \"name\": \"Example\"\n    }\n  ]\n}\n[/block]\n### getTags\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"PushNotification.prototype.getTags = function(\\tsuccess, fail\\t)\",\n      \"language\": \"javascript\",\n      \"name\": \"Example\"\n    }\n  ]\n}\n[/block]\n*[android, ios, wp8, windows]* \nReturns tags for the device including default tags.\n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"Parameter\",\n    \"h-1\": \"Description\",\n    \"0-0\": \"`success `\",\n    \"0-1\": \"success callback.  Receives tags as parameter\",\n    \"1-0\": \"`fail`\",\n    \"1-1\": \"error 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        console.warn('tags for the device: ' + JSON.stringify(tags));\\n    },\\n    function(error) {\\n        console.warn('get tags error: ' + JSON.stringify(error));\\n    }\\n);\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]\n### getPushToken\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"PushNotification.prototype.getPushToken = function(\\tsuccess\\t)\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]\n*[android, ios, wp8, windows]*\nReturns push token if it is available.  Note that the token also comes in registerDevice function callback.\n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"Parameter\",\n    \"h-1\": \"Description\",\n    \"0-0\": \"`success`\",\n    \"0-1\": \"getPushToken callback\"\n  },\n  \"cols\": 2,\n  \"rows\": 1\n}\n[/block]\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"pushwoosh.getPushToken(\\n    function(token) {\\n        console.warn('push token: ' + token);\\n    }\\n);\",\n      \"language\": \"javascript\",\n      \"name\": \"Example\"\n    }\n  ]\n}\n[/block]\n### getPushwooshHWID\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"PushNotification.prototype.getPushwooshHWID = function(\\tsuccess\\t)\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]\n*[android, ios, wp8, windows]* \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\": \"getPushwooshHWID callback\"\n  },\n  \"cols\": 2,\n  \"rows\": 1\n}\n[/block]\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"pushwoosh.getPushwooshHWID(\\n    function(token) {\\n        console.warn('Pushwoosh HWID: ' + token);\\n    }\\n);\",\n      \"language\": \"javascript\",\n      \"name\": \"Example\"\n    }\n  ]\n}\n[/block]\n### startLocationTracking\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"PushNotification.prototype.startLocationTracking = function( success, fail\\t)\",\n      \"language\": \"javascript\",\n      \"name\": \"Example\"\n    }\n  ]\n}\n[/block]\n*[android, ios, wp8, windows]*\nStarts geolocation-based push notifications.  Geozones are configured in Pushwoosh Control panel.\n\n### stopLocationTracking\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"PushNotification.prototype.stopLocationTracking = function(\\tsuccess, fail\\t)\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]\n*[android, ios, wp8, windows]*\nStops geolocation-based push notifications.\n\n### getRemoteNotificationStatus\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"PushNotification.prototype.getRemoteNotificationStatus = function(\\tcallback, error\\t)\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]\n*[android, ios]*\nReturns detailed status of push notification permissions.\n[block:parameters]\n{\n  \"data\": {\n    \"0-0\": \"`callback`\",\n    \"1-0\": \"`error`\",\n    \"1-1\": \"error callback\",\n    \"0-1\": \"success callback\\nReceives object with following properties:\\n{\\n”enabled”\\t: notificaions enabled flag.\\n”pushBadge” : badges permission granted.  (iOS only)\\n”pushAlert” : alert permission granted.  (iOS only)\\n”pushSound” : sound permission granted.  (iOS only)\\n}\",\n    \"h-0\": \"Parameter\",\n    \"h-1\": \"Description\"\n  },\n  \"cols\": 2,\n  \"rows\": 2\n}\n[/block]\n### setApplicationIconBadgeNumber\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"PushNotification.prototype.setApplicationIconBadgeNumber = function(\\tbadgeNumber\\t)\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]\n*[android, ios]*\nSet the application icon badge number.\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\": \"PushNotification.prototype.getApplicationIconBadgeNumber = function(\\tcallback\\t)\",\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\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"pushwoosh.getApplicationIconBadgeNumber(function(badge){ alert(badge);} );\",\n      \"language\": \"javascript\",\n      \"name\": \"Example\"\n    }\n  ]\n}\n[/block]\n### addToApplicationIconBadgeNumber\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"PushNotification.prototype.addToApplicationIconBadgeNumber = function( badgeNumber )\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]\n*[android, ios]*\nAdds value to application icon badge.\n[block:parameters]\n{\n  \"data\": {\n    \"0-0\": \"`badgeNumber`\",\n    \"0-1\": \"incremental icon badge number\",\n    \"h-0\": \"Parameter\",\n    \"h-1\": \"Description\"\n  },\n  \"cols\": 2,\n  \"rows\": 1\n}\n[/block]\n### getLaunchNotification\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"PushNotification.prototype.getLaunchNotification = function(\\tcallback\\t)\",\n      \"language\": \"text\"\n    }\n  ]\n}\n[/block]\n*[android, ios]*\nReturns push notification payload if the app was started in response to a push notification, or null.\n\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### clearLaunchNotification\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"PushNotification.prototype.clearLaunchNotification = function(\\tcallback\\t)\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]\n*[android, ios]*\nClears launch notification, getLaunchNotification() will return null after this call.\n\n### setUserId\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"PushNotification.prototype.setUserId = function(\\tuserId\\t)\",\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    \"0-0\": \"`userId`\",\n    \"0-1\": \"user string identifier\",\n    \"h-0\": \"Parameter\",\n    \"h-1\": \"Description\"\n  },\n  \"cols\": 2,\n  \"rows\": 1\n}\n[/block]\n### postEvent\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"PushNotification.prototype.postEvent = function( event, attributes )\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]\n*[android, ios]*\nPosts events for In-App Messages.  This can trigger In-App message display as specified in Pushwoosh Control Panel.\n[block:parameters]\n{\n  \"data\": {\n    \"0-0\": \"`event`\",\n    \"1-0\": \"`attributes`\",\n    \"0-1\": \"event to trigger\",\n    \"1-1\": \"object with additional event attributes\",\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.setUserId(\\\"XXXXXX\\\");\\npushwoosh.postEvent(\\\"buttonPressed\\\", { \\\"buttonNumber\\\" : 4, \\\"buttonLabel\\\" : \\\"banner\\\" });\",\n      \"language\": \"javascript\",\n      \"name\": \"Example\"\n    }\n  ]\n}\n[/block]\n### createLocalNotification\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"PushNotification.prototype.createLocalNotification = function( config, success, fail )\\n\",\n      \"language\": \"text\"\n    }\n  ]\n}\n[/block]\n*[android]*\nSchedules local notification.\n[block:parameters]\n{\n  \"data\": {\n    \"0-0\": \"`config.msg`\",\n    \"0-1\": \"notification message\",\n    \"1-0\": \"`config.seconds`\",\n    \"1-1\": \"notification delay in seconds\",\n    \"2-0\": \"`config.userData`\",\n    \"2-1\": \"additional data to pass in notification\",\n    \"3-0\": \"`success `\",\n    \"3-1\": \"success callback\",\n    \"4-0\": \"`fail`\",\n    \"4-1\": \"error callback\",\n    \"h-0\": \"Parameter\",\n    \"h-1\": \"Description\"\n  },\n  \"cols\": 2,\n  \"rows\": 5\n}\n[/block]\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"pushwoosh.createLocalNotification({msg:\\\"Your pumpkins are ready!\\\", seconds:30, userData:\\\"optional\\\"}\",\n      \"language\": \"javascript\",\n      \"name\": \"Example\"\n    }\n  ]\n}\n[/block]\n### clearLocalNotification\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"PushNotification.prototype.clearLocalNotification = function()\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]\n*[android]*\nClears all pending local notifications created by [createLocalNotification](#section-createlocatlnotification)\n\n### clearNotificationCenter\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"PushNotification.prototype.clearNotificationCenter = function()\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]\n*[android]*\nClears all notifications presented in Android Notification Center.\n\n### startBeaconPushes\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"\\nPushNotification.prototype.startBeaconPushes = function( success, fail )\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]\n*[android]*\nStarts beacon tracking.\n\n### stopBeaconPushes\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"PushNotification.prototype.stopBeaconPushes = function( success, fail )\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]\n*[android]*\nStops beacon tracking.\n\n### setBeaconBackgroundMode\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"PushNotification.prototype.setBeaconBackgroundMode = function( on, success, fail )\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]\n*[android]*\nInforms plugin that app went to background mode (or vise versa).  Call when going to background when using beacons.\n\n### setMultiNotificationMode\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"PushNotification.prototype.setMultiNotificationMode = function( success, fail )\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]\n*[android]*\nAllows multiple notifications to be displayed in the Android Notification Center.\n\n### setSingleNotificationMode\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"PushNotification.prototype.setSingleNotificationMode = function(\\tsuccess,\\nfail\\t)\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]\n*[android]* \nAllows only the last notification to be displayed in Android Notification Center.\n\n### setSoundType\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"PushNotification.prototype.setSoundType = function( type, success, fail )\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]\n*[android]*\nSets default sound for incoming pushes.\n[block:parameters]\n{\n  \"data\": {\n    \"0-0\": \"`type`\",\n    \"0-1\": \"Sound type (0 – default, 1 – no sound, 2 – always)\",\n    \"h-0\": \"Parameter\",\n    \"h-1\": \"Description\"\n  },\n  \"cols\": 2,\n  \"rows\": 1\n}\n[/block]\n### setVibrateType\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"PushNotification.prototype.setVibrateType = function(type, success, fail )\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]\n*[android]*\nSets default vibration mode for incoming pushes.\n[block:parameters]\n{\n  \"data\": {\n    \"0-0\": \"`type`\",\n    \"0-1\": \"Vibration type (0 – default, 1 – no vibration, 2 – always)\",\n    \"h-0\": \"Parameter\",\n    \"h-1\": \"Description\"\n  },\n  \"cols\": 2,\n  \"rows\": 1\n}\n[/block]\n### setLightScreenOnNotification\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"PushNotification.prototype.setLightScreenOnNotification = function( on, success, fail )\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]\n*[android]* \nTurns screen on when notification arrives.\n[block:parameters]\n{\n  \"data\": {\n    \"0-0\": \"`on`\",\n    \"0-1\": \"enable/disable screen unlock (disabled by default)\",\n    \"h-0\": \"Parameter\",\n    \"h-1\": \"Description\"\n  },\n  \"cols\": 2,\n  \"rows\": 1\n}\n[/block]\n### setEnableLED\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"PushNotification.prototype.setEnableLED = function( on, success, fail )\",\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    \"0-0\": \"`on`\",\n    \"0-1\": \"enable/disable LED blink (disabled by default)\",\n    \"h-0\": \"Parameter\",\n    \"h-1\": \"Description\"\n  },\n  \"cols\": 2,\n  \"rows\": 1\n}\n[/block]\n### setColorLED\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"PushNotification.prototype.setColorLED = function( color, success, fail )\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]\n*[android]*\nSets led color.  Use with [setEnableLED](#setction-setenableled).\n[block:parameters]\n{\n  \"data\": {\n    \"0-0\": \"`color`\",\n    \"0-1\": \"LED color in ARGB integer format\",\n    \"h-0\": \"Parameter\",\n    \"h-1\": \"Description\"\n  },\n  \"cols\": 2,\n  \"rows\": 1\n}\n[/block]\n### getPushHistory\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"PushNotification.prototype.getPushHistory = function(\\tsuccess\\t)\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]\n*[android]*\nReturns array of received push notifications.\n[block:parameters]\n{\n  \"data\": {\n    \"0-0\": \"`success`\",\n    \"0-1\": \"success callback\",\n    \"h-0\": \"Parameter\",\n    \"h-1\": \"Description\"\n  },\n  \"cols\": 2,\n  \"rows\": 1\n}\n[/block]\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"pushwoosh.getPushHistory(function(pushHistory) {\\n    if(pushHistory.length == 0)\\n        alert(\\\"no push history\\\");\\n    else\\n        alert(JSON.stringify(pushHistory));\\n});\\n\\npushwoosh.clearPushHistory();\",\n      \"language\": \"javascript\",\n      \"name\": \"Example\"\n    }\n  ]\n}\n[/block]\n### clearPushHistory\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"PushNotification.prototype.clearPushHistory = function()\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]\n*[android]*\nClears push history.\n\n### cancelAllLocalNotifications\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"PushNotification.prototype.cancelAllLocalNotifications = function( callback )\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]\n*[ios]*\nClears all local notifications from the notification center.\n\n### push-receive\n\n*[android, ios]*\nPush notification receive event. Is fired when application receives push notification in foreground or background. Closed applications does not receive this event.\n\n**Event properties**\n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"Property\",\n    \"0-0\": \"`message`\",\n    \"0-1\": \"(`string`) Push notification message\",\n    \"1-0\": \"`userdata`\",\n    \"1-1\": \"(`object`/`array`) Push notification custom data\",\n    \"2-0\": \"`onStart`\",\n    \"2-1\": \"(`boolean`) Is launch notification\",\n    \"3-0\": \"`foreground`\",\n    \"3-1\": \"(`boolean`) Is notification received in foreground\",\n    \"4-0\": \"`android`\",\n    \"4-1\": \"(`object`) Android specific notification payload\",\n    \"5-0\": \"`ios`\",\n    \"5-1\": \"(`object`) iOS specific notification payload\",\n    \"6-0\": \"`wp8`\",\n    \"6-1\": \"(`object`) Windows Phone specific notification payload\",\n    \"7-0\": \"`windows`\",\n    \"7-1\": \"(`object`) Windows specific notification payload\"\n  },\n  \"cols\": 2,\n  \"rows\": 8\n}\n[/block]\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"document.addEventListener('push-receive',\\n\\tfunction(event) {\\n\\t\\tvar userData = event.notification.userdata;\\n\\n\\t\\tif (typeof(userData) != \\\"undefined\\\") {\\n\\t\\t\\t// handle custom notification data\\n\\t\\t\\tconsole.warn('user data: ' + JSON.stringify(userData));\\n\\t\\t}\\n\\t}\\n);\",\n      \"language\": \"javascript\",\n      \"name\": \"Example\"\n    }\n  ]\n}\n[/block]\n### push-notification\n\n*[android, ios, wp8, windows]*\nPush notification accept event. Is fired when user clicks on push notification.\n[block:callout]\n{\n  \"type\": \"info\",\n  \"title\": \"Foreground notifications\",\n  \"body\": \"By default Pushwoosh plugin does not display notifications in the foreground and automatically triggers `push-notification` event. See [plugin customization guide](http://docs.pushwoosh.com/docs/customizing-cordova-plugin#push-notifications-in-foreground) for controlling this behaviour.\"\n}\n[/block]\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"document.addEventListener('push-notification',\\n\\tfunction(event) {\\n\\t\\tvar message = event.notification.message;\\n\\t\\tvar userData = event.notification.userdata;\\n\\n\\t\\tif (typeof(userData) != \\\"undefined\\\") {\\n\\t\\t\\tconsole.warn('user data: ' + JSON.stringify(userData));\\n\\t\\t}\\n\\t}\\n);\",\n      \"language\": \"javascript\",\n      \"name\": \"Example\"\n    }\n  ]\n}\n[/block]\n**Event properties**\n\nSame as [push-receive](#section-push-receive)","excerpt":"","slug":"cordova-api-reference","type":"basic","title":"Plugin API Reference"}

Plugin API Reference


[block:code] { "codes": [ { "code": "var pushwoosh = cordova.require(\"pushwoosh-cordova-plugin.PushNotification\");\n\n// Should be called before pushwoosh.onDeviceReady\ndocument.addEventListener('push-notification', function(event) {\n\tvar notification = event.notification;\n\t// handle push open here\n});\n\n// Initialize Pushwoosh. This will trigger all pending push notifications on start.\npushwoosh.onDeviceReady({\n\tappid: \"XXXXX-XXXXX\",\n\tprojectid: \"XXXXXXXXXXXXXXX\",\n\tserviceName: \"XXXX\"\n});\n\npushwoosh.registerDevice(\n\tfunction(status) {\n\t\tvar pushToken = status.pushToken;\n \t// handle successful registration here\n },\n function(status) {\n // handle registration error here\n }\n);", "language": "javascript", "name": "Example" } ] } [/block] [block:parameters] { "data": { "h-0": "Functions", "h-1": "", "0-0": "[onDeviceReady](#section-ondeviceready)(config)", "1-0": "[registerDevice](#section-registerdevice)(success, fail)", "2-0": "[unregisterDevice](#section-unregisterdevice)(success, fail)", "3-0": "[setTags](#section-settags)(config, success, fail)", "4-0": "[getTags](#section-gettags)(success, fail)", "5-0": "[getPushToken](#section-getpushtoken)(success)", "6-0": "[getPushwooshHWID](#section-getpushwooshhwid)(success)", "7-0": "[startLocationTracking](#section-startlocationtracking)()", "8-0": "[stopLocationTracking](#section-stoplocationtracking)()", "9-0": "[getRemoteNotificationStatus](#section-getremotenotificationstatus)(callback, error)", "10-0": "[setApplicationIconBadgeNumber](#section-setapplicationiconbadgenumber)(badgeNumber)", "11-0": "[getApplicationIconBadgeNumber](#section-getapplicationiconbadgenumber)(callback)", "12-0": "[addToApplicationIconBadgeNumber](#section-addtoapplicationiconbadgenumber)(badgeNumber)", "13-0": "[getLaunchNotification](#section-getlaunchnotification)(callback)", "14-0": "[clearLaunchNotification](#section-clearlaunchnotification)()", "15-0": "[setUserId](#section-setuserid)(userId)", "16-0": "[postEvent](#section-postevent)(event, attributes)", "17-0": "[createLocalNotification](#section-createlocalnotification)(config, success, fail)", "18-0": "[clearLocalNotification](#section-clearlocalnotification)()", "19-0": "[clearNotificationCenter](#section-clearnotificationcenter)()", "20-0": "[startBeaconPushes](#section-startbeaconpushes)()", "21-0": "[stopBeaconPushes](#section-stopbeaconpushes)()", "22-0": "[setBeaconBackgroundMode](#section-setbeaconbackgroundmode)(on)", "23-0": "[setMultiNotificationMode](#section-setmultinotificationmode)()", "24-0": "[setSingleNotificationMode](#section-setsinglenotificationmode)()", "25-0": "[setSoundType](#section-setsoundtype)(type)", "26-0": "[setVibrateType](#section-setvibratetype)(type)", "27-0": "[setLightScreenOnNotification](#section-setlightscreenonnotification)(on)", "28-0": "[setEnableLED](#section-setenableled)(on)", "29-0": "[setColorLED](#section-setcolorled)(color)", "30-0": "[getPushHistory](#section-getpushhistory)(callback)", "31-0": "[clearPushHistory](#section-clearpushhistory)()", "32-0": "[cancelAllLocalNotifications](#section-cancelalllocalnotifications)()", "0-1": "**[android, ios, wp8, windows]** \nInitializes Pushwoosh plugin and triggers a start push message. Should be called on every app launch.", "1-1": "**[android, ios, wp8, windows]** \nRegisters device for push notifications and retreives a push Token.", "2-1": "**[android, ios, wp8, windows]** \nUnregisters device from receiving push notifications.", "3-1": "**[android, ios, wp8, windows]** \nSets tags for the device.", "4-1": "**[android, ios, wp8, windows]** \nReturns tags for the device including default tags.", "5-1": "**[android, ios, wp8, windows]** \nReturns push token if it is available.", "6-1": "**[android, ios, wp8, windows]** \nReturns Pushwoosh HWID used for communications with Pushwoosh API.", "7-1": "**[android, ios, wp8, windows]** \nStarts geolocation-based push notifications.", "8-1": "**[android, ios, wp8, windows]** \nStops geolocation-based push notifications.", "9-1": "**[android, ios]** \nReturns a detailed status of push notification permissions.", "10-1": "**[android, ios]** \nSets the application icon badge number.", "11-1": "**[android, ios]** \nReturns the application icon badge number.", "12-1": "**[android, ios]** \nAdds value to the application icon badge.", "13-1": "**[android, ios]** \nReturns push notification payload if the app has been started in response to push notification or null.", "14-1": "**[android, ios]** \nClears launch notification, getLaunchNotification() will return null after this call.", "15-1": "**[android, ios]** \nSets User indentifier.", "16-1": "**[android, ios]** \nPosts events for In-App Messages.", "17-1": "**[android]** \nSchedules local notification.", "18-1": "**[android]** \nClears all pending local notifications created by /createLocalNotification.", "19-1": "**[android]** \nClears all notifications presented in Android Notification Center.", "20-1": "**[android]** \nStarts beacon tracking.", "21-1": "**[android]** \nStops beacon tracking.", "22-1": "**[android]** \nInforms plugin that app went to background mode (or vise versa).", "23-1": "**[android]** \nAllows multiple notifications to be displayed in the Android Notification Center.", "24-1": "**[android]** \nAllows only the last notification to be displayed in Android Notification Center.", "25-1": "**[android]** \nSets default sound as incoming notification chime.", "26-1": "**[android]** \nSets default vibration mode for incoming push. notifications.", "27-1": "**[android]** \nTurns screen on if notification arrives.", "28-1": "**[android]** \nEnables LED blinking when notification arrives and display is off.", "29-1": "**[android]** \nSets LED color.", "30-1": "**[android]** \nReturns array of push notifications received.", "31-1": "**[android]** \nClears push history.", "32-1": "**[ios]** \nClears all local notifications from notification center." }, "cols": 2, "rows": 33 } [/block] [block:parameters] { "data": { "h-0": "Events", "0-0": "[push-receive](#section-push-receive)", "1-0": "[push-notification](#section-push-notification)", "0-1": "**[android, ios]**\nPush notification receive event.", "1-1": "**[android, ios, wp8, windows]**\nPush notification accept event." }, "cols": 2, "rows": 2 } [/block] ### onDeviceReady [block:code] { "codes": [ { "code": "PushNotification.prototype.onDeviceReady = function( config )\n", "language": "javascript" } ] } [/block] *[android, ios, wp8, windows]* Initializes Pushwoosh plugin and triggers a start push message. Should be called on every app launch. [block:parameters] { "data": { "h-0": "Parameter", "h-1": "Description", "0-0": "`config.appid`", "1-0": "`config.projectid`", "2-0": "`config.serviceName`", "0-1": "Pushwoosh application code.", "1-1": "GCM project number for Android platform.", "2-1": "MPNS service name for wp8 platform." }, "cols": 2, "rows": 3 } [/block] [block:code] { "codes": [ { "code": "// initialize Pushwoosh with projectid: \"GOOGLE_PROJECT_NUMBER\", appid : \"PUSHWOOSH_APP_ID\", serviceName : \"WINDOWS_PHONE_SERVICE\". This will trigger all pending push notifications on start.\npushwoosh.onDeviceReady({\n appid : \"XXXXX-XXXXX\",\n projectid: \"XXXXXXXXXXXXXXX\",\n serviceName: \"XXXX\"\n});", "language": "javascript", "name": "Example" } ] } [/block] ### registerDevice [block:code] { "codes": [ { "code": "PushNotification.prototype.registerDevice = function( success, fail )", "language": "javascript" } ] } [/block] *[android, ios, wp8, windows]* Registers device for push notifications and retreives a push Token. [block:parameters] { "data": { "h-0": "Parameter", "h-1": "Description", "0-0": "`success`", "1-0": "`fail`", "0-1": "success callback. Push token is passed as “status.pushToken” parameter to this callback", "1-1": "error callback" }, "cols": 2, "rows": 2 } [/block] [block:code] { "codes": [ { "code": "pushwoosh.registerDevice(\n function(status) {\n alert(\"Registered with push token: \" + status.pushToken);\n },\n function(error) {\n alert(\"Failed to register: \" + error);\n }\n);", "language": "javascript", "name": "Example" } ] } [/block] ### unregisterDevice [block:code] { "codes": [ { "code": "PushNotification.prototype.unregisterDevice = function(\tsuccess, fail\t)", "language": "javascript" } ] } [/block] *[android, ios, wp8, windows]* Unregisters device from receiving push notifications. [block:parameters] { "data": { "h-0": "Parameter", "h-1": "Description", "0-0": "`success`", "0-1": "success callback", "1-0": "`fail`", "1-1": "error callback" }, "cols": 2, "rows": 2 } [/block] ### setTags [block:code] { "codes": [ { "code": "PushNotification.prototype.setTags = function(\tconfig, success, fail\t)", "language": "javascript" } ] } [/block] *[android, ios, wp8, windows]* Sets tags for the device. **Parameters** [block:parameters] { "data": { "0-0": "`config`", "1-0": "`success`", "2-0": "`fail`", "0-1": "object with custom device tags", "1-1": "success callback", "2-1": "error callback", "h-0": "Parameter", "h-1": "Description" }, "cols": 2, "rows": 3 } [/block] [block:code] { "codes": [ { "code": "// sets tags: “deviceName” with value “hello” and “deviceId” with value 10\npushwoosh.setTags({deviceName:\"hello\", deviceId:10},\n function() {\n console.warn('setTags success');\n },\n function(error) {\n console.warn('setTags failed');\n }\n);\n\n// sets list tags \"MyTag\" with values (array) \"hello\", \"world\"\npushwoosh.setTags({\"MyTag\":[\"hello\", \"world\"]});", "language": "javascript", "name": "Example" } ] } [/block] ### getTags [block:code] { "codes": [ { "code": "PushNotification.prototype.getTags = function(\tsuccess, fail\t)", "language": "javascript", "name": "Example" } ] } [/block] *[android, ios, wp8, windows]* Returns tags for the device including default tags. [block:parameters] { "data": { "h-0": "Parameter", "h-1": "Description", "0-0": "`success `", "0-1": "success callback. Receives tags as parameter", "1-0": "`fail`", "1-1": "error callback" }, "cols": 2, "rows": 2 } [/block] [block:code] { "codes": [ { "code": "pushwoosh.getTags(\n function(tags) {\n console.warn('tags for the device: ' + JSON.stringify(tags));\n },\n function(error) {\n console.warn('get tags error: ' + JSON.stringify(error));\n }\n);", "language": "javascript" } ] } [/block] ### getPushToken [block:code] { "codes": [ { "code": "PushNotification.prototype.getPushToken = function(\tsuccess\t)", "language": "javascript" } ] } [/block] *[android, ios, wp8, windows]* Returns push token if it is available. Note that the token also comes in registerDevice function callback. [block:parameters] { "data": { "h-0": "Parameter", "h-1": "Description", "0-0": "`success`", "0-1": "getPushToken callback" }, "cols": 2, "rows": 1 } [/block] [block:code] { "codes": [ { "code": "pushwoosh.getPushToken(\n function(token) {\n console.warn('push token: ' + token);\n }\n);", "language": "javascript", "name": "Example" } ] } [/block] ### getPushwooshHWID [block:code] { "codes": [ { "code": "PushNotification.prototype.getPushwooshHWID = function(\tsuccess\t)", "language": "javascript" } ] } [/block] *[android, ios, wp8, windows]* Returns Pushwoosh HWID used for communications with Pushwoosh API. [block:parameters] { "data": { "h-0": "Parameter", "h-1": "Description", "0-0": "`success`", "0-1": "getPushwooshHWID callback" }, "cols": 2, "rows": 1 } [/block] [block:code] { "codes": [ { "code": "pushwoosh.getPushwooshHWID(\n function(token) {\n console.warn('Pushwoosh HWID: ' + token);\n }\n);", "language": "javascript", "name": "Example" } ] } [/block] ### startLocationTracking [block:code] { "codes": [ { "code": "PushNotification.prototype.startLocationTracking = function( success, fail\t)", "language": "javascript", "name": "Example" } ] } [/block] *[android, ios, wp8, windows]* Starts geolocation-based push notifications. Geozones are configured in Pushwoosh Control panel. ### stopLocationTracking [block:code] { "codes": [ { "code": "PushNotification.prototype.stopLocationTracking = function(\tsuccess, fail\t)", "language": "javascript" } ] } [/block] *[android, ios, wp8, windows]* Stops geolocation-based push notifications. ### getRemoteNotificationStatus [block:code] { "codes": [ { "code": "PushNotification.prototype.getRemoteNotificationStatus = function(\tcallback, error\t)", "language": "javascript" } ] } [/block] *[android, ios]* Returns detailed status of push notification permissions. [block:parameters] { "data": { "0-0": "`callback`", "1-0": "`error`", "1-1": "error callback", "0-1": "success callback\nReceives object with following properties:\n{\n”enabled”\t: notificaions enabled flag.\n”pushBadge” : badges permission granted. (iOS only)\n”pushAlert” : alert permission granted. (iOS only)\n”pushSound” : sound permission granted. (iOS only)\n}", "h-0": "Parameter", "h-1": "Description" }, "cols": 2, "rows": 2 } [/block] ### setApplicationIconBadgeNumber [block:code] { "codes": [ { "code": "PushNotification.prototype.setApplicationIconBadgeNumber = function(\tbadgeNumber\t)", "language": "javascript" } ] } [/block] *[android, ios]* Set the application icon badge number. [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": "PushNotification.prototype.getApplicationIconBadgeNumber = function(\tcallback\t)", "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] [block:code] { "codes": [ { "code": "pushwoosh.getApplicationIconBadgeNumber(function(badge){ alert(badge);} );", "language": "javascript", "name": "Example" } ] } [/block] ### addToApplicationIconBadgeNumber [block:code] { "codes": [ { "code": "PushNotification.prototype.addToApplicationIconBadgeNumber = function( badgeNumber )", "language": "javascript" } ] } [/block] *[android, ios]* Adds value to application icon badge. [block:parameters] { "data": { "0-0": "`badgeNumber`", "0-1": "incremental icon badge number", "h-0": "Parameter", "h-1": "Description" }, "cols": 2, "rows": 1 } [/block] ### getLaunchNotification [block:code] { "codes": [ { "code": "PushNotification.prototype.getLaunchNotification = function(\tcallback\t)", "language": "text" } ] } [/block] *[android, ios]* Returns push notification payload if the app was started in response to a push notification, or null. [block:parameters] { "data": { "0-0": "`callback`", "0-1": "success callback", "h-0": "Parameter", "h-1": "Description" }, "cols": 2, "rows": 1 } [/block] ### clearLaunchNotification [block:code] { "codes": [ { "code": "PushNotification.prototype.clearLaunchNotification = function(\tcallback\t)", "language": "javascript" } ] } [/block] *[android, ios]* Clears launch notification, getLaunchNotification() will return null after this call. ### setUserId [block:code] { "codes": [ { "code": "PushNotification.prototype.setUserId = function(\tuserId\t)", "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": { "0-0": "`userId`", "0-1": "user string identifier", "h-0": "Parameter", "h-1": "Description" }, "cols": 2, "rows": 1 } [/block] ### postEvent [block:code] { "codes": [ { "code": "PushNotification.prototype.postEvent = function( event, attributes )", "language": "javascript" } ] } [/block] *[android, ios]* Posts events for In-App Messages. This can trigger In-App message display as specified in Pushwoosh Control Panel. [block:parameters] { "data": { "0-0": "`event`", "1-0": "`attributes`", "0-1": "event to trigger", "1-1": "object with additional event attributes", "h-0": "Parameter", "h-1": "Description" }, "cols": 2, "rows": 2 } [/block] [block:code] { "codes": [ { "code": "pushwoosh.setUserId(\"XXXXXX\");\npushwoosh.postEvent(\"buttonPressed\", { \"buttonNumber\" : 4, \"buttonLabel\" : \"banner\" });", "language": "javascript", "name": "Example" } ] } [/block] ### createLocalNotification [block:code] { "codes": [ { "code": "PushNotification.prototype.createLocalNotification = function( config, success, fail )\n", "language": "text" } ] } [/block] *[android]* Schedules local notification. [block:parameters] { "data": { "0-0": "`config.msg`", "0-1": "notification message", "1-0": "`config.seconds`", "1-1": "notification delay in seconds", "2-0": "`config.userData`", "2-1": "additional data to pass in notification", "3-0": "`success `", "3-1": "success callback", "4-0": "`fail`", "4-1": "error callback", "h-0": "Parameter", "h-1": "Description" }, "cols": 2, "rows": 5 } [/block] [block:code] { "codes": [ { "code": "pushwoosh.createLocalNotification({msg:\"Your pumpkins are ready!\", seconds:30, userData:\"optional\"}", "language": "javascript", "name": "Example" } ] } [/block] ### clearLocalNotification [block:code] { "codes": [ { "code": "PushNotification.prototype.clearLocalNotification = function()", "language": "javascript" } ] } [/block] *[android]* Clears all pending local notifications created by [createLocalNotification](#section-createlocatlnotification) ### clearNotificationCenter [block:code] { "codes": [ { "code": "PushNotification.prototype.clearNotificationCenter = function()", "language": "javascript" } ] } [/block] *[android]* Clears all notifications presented in Android Notification Center. ### startBeaconPushes [block:code] { "codes": [ { "code": "\nPushNotification.prototype.startBeaconPushes = function( success, fail )", "language": "javascript" } ] } [/block] *[android]* Starts beacon tracking. ### stopBeaconPushes [block:code] { "codes": [ { "code": "PushNotification.prototype.stopBeaconPushes = function( success, fail )", "language": "javascript" } ] } [/block] *[android]* Stops beacon tracking. ### setBeaconBackgroundMode [block:code] { "codes": [ { "code": "PushNotification.prototype.setBeaconBackgroundMode = function( on, success, fail )", "language": "javascript" } ] } [/block] *[android]* Informs plugin that app went to background mode (or vise versa). Call when going to background when using beacons. ### setMultiNotificationMode [block:code] { "codes": [ { "code": "PushNotification.prototype.setMultiNotificationMode = function( success, fail )", "language": "javascript" } ] } [/block] *[android]* Allows multiple notifications to be displayed in the Android Notification Center. ### setSingleNotificationMode [block:code] { "codes": [ { "code": "PushNotification.prototype.setSingleNotificationMode = function(\tsuccess,\nfail\t)", "language": "javascript" } ] } [/block] *[android]* Allows only the last notification to be displayed in Android Notification Center. ### setSoundType [block:code] { "codes": [ { "code": "PushNotification.prototype.setSoundType = function( type, success, fail )", "language": "javascript" } ] } [/block] *[android]* Sets default sound for incoming pushes. [block:parameters] { "data": { "0-0": "`type`", "0-1": "Sound type (0 – default, 1 – no sound, 2 – always)", "h-0": "Parameter", "h-1": "Description" }, "cols": 2, "rows": 1 } [/block] ### setVibrateType [block:code] { "codes": [ { "code": "PushNotification.prototype.setVibrateType = function(type, success, fail )", "language": "javascript" } ] } [/block] *[android]* Sets default vibration mode for incoming pushes. [block:parameters] { "data": { "0-0": "`type`", "0-1": "Vibration type (0 – default, 1 – no vibration, 2 – always)", "h-0": "Parameter", "h-1": "Description" }, "cols": 2, "rows": 1 } [/block] ### setLightScreenOnNotification [block:code] { "codes": [ { "code": "PushNotification.prototype.setLightScreenOnNotification = function( on, success, fail )", "language": "javascript" } ] } [/block] *[android]* Turns screen on when notification arrives. [block:parameters] { "data": { "0-0": "`on`", "0-1": "enable/disable screen unlock (disabled by default)", "h-0": "Parameter", "h-1": "Description" }, "cols": 2, "rows": 1 } [/block] ### setEnableLED [block:code] { "codes": [ { "code": "PushNotification.prototype.setEnableLED = function( on, success, fail )", "language": "javascript" } ] } [/block] *[android]* Enables led blinking when notification arrives and display is off. [block:parameters] { "data": { "0-0": "`on`", "0-1": "enable/disable LED blink (disabled by default)", "h-0": "Parameter", "h-1": "Description" }, "cols": 2, "rows": 1 } [/block] ### setColorLED [block:code] { "codes": [ { "code": "PushNotification.prototype.setColorLED = function( color, success, fail )", "language": "javascript" } ] } [/block] *[android]* Sets led color. Use with [setEnableLED](#setction-setenableled). [block:parameters] { "data": { "0-0": "`color`", "0-1": "LED color in ARGB integer format", "h-0": "Parameter", "h-1": "Description" }, "cols": 2, "rows": 1 } [/block] ### getPushHistory [block:code] { "codes": [ { "code": "PushNotification.prototype.getPushHistory = function(\tsuccess\t)", "language": "javascript" } ] } [/block] *[android]* Returns array of received push notifications. [block:parameters] { "data": { "0-0": "`success`", "0-1": "success callback", "h-0": "Parameter", "h-1": "Description" }, "cols": 2, "rows": 1 } [/block] [block:code] { "codes": [ { "code": "pushwoosh.getPushHistory(function(pushHistory) {\n if(pushHistory.length == 0)\n alert(\"no push history\");\n else\n alert(JSON.stringify(pushHistory));\n});\n\npushwoosh.clearPushHistory();", "language": "javascript", "name": "Example" } ] } [/block] ### clearPushHistory [block:code] { "codes": [ { "code": "PushNotification.prototype.clearPushHistory = function()", "language": "javascript" } ] } [/block] *[android]* Clears push history. ### cancelAllLocalNotifications [block:code] { "codes": [ { "code": "PushNotification.prototype.cancelAllLocalNotifications = function( callback )", "language": "javascript" } ] } [/block] *[ios]* Clears all local notifications from the notification center. ### push-receive *[android, ios]* Push notification receive event. Is fired when application receives push notification in foreground or background. Closed applications does not receive this event. **Event properties** [block:parameters] { "data": { "h-0": "Property", "0-0": "`message`", "0-1": "(`string`) Push notification message", "1-0": "`userdata`", "1-1": "(`object`/`array`) Push notification custom data", "2-0": "`onStart`", "2-1": "(`boolean`) Is launch notification", "3-0": "`foreground`", "3-1": "(`boolean`) Is notification received in foreground", "4-0": "`android`", "4-1": "(`object`) Android specific notification payload", "5-0": "`ios`", "5-1": "(`object`) iOS specific notification payload", "6-0": "`wp8`", "6-1": "(`object`) Windows Phone specific notification payload", "7-0": "`windows`", "7-1": "(`object`) Windows specific notification payload" }, "cols": 2, "rows": 8 } [/block] [block:code] { "codes": [ { "code": "document.addEventListener('push-receive',\n\tfunction(event) {\n\t\tvar userData = event.notification.userdata;\n\n\t\tif (typeof(userData) != \"undefined\") {\n\t\t\t// handle custom notification data\n\t\t\tconsole.warn('user data: ' + JSON.stringify(userData));\n\t\t}\n\t}\n);", "language": "javascript", "name": "Example" } ] } [/block] ### push-notification *[android, ios, wp8, windows]* Push notification accept event. Is fired when user clicks on push notification. [block:callout] { "type": "info", "title": "Foreground notifications", "body": "By default Pushwoosh plugin does not display notifications in the foreground and automatically triggers `push-notification` event. See [plugin customization guide](http://docs.pushwoosh.com/docs/customizing-cordova-plugin#push-notifications-in-foreground) for controlling this behaviour." } [/block] [block:code] { "codes": [ { "code": "document.addEventListener('push-notification',\n\tfunction(event) {\n\t\tvar message = event.notification.message;\n\t\tvar userData = event.notification.userdata;\n\n\t\tif (typeof(userData) != \"undefined\") {\n\t\t\tconsole.warn('user data: ' + JSON.stringify(userData));\n\t\t}\n\t}\n);", "language": "javascript", "name": "Example" } ] } [/block] **Event properties** Same as [push-receive](#section-push-receive)