{"_id":"57ad83c05aa73d0e005fc62f","user":"55b8b82fdec1c9210013cfa1","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"},"category":{"_id":"55b9ff7f04775a2f00628074","project":"5540ce1b31827a0d007ab1cc","version":"5540ce1c31827a0d007ab1cf","__v":0,"pages":[],"sync":{"url":"","isSync":false},"reference":false,"createdAt":"2015-07-30T10:42:07.014Z","from_sync":false,"order":20,"slug":"appcelerator-titanium","title":"Appcelerator Titanium"},"__v":1,"parentDoc":null,"updates":[],"next":{"pages":[],"description":""},"createdAt":"2016-08-12T08:07:28.177Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"settings":"","results":{"codes":[]},"auth":"required","params":[],"url":""},"isReference":false,"order":1,"body":"[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Push Notifications in Foreground\"\n}\n[/block]\nBy default, Pushwoosh plugin does not display notifications in the foreground and automatically triggers [onPushOpened](https://github.com/Pushwoosh/pushwoosh-appcelerator-titanium/tree/master/Documentation#onpushopened) callback. This is controlled by `PW_BROADCAST_PUSH` metadata on Android:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"<?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?>\\n<ti:app xmlns:ti=\\\"http://ti.appcelerator.org\\\">\\n  <android xmlns:android=\\\"http://schemas.android.com/apk/res/android\\\">\\n    <manifest>\\n      <application>\\n        <!-- Set to false if you want to disable automatic push open in foreground -->\\n        <meta-data android:name=\\\"PW_BROADCAST_PUSH\\\" android:value=\\\"true\\\"/>\\n      </application>\\n    </manifest>\\n  </android>\\n</ti:app>\",\n      \"language\": \"xml\",\n      \"name\": \"tiapp.xml\"\n    }\n  ]\n}\n[/block]\nAnd `Pushwoosh_ALERT_TYPE` Info.plist key on iOS:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"<?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?>\\n<ti:app xmlns:ti=\\\"http://ti.appcelerator.org\\\">\\n  <ios>\\n    <plist>\\n      <dict>\\n        <!-- Set value to ALERT or BANNER to change notification appearance in foreground -->\\n        <key>Pushwoosh_ALERT_TYPE</key>\\n        <string>NONE</string>\\n      </dict>\\n    </plist>\\n  </ios>\\n</ti:app>\",\n      \"language\": \"xml\",\n      \"name\": \"tiapp.xml\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Custom Push Sound\"\n}\n[/block]\nTo enable custom push notifications sounds for Android put sound samples in **app/platform/android/res/raw** folder. The sounds will be accessible through **Sound** dropdown menu of **Send Push** panel.\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Custom Push Icon\"\n}\n[/block]\nPush notification icon can be customized on Android locally by using **pw_notification** as resource name for such icon; or remotely by referencing any resource name in **Icon** setting in **Send Push panel**. Android resources should be placed in **app/platform/android/res/** [folder](https://github.com/Pushwoosh/pushwoosh-appcelerator-titanium/tree/master/Titanium-Sample-iOS-Android/app/platform/android/res)\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Custom Push Data\"\n}\n[/block]\nCustom push data can be sent using Action setting in the Send Push panel. To receive and handle such data use the following code:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"pushwoosh.onPushOpened(function(e) {\\n\\tvar customData = e.extras;\\n  // handle custom push data\\n});\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Push receive callback\"\n}\n[/block]\nIf application is registered for push notifications and is not closed, push delivery event can be handled using:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"pushwoosh.onPushReceived(function(e) {\\n\\tvar message = e.message;\\n  var foreground = e.foreground;\\n  var customData = e.extras;\\n  var raw = e.data;\\n  \\n  // handle push receive here\\n});\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]\nFor iOS, enable Background Modes:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"<?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?>\\n<ti:app xmlns:ti=\\\"http://ti.appcelerator.org\\\">\\n  <ios>\\n    <plist>\\n      <dict>\\n        <key>UIBackgroundModes</key>\\n        <array>\\n          <string>remote-notification</string>\\n        </array>\\n\\t\\t\\t</dict>\\n    </plist>\\n  </ios>\\n</ti:app>\",\n      \"language\": \"xml\",\n      \"name\": \"tiapp.xml\"\n    }\n  ]\n}\n[/block]","excerpt":"","slug":"customizing-appcelerator-module","type":"basic","title":"Customizing Module"}

Customizing Module


[block:api-header] { "type": "basic", "title": "Push Notifications in Foreground" } [/block] By default, Pushwoosh plugin does not display notifications in the foreground and automatically triggers [onPushOpened](https://github.com/Pushwoosh/pushwoosh-appcelerator-titanium/tree/master/Documentation#onpushopened) callback. This is controlled by `PW_BROADCAST_PUSH` metadata on Android: [block:code] { "codes": [ { "code": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<ti:app xmlns:ti=\"http://ti.appcelerator.org\">\n <android xmlns:android=\"http://schemas.android.com/apk/res/android\">\n <manifest>\n <application>\n <!-- Set to false if you want to disable automatic push open in foreground -->\n <meta-data android:name=\"PW_BROADCAST_PUSH\" android:value=\"true\"/>\n </application>\n </manifest>\n </android>\n</ti:app>", "language": "xml", "name": "tiapp.xml" } ] } [/block] And `Pushwoosh_ALERT_TYPE` Info.plist key on iOS: [block:code] { "codes": [ { "code": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<ti:app xmlns:ti=\"http://ti.appcelerator.org\">\n <ios>\n <plist>\n <dict>\n <!-- Set value to ALERT or BANNER to change notification appearance in foreground -->\n <key>Pushwoosh_ALERT_TYPE</key>\n <string>NONE</string>\n </dict>\n </plist>\n </ios>\n</ti:app>", "language": "xml", "name": "tiapp.xml" } ] } [/block] [block:api-header] { "type": "basic", "title": "Custom Push Sound" } [/block] To enable custom push notifications sounds for Android put sound samples in **app/platform/android/res/raw** folder. The sounds will be accessible through **Sound** dropdown menu of **Send Push** panel. [block:api-header] { "type": "basic", "title": "Custom Push Icon" } [/block] Push notification icon can be customized on Android locally by using **pw_notification** as resource name for such icon; or remotely by referencing any resource name in **Icon** setting in **Send Push panel**. Android resources should be placed in **app/platform/android/res/** [folder](https://github.com/Pushwoosh/pushwoosh-appcelerator-titanium/tree/master/Titanium-Sample-iOS-Android/app/platform/android/res) [block:api-header] { "type": "basic", "title": "Custom Push Data" } [/block] Custom push data can be sent using Action setting in the Send Push panel. To receive and handle such data use the following code: [block:code] { "codes": [ { "code": "pushwoosh.onPushOpened(function(e) {\n\tvar customData = e.extras;\n // handle custom push data\n});", "language": "javascript" } ] } [/block] [block:api-header] { "type": "basic", "title": "Push receive callback" } [/block] If application is registered for push notifications and is not closed, push delivery event can be handled using: [block:code] { "codes": [ { "code": "pushwoosh.onPushReceived(function(e) {\n\tvar message = e.message;\n var foreground = e.foreground;\n var customData = e.extras;\n var raw = e.data;\n \n // handle push receive here\n});", "language": "javascript" } ] } [/block] For iOS, enable Background Modes: [block:code] { "codes": [ { "code": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<ti:app xmlns:ti=\"http://ti.appcelerator.org\">\n <ios>\n <plist>\n <dict>\n <key>UIBackgroundModes</key>\n <array>\n <string>remote-notification</string>\n </array>\n\t\t\t</dict>\n </plist>\n </ios>\n</ti:app>", "language": "xml", "name": "tiapp.xml" } ] } [/block]