diff options
Diffstat (limited to 'StoneIsland/plugins/phonegap-plugin-push')
35 files changed, 0 insertions, 7343 deletions
diff --git a/StoneIsland/plugins/phonegap-plugin-push/CHANGELOG.md b/StoneIsland/plugins/phonegap-plugin-push/CHANGELOG.md deleted file mode 100644 index e46cdae8..00000000 --- a/StoneIsland/plugins/phonegap-plugin-push/CHANGELOG.md +++ /dev/null @@ -1,597 +0,0 @@ -# Change Log - -## [v1.9.1](https://github.com/phonegap/phonegap-plugin-push/tree/v1.9.1) (2016-07-09) -[Full Changelog](https://github.com/phonegap/phonegap-plugin-push/compare/v1.9.0...v1.9.1) - -- 1.9.1 [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/6178688d10fc9fd5770795e5caa3f402d3fec574) -- Bumping plugin version to 1.9.1 [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/4d0d2d0c0f19305189bbc7db11c56abfcb0e629a) -- :bug: Issue #1412: push.subscribe 'not a function' error [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/1c0c0bcac7ae4a0fe8a7c54e2f00fdba90ff5207) -- :memo: Add emoji guide to CONTRIBUTING [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/dce845fde55429c36a885a4711e04a73904ab9c0) -- Issue #1342: Fail to add 1.9.0 to ios platform [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/7481e286607dacf01327c9f6d5a7c21acc5eeba1) -- Issue #1402: force-start:1 brings a killed application to foreground, not background [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/256f28fa08da4aab9691d628a3150022b67da02d) -- Issue #1400: Version 1.9.0 on PGB not working [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/c45228a892c602b8616d165ccf142eac0ff2f7f2) -- Merge pull request #1398 from getlarky/android-badge-documentation [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/6884df95602a15c219846bbcdb01ce1285d660bb) -- Warn about android badge support in documentation [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/2842de212b11a76580865c6ee0d6a1b7b42d030e) -- Enahancement : Add custom permission for PushHandlerActivity (#1362) [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/e15fdc442030648daabc79a44ae72b2d14b7c1d2) -- Issue #1248: upgrade ShortcutBadger version to latest [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/4ab1cf0f0747b1f122f1f43c4af67db37dd0e443) -- Merge pull request #1361 from pataar/master [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/29ec1e241036611c6a3a2c71d2a61860427be5d0) -- Fix minor typos in INSTALLATION.md [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/840b0e06cb2643635cfb882de9a35202799f3953) -- Add mimimum cordova versions to installation docs [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/dcb528384dfd7f65410545b842e16ef89277ff7b) -- Updating CHANGELOG [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/e268a0dceff248b703ae75ff7923b7b3d673aeee) - -## [v1.9.0](https://github.com/phonegap/phonegap-plugin-push/tree/v1.9.0) (2016-07-09) -[Full Changelog](https://github.com/phonegap/phonegap-plugin-push/compare/v1.8.4...v1.9.0) - -- 1.9.0 [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/e5b7f22299d900a37064a783da43905ad73c58bf) -- Bumping plugin version to 1.9.0 [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/dc6a11db4157e1070e48e073a8a78401f185d324) -- Prepare for 1.9.0 release [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/0f889bfb5e612ef3ffbc1466deabfe9eb99b760b) -- Update gitignore [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/d70bad64564444c01e59ff494b8ba09d190d3dbb) -- Bumping plugin version to 1.9.0 [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/600993e7739a0a84ef77b60c4a1457f8aea084b6) -- Issue #1154: Register fail iOS 10 [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/e6013d49ecf0025be10fb6bb87152ee4025b5df4) -- Issue #1337: Build failed, invalid package.json [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/8631666e4654fd6acafa6cf160cc59424e912ceb) -- Set default SENDER_ID [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/82ca365f4d6d91b18fc28c338a647a2622e60f6e) -- Issue #158: Notification Event Not Firing When Closed Through App Launcher [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/ca18653d6ff332db41f48824a2d65bd2699ed8bc) -- Merge branch 'master' of https://github.com/hanicker/phonegap-plugin-push into hanicker-master [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/43402909d3b2d5c6ff518cc69e401dc918b585aa) -- Update plugin to use GCM Cocoapods <framework> reference in plugin.xml (#1183) [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/b639d83fe125d5b77720d130ccec53af3a5f3d91) -- Updating CHANGELOG [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/e4779de2a5996703ba70656630f35d79415d1af8) -- feat(forced restart, notify javascript) [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/8c03beff9a5a83927b7020ee04c3ed541de04edd) -- restart application after force close (#158 #333) [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/8b7c972dbf617f22218c178d74368b35521eecb9) - -## [v1.8.4](https://github.com/phonegap/phonegap-plugin-push/tree/v1.8.4) (2016-07-09) -[Full Changelog](https://github.com/phonegap/phonegap-plugin-push/compare/v1.8.3...v1.8.4) - -- 1.8.4 [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/4b18505a2c30e17564c0e80060f0524968aa0d40) -- Bumping plugin version to 1.8.4 [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/046c727f58a6fa675a5f49c10334095cd4282884) -- Issue #1251: [Android] deviceId persists between uninstalls, but is invalid after an uninstall [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/8a7bbe5cba186d9685f31adc07e25bd908409498) -- Merge pull request #1323 from hung-doan/issue-1319 [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/021f0abd9a49fb83d19faca3ffb7d142759bb01a) -- Update GCM to 9.8+ issue #1319 [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/450e0e01b9bcd747a49081c4a0d6ce998c37478a) -- Support Twilio Notify (#1306) [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/a9bb3bf0a2ca57f68eafc39070fc125746bbbb23) -- Cache multiple Android action button pushes if app is not running (#1272) [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/d0547bab04c292024dc6ed41939590fba01115ff) -- Add sub/unsub tests [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/3bf9ff5f04e10622d7d9ff47a9bd57a829ee9eef) -- Add features: push.subscribe, push.unsubscribe (issue #1040) (#1227) [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/bb0d3ed087e13e24af57e682776930cea2f577a8) -- Updating CHANGELOG [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/cf7ce8e716fe60de121634abc164b509100a9d15) - -## [v1.8.3](https://github.com/phonegap/phonegap-plugin-push/tree/v1.8.3) (2016-07-09) -[Full Changelog](https://github.com/phonegap/phonegap-plugin-push/compare/v1.8.2...v1.8.3) - -- 1.8.3 [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/a0cfba9f85b7d7dfa3c244c9e78a03872ff938f9) -- Bumping plugin version to 1.8.3 [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/cc7d5abe55957cebfdd3b39ba670f8093bdac564) -- Update pluginpub version [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/0d8548d3166b7b4d34b32944b800c96e4aadf70a) -- Issue#1282 Show app name if title is empty (#1285) [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/3d7a3a39fb931aafa86be6b1568a682133c36de7) -- Note about background app refresh (#1267) [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/4f13533deb0c1b927dab9d9cddb13c53fdefd9b0) -- Issue #1213: XDK instructions link for www template is incorrect (#1283) [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/d2ede2bab4cd6462f7dffc4e2bc733d585107e89) -- Merge pull request #1277 from dannywillems/patch-1 [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/ea5ae88f3fcfa8fc605cf2c974b52d793bd2c4c9) -- Unused variable app. Caused warnings. [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/09dedb43481d207d0b17de4eb26c5a1904d08f65) -- Issue #1254: [Question] Is it possible to get more than 3 action buttons on Android notifications? [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/d8ab6665d878c8dec3ff9914c11a9329c8a415e7) -- Use unique pending intent request code to enable multiple... (#1225) [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/475883833556eb001e2e0adb986bd96b78bdcb2f) -- Add `cordovaDependencies` section to package.json (#1232) [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/6b343e78e9bfca921cef78eb504755477ecaeff9) -- Updating CHANGELOG [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/14afb94126acb51a6f10a2094f7f391f2f17dee5) - -## [v1.8.2](https://github.com/phonegap/phonegap-plugin-push/tree/v1.8.2) (2016-07-09) -[Full Changelog](https://github.com/phonegap/phonegap-plugin-push/compare/v1.8.1...v1.8.2) - -- 1.8.2 [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/b47d519abff667400c4863fe90a27ae88e3c0671) -- Bumping plugin version to 1.8.2 [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/738735ddcd9b60014beb4207c3ccdcd30ba7a803) -- Localization from resources (#1196) [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/2de9fc2827a18941ae6040e90ea0da5dc97652d8) -- Issue #1199: iOS 10 is not firing the 'notification' event after clicking on a notification when the app is in hibernate [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/e711b09b15a8e85156e9158026509522859c7900) -- Use unique pending intent request code to enable multiple simultaneous notifications with action buttons (#1216) [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/1fe640637fd67ec0ce2cf50ee1cab793ed01cfb7) -- (doc) Fixing `ios.catetories` type in api reference. [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/0a93fab9cec5ac2a2b813090958054e8e7b15f9a) -- Issue #1155: [doc] Explain usage of the top level "priority" in GCM notifications [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/ddaf48e089dc3cb46f9bd9f5e4678a2118b14a48) -- Issue #1121: Notification is not shown on ios device [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/432761202c43a1f2a4ba9c643df78b81b87d66fa) -- Issue #1160: data.additionalData.[Object] as 'undefined' in iOS [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/946052a895268155f56a7a3a1006d019599b46f9) -- Few edits (#1179) [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/f90b4bbf0e78adaa029737cf70b146ec97d09015) -- Adding workshop tutorial link to the README (#1169) [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/59800a930557bd864e527404e1035c2d8ac149c9) -- added Azure server-side example (#1124) [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/0bd4d0e612f6f1c62e33d147564b7e495436f15e) -- Update appxmanifests with ToastCapable=true after plugin install (#1158) [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/eeefc036a8600bea80135b6b14241509853444ab) -- Updating CHANGELOG [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/30d3d5dc733c80bc1687e5eff28d0614a0f38e51) - -## [v1.8.1](https://github.com/phonegap/phonegap-plugin-push/tree/v1.8.1) (2016-07-09) -[Full Changelog](https://github.com/phonegap/phonegap-plugin-push/compare/v1.8.0...v1.8.1) - -- 1.8.1 [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/95c27d29ef37bfd750972561022db53de256840d) -- Bumping plugin version to 1.8.1 [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/e4ba55ff310d4d931503de2547738cc169b6f968) -- [Windows] Added a check on activation context existence (#1129) [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/151c8cd97aa71742798e969dd9e6c2208b8c1f15) -- Updating CHANGELOG [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/4cd4ee00e2eb081d0d29d001e580009fba5c341a) - -## [v1.8.0](https://github.com/phonegap/phonegap-plugin-push/tree/v1.8.0) (2016-07-09) -[Full Changelog](https://github.com/phonegap/phonegap-plugin-push/compare/v1.7.4...v1.8.0) - -- 1.8.0 [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/d5a8480e6e230c959d8079554a6366f3605cb97e) -- Bumping plugin version to 1.8.0 [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/f8c784536e40ce6dddf14edeff7ad2a9ee944156) -- Check that serviceWorker exists before unregistering [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/ef004002d60d8028ed6aad2cef79d4d8ac6aed49) -- Populate additionalData on browser platform [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/63a29cdbbc0cd0374552d51e0e2d2217f5361f79) -- Issue #683: Support Android N inline reply actions [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/e835ca31ac02a3455ece8c96938260935e2e7100) -- Issue #1109: Installation.MD has a mistake [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/89834b78a63ad6c927295eb5699204a0ccb49a73) -- Use push server DELETE route to remove browser keys [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/4615ea694bd5858bfdb8553c9a9390e1e30c2c36) -- [chore] fix mis-spelling [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/efdef52deec4f7e8b6b4ee87460bd87cc0479c74) -- Browser: always call success on unimplemented methods [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/1b8bf267674508361c68fb03b12f97608e87456b) -- Update push url [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/e1d8774f760d7a72a547d68e1b2ac367572e2b6d) -- Merge branch 'browser' [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/a2ad8da9a25a02a1b674e6adf0a37e18cde185ab) -- Add browser platform support [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/e8e0fe47001e461cf7fb7274d4c2b3dc687cd90e) -- Issue #1080: clearAllNotifications not working on iOS [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/4bea2a7469ab2bd677e12d440b457e1d5383b1f0) -- [whoops] revert accidental commit of a pluginpub test [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/da301e8a43a0a659947294c9d94f7fd09f5ac4b2) -- [doc] remove deprecation notice on hasPermission [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/d4b79a81c5ad85a4b566e5a23a19b10fa78dcf17) -- Updating CHANGELOG [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/8512a6cb7be3c0bb2b5db813c7aaff4c49fc52a2) -- Bumping plugin version to 1.9.0 [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/b015543b8a06526b7b70357407e635c180c473ee) -- Update CHANGELOG [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/e6f87a50d9f9cb3bd7c9ba599b3d3afbc0fd7aaf) - -## [1.7.4](https://github.com/phonegap/phonegap-plugin-push/tree/v1.7.4) (2016-07-09) -[Full Changelog](https://github.com/phonegap/phonegap-plugin-push/compare/1.7.3...v1.7.4) - -**Closed issues:** - -- FYI: Resumed iOS 10 Notifications results in an error (fix problem on iOS) [\#1002](https://github.com/phonegap/phonegap-plugin-push/issues/1002) - - -## [1.7.3](https://github.com/phonegap/phonegap-plugin-push/tree/1.7.3) (2016-07-06) -[Full Changelog](https://github.com/phonegap/phonegap-plugin-push/compare/1.7.2...1.7.3) - -**Closed issues:** - -- Implemented clearBadge for Android [\#1030](https://github.com/phonegap/phonegap-plugin-push/issues/1030) -- update badge number even if the app is totally closed [\#1027](https://github.com/phonegap/phonegap-plugin-push/issues/1027) -- Documentation issue of Android pictures push [\#1028](https://github.com/phonegap/phonegap-plugin-push/issues/1028) -- [iOS] unregister for a topic: parameter is not consistent between ios/android [\#1029](https://github.com/phonegap/phonegap-plugin-push/issues/1029) -- [doc] Error installing in IOS, version requirement: >=4.1.0 [\#1047](https://github.com/phonegap/phonegap-plugin-push/issues/1047) - -## [1.7.2](https://github.com/phonegap/phonegap-plugin-push/tree/1.7.2) (2016-06-24) -[Full Changelog](https://github.com/phonegap/phonegap-plugin-push/compare/1.7.1...1.7.2) - -**Closed issues:** - -- FYI: Resumed iOS 10 Notifications results in an error [\#1002](https://github.com/phonegap/phonegap-plugin-push/issues/1002) - -## [1.7.1](https://github.com/phonegap/phonegap-plugin-push/tree/1.7.1) (2016-06-17) -[Full Changelog](https://github.com/phonegap/phonegap-plugin-push/compare/1.7.0...1.7.1) - -**Closed issues:** - -- Update docs for Android badges [\#982](https://github.com/phonegap/phonegap-plugin-push/issues/982) -- visibility not working [\#987](https://github.com/phonegap/phonegap-plugin-push/issues/982) -- Revert pinning of support-v13 [\#983](https://github.com/phonegap/phonegap-plugin-push/issues/983) - -## [1.7.0](https://github.com/phonegap/phonegap-plugin-push/tree/1.7.0) (2016-06-06) -[Full Changelog](https://github.com/phonegap/phonegap-plugin-push/compare/1.6.4...1.7.0) - -**Closed issues:** - -- disable notification's sounds on a per notification basis [\#885](https://github.com/phonegap/phonegap-plugin-push/issues/885) -- Android GCM Action Buttons lack of documentation [\#884](https://github.com/phonegap/phonegap-plugin-push/issues/884) -- Android double on('notification') fired [\#828](https://github.com/phonegap/phonegap-plugin-push/issues/828) -- Device should register, Push Notification should receive on IOS (IntelXDK) [\#926](https://github.com/phonegap/phonegap-plugin-push/issues/926) -- Use cordova-ios 4.1.0 in Milestone 1.7.0 [\#751](https://github.com/phonegap/phonegap-plugin-push/issues/751) -- Badge on android [\#190](https://github.com/phonegap/phonegap-plugin-push/issues/190) -- JS error in Success callbackId: PushNotifiation###.. whenever a notification is sent to the device [\#824](https://github.com/phonegap/phonegap-plugin-push/issues/824) -- coldstart flag always set to true if the app has been opened through an alert, on ios 9.3.1, plugin version 1.6.2 cordova 6.1.0 cordova ios 4.1.1 [\#795](https://github.com/phonegap/phonegap-plugin-push/issues/795) -- Is there any way to clear notifications out from the app? [\#346](https://github.com/phonegap/phonegap-plugin-push/issues/346) -- Show contents of notification when phone is locked [\#750](https://github.com/phonegap/phonegap-plugin-push/issues/750) -- PushPlugin.m init() should send pending notification when js side is ready [\#658](https://github.com/phonegap/phonegap-plugin-push/issues/658) - -## [1.6.4](https://github.com/phonegap/phonegap-plugin-push/tree/1.6.4) (2016-05-24) -[Full Changelog](https://github.com/phonegap/phonegap-plugin-push/compare/1.6.3...1.6.4) - -**Closed issues:** - -- hasPermission() for windows [\#874](https://github.com/phonegap/phonegap-plugin-push/issues/874) -- Latest Play store service breaks phonegap-plugin-push [\#909](https://github.com/phonegap/phonegap-plugin-push/issues/909) - -## [1.6.3](https://github.com/phonegap/phonegap-plugin-push/tree/1.6.3) (2016-04-27) -[Full Changelog](https://github.com/phonegap/phonegap-plugin-push/compare/1.6.2...1.6.3) - -**Fixed bugs:** - -- \[Android\] Can't install multiple apps using this plugin \(v1.6.x\) [\#768](https://github.com/phonegap/phonegap-plugin-push/issues/768) -- JS error in "Success callbackId: PushNotifiation\#\#\#.." whenever a notification is sent to the device [\#824](https://github.com/phonegap/phonegap-plugin-push/issues/824) - -**Closed issues:** - -- Move example directory to a phonegap template [\#832](https://github.com/phonegap/phonegap-plugin-push/issues/832) -- va [\#830](https://github.com/phonegap/phonegap-plugin-push/issues/830) -- does not create the notification bar [\#821](https://github.com/phonegap/phonegap-plugin-push/issues/821) -- Did not show notification in status bar for Xiomi Redmi Note 3 [\#790](https://github.com/phonegap/phonegap-plugin-push/issues/790) -- PushNotification.hasPermission not working as expected [\#789](https://github.com/phonegap/phonegap-plugin-push/issues/789) - - -## [1.6.2](https://github.com/phonegap/phonegap-plugin-push/tree/1.6.2) (2016-04-06) -[Full Changelog](https://github.com/phonegap/phonegap-plugin-push/compare/1.6.1...1.6.2) - -**Fixed bugs:** - -- Unexpected / Broken Android Behavior [\#767](https://github.com/phonegap/phonegap-plugin-push/issues/767) - -**Closed issues:** - -- Android: JSON Exception No Value Found for Sender [\#781](https://github.com/phonegap/phonegap-plugin-push/issues/781) -- Should I call init\(\) every time the app is launched?? [\#777](https://github.com/phonegap/phonegap-plugin-push/issues/777) -- Request: extend action buttons to wearables [\#776](https://github.com/phonegap/phonegap-plugin-push/issues/776) -- After upgrade: 601 duplicate symbols for architecture i386 [\#769](https://github.com/phonegap/phonegap-plugin-push/issues/769) -- push plugin [\#766](https://github.com/phonegap/phonegap-plugin-push/issues/766) -- Documentation mentions old name for dependency [\#763](https://github.com/phonegap/phonegap-plugin-push/issues/763) -- push.on\('notification'\) callback is not called on coldstart on iOS [\#758](https://github.com/phonegap/phonegap-plugin-push/issues/758) -- plugin doesn't work in background or when app not running on kitkat 4.4.2 [\#754](https://github.com/phonegap/phonegap-plugin-push/issues/754) -- App Icon not displayed in tray using build.phonegap and cli-6.0.0 \[ios\] [\#753](https://github.com/phonegap/phonegap-plugin-push/issues/753) -- push.on\('registration'\) event not called on IOS. [\#752](https://github.com/phonegap/phonegap-plugin-push/issues/752) -- catch 22 when trying to use this plug [\#741](https://github.com/phonegap/phonegap-plugin-push/issues/741) -- push.setApplicationIconBadgeNumber not working in background [\#736](https://github.com/phonegap/phonegap-plugin-push/issues/736) -- Strange issue while debugging in Safari Inspector [\#733](https://github.com/phonegap/phonegap-plugin-push/issues/733) - -## [1.6.1](https://github.com/phonegap/phonegap-plugin-push/tree/1.6.1) (2016-03-23) -[Full Changelog](https://github.com/phonegap/phonegap-plugin-push/compare/1.6.0...1.6.1) - -**Fixed bugs:** - -- App crashes on notification when in background [\#715](https://github.com/phonegap/phonegap-plugin-push/issues/715) - -**Closed issues:** - -- Memory Leak when call `push.on\('registration'`. so `Push Plugin register called` not called [\#743](https://github.com/phonegap/phonegap-plugin-push/issues/743) -- l [\#739](https://github.com/phonegap/phonegap-plugin-push/issues/739) -- \[testing issue template\] ignore me [\#717](https://github.com/phonegap/phonegap-plugin-push/issues/717) -- Incorrect init option "vibration" in a few ios samples on PAYLOAD.md [\#713](https://github.com/phonegap/phonegap-plugin-push/issues/713) -- android M wear case [\#691](https://github.com/phonegap/phonegap-plugin-push/issues/691) -- Incorrect document detailing \(PHONEGAP\_BUILD.md\) [\#686](https://github.com/phonegap/phonegap-plugin-push/issues/686) -- Windows Phone 8.1, not fired plugin methods [\#526](https://github.com/phonegap/phonegap-plugin-push/issues/526) - -## [1.6.0](https://github.com/phonegap/phonegap-plugin-push/tree/1.6.0) (2016-03-09) -[Full Changelog](https://github.com/phonegap/phonegap-plugin-push/compare/1.5.3...1.6.0) - -**Implemented enhancements:** - -- Background processing with coldstart on iOS [\#583](https://github.com/phonegap/phonegap-plugin-push/issues/583) - -**Fixed bugs:** - -- Android: notification does not dismiss after selection button \(1.6.x dev\) [\#610](https://github.com/phonegap/phonegap-plugin-push/issues/610) - -**Closed issues:** - -- XDK doesn't work with v1.5.x. Are you going to have a non-gradle version for v1.5.x [\#675](https://github.com/phonegap/phonegap-plugin-push/issues/675) -- emoji support [\#668](https://github.com/phonegap/phonegap-plugin-push/issues/668) -- iOS sound not found \[edited with new debug info\] [\#667](https://github.com/phonegap/phonegap-plugin-push/issues/667) -- Push notification register APN to GCM Problem [\#665](https://github.com/phonegap/phonegap-plugin-push/issues/665) -- IOS Never fire the registration event [\#659](https://github.com/phonegap/phonegap-plugin-push/issues/659) -- Badge count inaccurate [\#651](https://github.com/phonegap/phonegap-plugin-push/issues/651) -- Android Icon options in phonegap-plugin-push@1.2.3 [\#648](https://github.com/phonegap/phonegap-plugin-push/issues/648) -- Getting same registration id when re-register [\#641](https://github.com/phonegap/phonegap-plugin-push/issues/641) -- Callback not called unless you register to GCM everytime you open the app [\#626](https://github.com/phonegap/phonegap-plugin-push/issues/626) -- How to make GCM show alert automatically ios [\#602](https://github.com/phonegap/phonegap-plugin-push/issues/602) -- Shoddy image for notification icon,status bar icon? [\#587](https://github.com/phonegap/phonegap-plugin-push/issues/587) -- ERROR: Plugin 'PushNotification' not found [\#568](https://github.com/phonegap/phonegap-plugin-push/issues/568) -- ar [\#533](https://github.com/phonegap/phonegap-plugin-push/issues/533) -- No sound and vibration for GCM when built with Cordova but Ok with PhoneBuild [\#520](https://github.com/phonegap/phonegap-plugin-push/issues/520) - -## [1.5.3](https://github.com/phonegap/phonegap-plugin-push/tree/1.5.3) (2016-01-14) -[Full Changelog](https://github.com/phonegap/phonegap-plugin-push/compare/1.5.2...1.5.3) - -**Fixed bugs:** - -- Android 4.1 and AppOpsManager [\#495](https://github.com/phonegap/phonegap-plugin-push/issues/495) - -**Closed issues:** - -- iOS Building Error [\#507](https://github.com/phonegap/phonegap-plugin-push/issues/507) -- \[FIX\] notification not fired when app is in background/killed ? Check this out [\#502](https://github.com/phonegap/phonegap-plugin-push/issues/502) -- Which Sender ID to use [\#485](https://github.com/phonegap/phonegap-plugin-push/issues/485) -- coldstart not documented [\#483](https://github.com/phonegap/phonegap-plugin-push/issues/483) -- Android: iconColor doesn't work in hexadecimal \(\#RRGGBB\) format [\#480](https://github.com/phonegap/phonegap-plugin-push/issues/480) -- Cannot find symbol variable INSTANCE\_ID\_SCOPE [\#477](https://github.com/phonegap/phonegap-plugin-push/issues/477) -- notification event not fired on cold start on Android 5 [\#469](https://github.com/phonegap/phonegap-plugin-push/issues/469) -- Push notifications not working with iPhone6 + ios 9.2? [\#462](https://github.com/phonegap/phonegap-plugin-push/issues/462) -- UTF8 support on android: the notification text \(on android only\) is shown with "???" [\#461](https://github.com/phonegap/phonegap-plugin-push/issues/461) -- example application? [\#460](https://github.com/phonegap/phonegap-plugin-push/issues/460) -- build fail in ios - version 1.5.2 [\#458](https://github.com/phonegap/phonegap-plugin-push/issues/458) -- Getting NotRegistered error when sending GCM push notification, but the device never unregistered [\#419](https://github.com/phonegap/phonegap-plugin-push/issues/419) -- Changelog neglected [\#412](https://github.com/phonegap/phonegap-plugin-push/issues/412) - -## [1.5.2](https://github.com/phonegap/phonegap-plugin-push/tree/1.5.1) (2015-12-21) -[Full Changelog](https://github.com/phonegap/phonegap-plugin-push/compare/1.5.1...1.5.2) - -**Fixed bugs:** - -- notification\_applicationDidBecomeActive method [\#447](https://github.com/phonegap/phonegap-plugin-push/issues/447) - -## [1.5.1](https://github.com/phonegap/phonegap-plugin-push/tree/1.5.1) (2015-12-18) -[Full Changelog](https://github.com/phonegap/phonegap-plugin-push/compare/1.5.0...1.5.1) - -**Closed issues:** - -- Unsubscribing to topics should not clear event handlers [\#443](https://github.com/phonegap/phonegap-plugin-push/issues/443) - -## [1.5.0](https://github.com/phonegap/phonegap-plugin-push/tree/1.5.0) (2015-12-18) -[Full Changelog](https://github.com/phonegap/phonegap-plugin-push/compare/1.4.5...1.5.0) - -**Fixed bugs:** - -- Make sure iOS/Android can receive the same GCM payload [\#401](https://github.com/phonegap/phonegap-plugin-push/issues/401) - -**Closed issues:** - -- Using stacking notifications but only able to process one [\#435](https://github.com/phonegap/phonegap-plugin-push/issues/435) -- Cant find stacking docs [\#430](https://github.com/phonegap/phonegap-plugin-push/issues/430) -- Android Marshmallow 6.0 push icon [\#422](https://github.com/phonegap/phonegap-plugin-push/issues/422) -- Distinguish between 'android' or 'ios' on registration event [\#418](https://github.com/phonegap/phonegap-plugin-push/issues/418) -- Phonegap Build Issues for 1.4.X [\#417](https://github.com/phonegap/phonegap-plugin-push/issues/417) -- using in Ionic [\#416](https://github.com/phonegap/phonegap-plugin-push/issues/416) -- notification event not called on ios [\#414](https://github.com/phonegap/phonegap-plugin-push/issues/414) -- \[docs\] detail on deviceready dependency [\#410](https://github.com/phonegap/phonegap-plugin-push/issues/410) -- iOS: Plugin does not start [\#404](https://github.com/phonegap/phonegap-plugin-push/issues/404) -- Process notifications in background [\#398](https://github.com/phonegap/phonegap-plugin-push/issues/398) -- On iOS 9 the badge does not clear [\#395](https://github.com/phonegap/phonegap-plugin-push/issues/395) -- Background notification OK, but event "notification" never called [\#387](https://github.com/phonegap/phonegap-plugin-push/issues/387) -- Android action button callback not triggered [\#298](https://github.com/phonegap/phonegap-plugin-push/issues/298) - -## [1.4.5](https://github.com/phonegap/phonegap-plugin-push/tree/1.4.5) (2015-12-03) -[Full Changelog](https://github.com/phonegap/phonegap-plugin-push/compare/1.4.4...1.4.5) - -**Fixed bugs:** - -- register -\> unregister lifecycle [\#368](https://github.com/phonegap/phonegap-plugin-push/issues/368) - -**Closed issues:** - -- jshint support [\#380](https://github.com/phonegap/phonegap-plugin-push/issues/380) -- Platform support [\#379](https://github.com/phonegap/phonegap-plugin-push/issues/379) -- Ionic implemenation [\#364](https://github.com/phonegap/phonegap-plugin-push/issues/364) -- on registration callback getting called repeatedly. [\#353](https://github.com/phonegap/phonegap-plugin-push/issues/353) -- on\("notification"\) dont fire when the app its open [\#351](https://github.com/phonegap/phonegap-plugin-push/issues/351) - -## [1.4.4](https://github.com/phonegap/phonegap-plugin-push/tree/1.4.4) (2015-11-20) -[Full Changelog](https://github.com/phonegap/phonegap-plugin-push/compare/1.4.3...1.4.4) - -**Fixed bugs:** - -- InstanceID.getToken\(\) not called in an Intent [\#354](https://github.com/phonegap/phonegap-plugin-push/issues/354) -- Handle both data and notification payloads in the same GCM push [\#343](https://github.com/phonegap/phonegap-plugin-push/issues/343) -- \[INSTALL\_FAILED\_CONFLICTING\_PROVIDER\] [\#320](https://github.com/phonegap/phonegap-plugin-push/issues/320) -- Getting "Error : Empty registration ID received from GCM" [\#315](https://github.com/phonegap/phonegap-plugin-push/issues/315) - -**Closed issues:** - -- xcode build fails with phonegap-plugin-push [\#358](https://github.com/phonegap/phonegap-plugin-push/issues/358) -- App crashes after adding push plugin and wikipedia app installed [\#357](https://github.com/phonegap/phonegap-plugin-push/issues/357) -- Conflict when compiling with com.google.maps [\#355](https://github.com/phonegap/phonegap-plugin-push/issues/355) - -## [1.4.3](https://github.com/phonegap/phonegap-plugin-push/tree/1.4.3) (2015-11-18) -[Full Changelog](https://github.com/phonegap/phonegap-plugin-push/compare/1.4.2...1.4.3) - -**Closed issues:** - -- \[Question\] about the action's icon color [\#348](https://github.com/phonegap/phonegap-plugin-push/issues/348) -- Can I access Web API's from 'notification' handler? [\#335](https://github.com/phonegap/phonegap-plugin-push/issues/335) -- Init Error: Missing Instance ID Service [\#334](https://github.com/phonegap/phonegap-plugin-push/issues/334) -- Install issue [\#332](https://github.com/phonegap/phonegap-plugin-push/issues/332) -- Multiple Apps gets error [\#330](https://github.com/phonegap/phonegap-plugin-push/issues/330) -- Can't find variable PushNotification [\#328](https://github.com/phonegap/phonegap-plugin-push/issues/328) -- When app is in background, clicking on Android notification in shade opens app but does not trigger the on\('notification'\) event handler [\#326](https://github.com/phonegap/phonegap-plugin-push/issues/326) -- "Missing Command Error" when running in browser [\#318](https://github.com/phonegap/phonegap-plugin-push/issues/318) -- Small icon not working [\#316](https://github.com/phonegap/phonegap-plugin-push/issues/316) -- Duplicate push notifications happening on iOS when phone is unlocked [\#309](https://github.com/phonegap/phonegap-plugin-push/issues/309) -- Is it possible to add badge on Android portion. [\#308](https://github.com/phonegap/phonegap-plugin-push/issues/308) -- \[just a question\] about the priority [\#306](https://github.com/phonegap/phonegap-plugin-push/issues/306) -- Android - After unregister and reregister no notifications [\#304](https://github.com/phonegap/phonegap-plugin-push/issues/304) -- Amazon-Fireos and Blackberry 10 support [\#300](https://github.com/phonegap/phonegap-plugin-push/issues/300) -- 1.4.x not showing notification on Android [\#299](https://github.com/phonegap/phonegap-plugin-push/issues/299) -- "push.unregister" not really work in iOS [\#296](https://github.com/phonegap/phonegap-plugin-push/issues/296) - -## [1.4.2](https://github.com/phonegap/phonegap-plugin-push/tree/1.4.2) (2015-11-03) -[Full Changelog](https://github.com/phonegap/phonegap-plugin-push/compare/1.4.1...1.4.2) - -**Closed issues:** - -- data.registrationId is empty string "" on register event callback [\#295](https://github.com/phonegap/phonegap-plugin-push/issues/295) - -## [1.4.1](https://github.com/phonegap/phonegap-plugin-push/tree/1.4.1) (2015-11-02) -[Full Changelog](https://github.com/phonegap/phonegap-plugin-push/compare/1.4.0...1.4.1) - -## [1.4.0](https://github.com/phonegap/phonegap-plugin-push/tree/1.4.0) (2015-10-27) -[Full Changelog](https://github.com/phonegap/phonegap-plugin-push/compare/1.3.0...1.4.0) - -**Implemented enhancements:** - -- Use Google's InstanceID API [\#188](https://github.com/phonegap/phonegap-plugin-push/issues/188) - -**Closed issues:** - -- How to handle a re-installed app? [\#203](https://github.com/phonegap/phonegap-plugin-push/issues/203) -- interactive push notifications? [\#266](https://github.com/phonegap/phonegap-plugin-push/issues/266) -- Empty registrationId Android [\#265](https://github.com/phonegap/phonegap-plugin-push/issues/265) -- Run callback when clicking of notification body [\#261](https://github.com/phonegap/phonegap-plugin-push/issues/261) -- Android BUILD FAILED [\#251](https://github.com/phonegap/phonegap-plugin-push/issues/251) -- Re-register [\#250](https://github.com/phonegap/phonegap-plugin-push/issues/250) -- how to work in background ? [\#249](https://github.com/phonegap/phonegap-plugin-push/issues/249) -- installing plugin [\#244](https://github.com/phonegap/phonegap-plugin-push/issues/244) -- No Sound and vibration [\#242](https://github.com/phonegap/phonegap-plugin-push/issues/242) -- Unable to build apk [\#241](https://github.com/phonegap/phonegap-plugin-push/issues/241) -- still having problems with build. [\#239](https://github.com/phonegap/phonegap-plugin-push/issues/239) -- Registering on iOS 9 [\#238](https://github.com/phonegap/phonegap-plugin-push/issues/238) -- Custom sound repeated multiple times on Android [\#237](https://github.com/phonegap/phonegap-plugin-push/issues/237) -- Android: status bar notification is not shown [\#236](https://github.com/phonegap/phonegap-plugin-push/issues/236) -- Multiple Push Notifications - phonegap build [\#234](https://github.com/phonegap/phonegap-plugin-push/issues/234) -- error: cannot find symbol String token = InstanceID.getInstance\(getApplicationContext\(\)\).getToken\(senderID, GCM\); [\#231](https://github.com/phonegap/phonegap-plugin-push/issues/231) -- Problem using "ledColor" and "VibrationPattern" [\#229](https://github.com/phonegap/phonegap-plugin-push/issues/229) -- Notificaction event receive, but not notification showing on android [\#228](https://github.com/phonegap/phonegap-plugin-push/issues/228) -- Events for registration not being fired [\#227](https://github.com/phonegap/phonegap-plugin-push/issues/227) -- 'registration' event not firing on windows phone [\#224](https://github.com/phonegap/phonegap-plugin-push/issues/224) -- Can i subscribe to a topic in using plugin? [\#219](https://github.com/phonegap/phonegap-plugin-push/issues/219) -- GCMIntentService.java:472: error: cannot find symbol iconColor [\#217](https://github.com/phonegap/phonegap-plugin-push/issues/217) -- Push Plugin registering on iOS 9 Devices but not showing Notification [\#216](https://github.com/phonegap/phonegap-plugin-push/issues/216) -- Receiving a notification "outside app" while in it? [\#213](https://github.com/phonegap/phonegap-plugin-push/issues/213) -- iOS push not working for device tokens when spaces removed [\#212](https://github.com/phonegap/phonegap-plugin-push/issues/212) -- Error: Plugin PushPlugin failed to install. [\#210](https://github.com/phonegap/phonegap-plugin-push/issues/210) -- Build error [\#205](https://github.com/phonegap/phonegap-plugin-push/issues/205) -- Android push.on\('registration', cb\) fires correctly on device, but not in emulator. [\#204](https://github.com/phonegap/phonegap-plugin-push/issues/204) -- 1.3.0 version not compatible with "crosswalk" by PGB [\#199](https://github.com/phonegap/phonegap-plugin-push/issues/199) -- How to get data on didReceiveNotification Background Process [\#198](https://github.com/phonegap/phonegap-plugin-push/issues/198) -- PushNotification is not defined in some devices [\#196](https://github.com/phonegap/phonegap-plugin-push/issues/196) -- not getting notifications on the Android device [\#195](https://github.com/phonegap/phonegap-plugin-push/issues/195) -- Installation Errors [\#186](https://github.com/phonegap/phonegap-plugin-push/issues/186) -- IOS: on registration fired twice [\#185](https://github.com/phonegap/phonegap-plugin-push/issues/185) -- Build failed with exit code 8 [\#184](https://github.com/phonegap/phonegap-plugin-push/issues/184) -- iOS: Not able to schedule local notification after adding the plugin [\#183](https://github.com/phonegap/phonegap-plugin-push/issues/183) -- How to show multiple notifications individually in android? [\#181](https://github.com/phonegap/phonegap-plugin-push/issues/181) -- iOS init option type [\#180](https://github.com/phonegap/phonegap-plugin-push/issues/180) -- Building for Android is a quest [\#179](https://github.com/phonegap/phonegap-plugin-push/issues/179) -- How do i tell if the user open the app by tapping the notification? [\#176](https://github.com/phonegap/phonegap-plugin-push/issues/176) -- IOS custom push sound when app is in background [\#175](https://github.com/phonegap/phonegap-plugin-push/issues/175) -- Hi guys please post full working procedure, I'm not able to get registration id also. Please help [\#174](https://github.com/phonegap/phonegap-plugin-push/issues/174) -- Has anyone tested this plugin on windows? [\#173](https://github.com/phonegap/phonegap-plugin-push/issues/173) - -## [1.3.0](https://github.com/phonegap/phonegap-plugin-push/tree/1.3.0) (2015-09-21) -[Full Changelog](https://github.com/phonegap/phonegap-plugin-push/compare/1.2.3...1.3.0) - -**Implemented enhancements:** - -- How to use GCM 3.0 with this plugin? [\#127](https://github.com/phonegap/phonegap-plugin-push/issues/127) -- Android: possibility to send a notification with a title and without message [\#122](https://github.com/phonegap/phonegap-plugin-push/issues/122) -- Enhancement - Led, Vibration Pattern, Priority on Android [\#105](https://github.com/phonegap/phonegap-plugin-push/issues/105) - -**Fixed bugs:** - -- It is using in gcm data.additionalData ? [\#126](https://github.com/phonegap/phonegap-plugin-push/issues/126) -- iOS notification from cold boot [\#117](https://github.com/phonegap/phonegap-plugin-push/issues/117) -- Notification LED is not working [\#97](https://github.com/phonegap/phonegap-plugin-push/issues/97) - -**Closed issues:** - -- Know which version is used in build service [\#151](https://github.com/phonegap/phonegap-plugin-push/issues/151) -- Registration is not working in IOS9 [\#150](https://github.com/phonegap/phonegap-plugin-push/issues/150) -- build fail on android [\#149](https://github.com/phonegap/phonegap-plugin-push/issues/149) -- iconColor does not set icon background on Android [\#146](https://github.com/phonegap/phonegap-plugin-push/issues/146) -- Prevent windows toast notification when in foreground [\#145](https://github.com/phonegap/phonegap-plugin-push/issues/145) -- How to implement push notification for ios with this plug-in? [\#143](https://github.com/phonegap/phonegap-plugin-push/issues/143) -- After installing this plugin I can't build on Android [\#141](https://github.com/phonegap/phonegap-plugin-push/issues/141) -- version 1.2.3 [\#134](https://github.com/phonegap/phonegap-plugin-push/issues/134) -- New inbox style on android [\#131](https://github.com/phonegap/phonegap-plugin-push/issues/131) -- impossible to install the phonegap-plugin-push Error [\#130](https://github.com/phonegap/phonegap-plugin-push/issues/130) -- Hello, i am developing a cordova app which requires push notifications to be sent to users android phone, so i tried using this new phonegap push plugin as old one is deprecated, and it keeps giving me an error in console: Uncaught ReferenceError: module is not defined --- Line 154 Push.js and i dont have much experience with cordova, so can anyone assist me ? [\#128](https://github.com/phonegap/phonegap-plugin-push/issues/128) -- INVALID\_REGISTRATION when http post request with to IOS [\#123](https://github.com/phonegap/phonegap-plugin-push/issues/123) -- Andriod :More than 2 notifications in status bar it is not works. [\#121](https://github.com/phonegap/phonegap-plugin-push/issues/121) -- Release notes for 1.2.x [\#119](https://github.com/phonegap/phonegap-plugin-push/issues/119) -- Google cloud messaging GCM - Push Notification not being sent \(Server Side\) [\#110](https://github.com/phonegap/phonegap-plugin-push/issues/110) - -## [1.2.3](https://github.com/phonegap/phonegap-plugin-push/tree/1.2.3) (2015-09-08) -[Full Changelog](https://github.com/phonegap/phonegap-plugin-push/compare/1.2.2...1.2.3) - -**Fixed bugs:** - -- Notification not showing..... [\#101](https://github.com/phonegap/phonegap-plugin-push/issues/101) -- Same data payload for messages with action buttons [\#90](https://github.com/phonegap/phonegap-plugin-push/issues/90) - -**Closed issues:** - -- Notification doesn't show the app icon [\#112](https://github.com/phonegap/phonegap-plugin-push/issues/112) -- Notification doesn't show the app icon [\#111](https://github.com/phonegap/phonegap-plugin-push/issues/111) -- Issue with plugin facebook connect [\#107](https://github.com/phonegap/phonegap-plugin-push/issues/107) -- Cordova Support [\#99](https://github.com/phonegap/phonegap-plugin-push/issues/99) -- Uncaught ReferenceError: cordova is not defined, http://localhost:8100/lib/push.js, Line: 7 [\#98](https://github.com/phonegap/phonegap-plugin-push/issues/98) -- Notifications never received on Android [\#96](https://github.com/phonegap/phonegap-plugin-push/issues/96) -- How know the way the app was launched [\#95](https://github.com/phonegap/phonegap-plugin-push/issues/95) -- Android, example doesn't work when it goes into background [\#94](https://github.com/phonegap/phonegap-plugin-push/issues/94) -- Utilizing push plugin [\#91](https://github.com/phonegap/phonegap-plugin-push/issues/91) - -## [1.2.2](https://github.com/phonegap/phonegap-plugin-push/tree/1.2.2) (2015-08-31) -[Full Changelog](https://github.com/phonegap/phonegap-plugin-push/compare/1.2.1...1.2.2) - -**Closed issues:** - -- PushPlugin notification icon is too big [\#88](https://github.com/phonegap/phonegap-plugin-push/issues/88) - -## [1.2.1](https://github.com/phonegap/phonegap-plugin-push/tree/1.2.1) (2015-08-31) -[Full Changelog](https://github.com/phonegap/phonegap-plugin-push/compare/1.2.0...1.2.1) - -**Implemented enhancements:** - -- Question about GCM Notifications and data in the message payload [\#87](https://github.com/phonegap/phonegap-plugin-push/issues/87) - -**Fixed bugs:** - -- Notification callback for pushes without a message [\#80](https://github.com/phonegap/phonegap-plugin-push/issues/80) - -**Closed issues:** - -- Android: No notification displayed on device. Notification event never called. [\#86](https://github.com/phonegap/phonegap-plugin-push/issues/86) -- it seem no wp8 version for now [\#56](https://github.com/phonegap/phonegap-plugin-push/issues/56) - -## [1.2.0](https://github.com/phonegap/phonegap-plugin-push/tree/1.2.0) (2015-08-25) -[Full Changelog](https://github.com/phonegap/phonegap-plugin-push/compare/1.1.1...1.2.0) - -**Implemented enhancements:** - -- Implement Inbox style for Android [\#74](https://github.com/phonegap/phonegap-plugin-push/issues/74) -- multi-line text support [\#63](https://github.com/phonegap/phonegap-plugin-push/issues/63) - -**Fixed bugs:** - -- Pushes being deleted from notification bar when cold start [\#67](https://github.com/phonegap/phonegap-plugin-push/issues/67) - -**Closed issues:** - -- oficial push plugin and windows and wp8 compatibility [\#71](https://github.com/phonegap/phonegap-plugin-push/issues/71) -- On Android, GCMIntentService.onError\(\) doesn't get passed to the JavaScript "error" event [\#65](https://github.com/phonegap/phonegap-plugin-push/issues/65) -- Android: add property to vibrate phone on received notification [\#61](https://github.com/phonegap/phonegap-plugin-push/issues/61) -- push.on =\> "registration" will trigger twice times that only in iOS [\#57](https://github.com/phonegap/phonegap-plugin-push/issues/57) - -## [1.1.1](https://github.com/phonegap/phonegap-plugin-push/tree/1.1.1) (2015-07-27) -[Full Changelog](https://github.com/phonegap/phonegap-plugin-push/compare/1.1.0...1.1.1) - -## [1.1.0](https://github.com/phonegap/phonegap-plugin-push/tree/1.1.0) (2015-07-27) -[Full Changelog](https://github.com/phonegap/phonegap-plugin-push/compare/1.0.1...1.1.0) - -**Implemented enhancements:** - -- iOS doesn't add foreground key [\#41](https://github.com/phonegap/phonegap-plugin-push/issues/41) -- Android: Notification icon problem [\#20](https://github.com/phonegap/phonegap-plugin-push/issues/20) -- iOS badge number [\#18](https://github.com/phonegap/phonegap-plugin-push/issues/18) -- How i can set icons for push notifications in status bar and push view in android [\#14](https://github.com/phonegap/phonegap-plugin-push/issues/14) -- Support Win8.1 + Phone 8.1 Universal Apps \(WNS\), drop support for WP8.0 \(MPNS\) [\#13](https://github.com/phonegap/phonegap-plugin-push/issues/13) - -**Fixed bugs:** - -- iOS only reads out "aps" payload [\#29](https://github.com/phonegap/phonegap-plugin-push/issues/29) -- Event not fired when in background [\#24](https://github.com/phonegap/phonegap-plugin-push/issues/24) -- Custom notification sound in background mode? [\#17](https://github.com/phonegap/phonegap-plugin-push/issues/17) - -**Closed issues:** - -- iOS only receives first notification in foreground [\#42](https://github.com/phonegap/phonegap-plugin-push/issues/42) -- Cannot register on iOS [\#30](https://github.com/phonegap/phonegap-plugin-push/issues/30) -- Fix Android paths in src folder [\#23](https://github.com/phonegap/phonegap-plugin-push/issues/23) -- PushNotification not defined [\#21](https://github.com/phonegap/phonegap-plugin-push/issues/21) -- Error trying to remove the plugin [\#19](https://github.com/phonegap/phonegap-plugin-push/issues/19) -- Handling multiple notifications on Android devices [\#12](https://github.com/phonegap/phonegap-plugin-push/issues/12) -- PGB \(build.phonegap.com\) problem [\#11](https://github.com/phonegap/phonegap-plugin-push/issues/11) -- reporting location via gcm [\#6](https://github.com/phonegap/phonegap-plugin-push/issues/6) - -**Merged pull requests:** - -- Updating Readme to document toast capable setting [\#47](https://github.com/phonegap/phonegap-plugin-push/pull/47) ([rakatyal](https://github.com/rakatyal)) -- fix issue \#41 [\#44](https://github.com/phonegap/phonegap-plugin-push/pull/44) ([Deminetix](https://github.com/Deminetix)) -- fix issue \#42 [\#43](https://github.com/phonegap/phonegap-plugin-push/pull/43) ([Deminetix](https://github.com/Deminetix)) -- Adding hyperlinks to README [\#40](https://github.com/phonegap/phonegap-plugin-push/pull/40) ([rakatyal](https://github.com/rakatyal)) -- Updating Readme [\#37](https://github.com/phonegap/phonegap-plugin-push/pull/37) ([rakatyal](https://github.com/rakatyal)) -- Adding windows support to plugin [\#36](https://github.com/phonegap/phonegap-plugin-push/pull/36) ([rakatyal](https://github.com/rakatyal)) -- Raghav/update [\#35](https://github.com/phonegap/phonegap-plugin-push/pull/35) ([rakatyal](https://github.com/rakatyal)) -- Adding behavior for different notification types [\#28](https://github.com/phonegap/phonegap-plugin-push/pull/28) ([rakatyal](https://github.com/rakatyal)) -- Initial commit to add support for windows universal platform [\#15](https://github.com/phonegap/phonegap-plugin-push/pull/15) ([rakatyal](https://github.com/rakatyal)) - -## [1.0.1](https://github.com/phonegap/phonegap-plugin-push/tree/1.0.1) (2015-06-08) -[Full Changelog](https://github.com/phonegap/phonegap-plugin-push/compare/1.0.0...1.0.1) - -**Closed issues:** - -- documentation "senderId" correction [\#10](https://github.com/phonegap/phonegap-plugin-push/issues/10) -- add to our ci page [\#9](https://github.com/phonegap/phonegap-plugin-push/issues/9) -- Update installation instructions [\#7](https://github.com/phonegap/phonegap-plugin-push/issues/7) - -## [1.0.0](https://github.com/phonegap/phonegap-plugin-push/tree/1.0.0) (2015-06-05) -**Closed issues:** - -- Update code using enabledRemoteNotificationTypes because it is “not supported in iOS 8” [\#8](https://github.com/phonegap/phonegap-plugin-push/issues/8) -- Register method not working [\#4](https://github.com/phonegap/phonegap-plugin-push/issues/4) -- Publish plugin to npm [\#3](https://github.com/phonegap/phonegap-plugin-push/issues/3) -- Update example to use new API [\#2](https://github.com/phonegap/phonegap-plugin-push/issues/2) -- Lowercase Example/ directory [\#1](https://github.com/phonegap/phonegap-plugin-push/issues/1) - - - -\* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)* diff --git a/StoneIsland/plugins/phonegap-plugin-push/MIT-LICENSE b/StoneIsland/plugins/phonegap-plugin-push/MIT-LICENSE deleted file mode 100644 index a017eb00..00000000 --- a/StoneIsland/plugins/phonegap-plugin-push/MIT-LICENSE +++ /dev/null @@ -1,20 +0,0 @@ -Copyright 2012-2016 Adobe Systems - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/StoneIsland/plugins/phonegap-plugin-push/README.md b/StoneIsland/plugins/phonegap-plugin-push/README.md deleted file mode 100644 index 8f9ff5e9..00000000 --- a/StoneIsland/plugins/phonegap-plugin-push/README.md +++ /dev/null @@ -1,26 +0,0 @@ -#phonegap-plugin-push [](https://travis-ci.org/phonegap/phonegap-plugin-push) - -> Register and receive push notifications - -# What is this? - -This plugin offers support to receive and handle native push notifications with a **single unified API**. - -Starting with version `1.9.0`, this plugin will support `CocoaPods` installation of the `Google Cloud Messaging` library. More details are available in the [Installation](docs/INSTALLATION.md#cocoapods) documentation. - -- [Reporting Issues](docs/ISSUES.md) -- [Installation](docs/INSTALLATION.md) -- [API reference](docs/API.md) -- [Typescript support](docs/TYPESCRIPT.md) -- [Examples](docs/EXAMPLES.md) -- [Platform support](docs/PLATFORM_SUPPORT.md) -- [Cloud build support (PG Build, IntelXDK)](docs/PHONEGAP_BUILD.md) -- [Push notification payload details](docs/PAYLOAD.md) -- [Contributing](.github/CONTRIBUTING.md) -- [License (MIT)](MIT-LICENSE) - - -# Do you like tutorial? You get tutorial! - - - [PhoneGap Day US Push Workshop 2016 (using node-gcm)](http://macdonst.github.io/push-workshop/) - - [PhoneGap Day EU Push Workshop 2016 (using PhoneGap Push)](http://macdonst.github.io/push-workshop-eu/) diff --git a/StoneIsland/plugins/phonegap-plugin-push/bower.json b/StoneIsland/plugins/phonegap-plugin-push/bower.json deleted file mode 100644 index 79676644..00000000 --- a/StoneIsland/plugins/phonegap-plugin-push/bower.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "name": "phonegap-plugin-push", - "description": "bower package for server side javascript", - "main": "www/push.js", - "authors": [ - "Adobe PhoneGap Team" - ], - "license": "APL", - "keywords": [ - "ecosystem:cordova", - "ecosystem:phonegap", - "cordova-ios", - "cordova-android", - "cordova-windows", - "cordova-browser" - ], - "homepage": "https://github.com/phonegap/phonegap-plugin-push", - "moduleType": [], - "ignore": [ - "**/.*", - "node_modules", - "bower_components", - "test", - "tests" - ] -} diff --git a/StoneIsland/plugins/phonegap-plugin-push/docs/API.md b/StoneIsland/plugins/phonegap-plugin-push/docs/API.md deleted file mode 100644 index e0481af8..00000000 --- a/StoneIsland/plugins/phonegap-plugin-push/docs/API.md +++ /dev/null @@ -1,425 +0,0 @@ -# API - -- [.init()](#pushnotificationinitoptions) -- [.hasPermission() - Android & iOS only](#pushnotificationhaspermissionsuccesshandler---android--ios-only) -- [push.on()](#pushonevent-callback) - - [push.on('registration')](#pushonregistration-callback) - - [push.on('notification')](#pushonnotification-callback) - - [push.on('error')](#pushonerror-callback) -- [push.off()](#pushoffevent-callback) -- [push.unregister()](#pushunregistersuccesshandler-errorhandler-topics) -- [push.subscribe()](#pushsubscribetopic-successhandler-errorhandler) -- [push.unsubscribe()](#pushunsubscribetopic-successhandler-errorhandler) -- [push.setApplicationIconBadgeNumber() - iOS & Android only](#pushsetapplicationiconbadgenumbersuccesshandler-errorhandler-count---ios--android-only) -- [push.getApplicationIconBadgeNumber() - iOS only](#pushgetapplicationiconbadgenumbersuccesshandler-errorhandler---ios-only) -- [push.finish() - iOS only](#pushfinishsuccesshandler-errorhandler-id---ios-only) -- [push.clearAllNotifications() - iOS & Android only](#pushclearallnotificationssuccesshandler-errorhandler---ios--android-only) - -## PushNotification.init(options) - -Initializes the plugin on the native side. - -**Note:** like all plugins you must wait until you receive the [`deviceready`](https://cordova.apache.org/docs/en/5.4.0/cordova/events/events.deviceready.html) event before calling `PushNotification.init()`. - -**Note:** you will want to call `PushNotification.init()` each time your app starts. The remote push service can periodically reset your registration ID so this ensures you have the correct value. - -### Returns - -- Instance of `PushNotification`. - -### Parameters - -Parameter | Type | Default | Description ---------- | ---- | ------- | ----------- -`options` | `Object` | `{}` | An object describing relevant specific options for all target platforms. - -All available option attributes are described bellow. Currently, there are no Windows specific options. - -#### Android - -Attribute | Type | Default | Description ---------- | ---- | ------- | ----------- -`android.senderID` | `string` | | Maps to the project number in the Google Developer Console. -`android.icon` | `string` | | Optional. The name of a drawable resource to use as the small-icon. The name should not include the extension. -`android.iconColor` | `string` | | Optional. Sets the background color of the small icon on Android 5.0 and greater. [Supported Formats](http://developer.android.com/reference/android/graphics/Color.html#parseColor(java.lang.String)) -`android.sound` | `boolean` | `true` | Optional. If `true` it plays the sound specified in the push data or the default system sound. -`android.vibrate` | `boolean` | `true` | Optional. If `true` the device vibrates on receipt of notification. -`android.clearBadge` | `boolean` | `false` | Optional. If `true` the icon badge will be cleared on init and before push messages are processed. -`android.clearNotifications` | `boolean` | `true` | Optional. If `true` the app clears all pending notifications when it is closed. -`android.forceShow` | `boolean` | `false` | Optional. Controls the behavior of the notification when app is in foreground. If `true` and app is in foreground, it will show a notification in the notification drawer, the same way as when the app is in background (and `on('notification')` callback will be called *only when the user clicks the notification*). When `false` and app is in foreground, the `on('notification')` callback will be called immediately. -`android.topics` | `array` | `[]` | Optional. If the array contains one or more strings each string will be used to subscribe to a GcmPubSub topic. - -#### Browser - -Attribute | Type | Default | Description ---------- | ---- | ------- | ----------- -`browser.pushServiceURL` | `string` | `http://push.api.phonegap.com/v1/push` | Optional. URL for the push server you want to use. - -#### iOS - -All iOS boolean options can also be specified as `string` - -Attribute | Type | Default | Description ---------- | ---- | ------- | ----------- -`ios.alert` | `boolean` | `false` | Optional. If `true` the device shows an alert on receipt of notification. **Note:** the value you set this option to the first time you call the init method will be how the application always acts. Once this is set programmatically in the init method it can only be changed manually by the user in Settings>Notifications>`App Name`. This is normal iOS behaviour. -`ios.badge` | `boolean` | `false` | Optional. If `true` the device sets the badge number on receipt of notification. **Note:** the value you set this option to the first time you call the init method will be how the application always acts. Once this is set programmatically in the init method it can only be changed manually by the user in Settings>Notifications>`App Name`. This is normal iOS behaviour. -`ios.sound` | `boolean` | `false` | Optional. If `true` the device plays a sound on receipt of notification. **Note:** the value you set this option to the first time you call the init method will be how the application always acts. Once this is set programmatically in the init method it can only be changed manually by the user in Settings>Notifications>`App Name`. This is normal iOS behaviour. -`ios.clearBadge` | `boolean` | `false` | Optional. If `true` the badge will be cleared on app startup. -`ios.categories` | `Object` | `{}` | Optional. The data required in order to enabled Action Buttons for iOS. See [Action Buttons on iOS](https://github.com/phonegap/phonegap-plugin-push/blob/master/docs/PAYLOAD.md#action-buttons-1) for more details. - -#### iOS GCM support - -The following properties are used if you want use GCM on iOS. - -Attribute | Type | Default | Description ---------- | ---- | ------- | ----------- -`ios.senderID` | `string` | `undefined` (Native) | Maps to the project number in the Google Developer Console. Setting this uses GCM for notifications instead of native -`ios.gcmSandbox` | `boolean` | `false` | Whether to use prod or sandbox GCM setting. Defaults to false. -`ios.topics` | `array` | `[]` | Optional. If the array contains one or more strings each string will be used to subscribe to a GcmPubSub topic. Note: only usable in conjunction with `senderID`. - -##### How GCM on iOS works. - -First it is kind of a misnomer as GCM does not send push messages directly to devices running iOS. - -What happens is on the device side is that it registers with APNS, then that registration ID is sent to GCM which returns a different GCM specific ID. That is the ID you get from the push plugin `registration` event. - -When you send a message to GCM using that ID, what it does is look up the APNS registration ID on it's side and forward the message you sent to GCM on to APSN to deliver to your iOS device. - -Make sure that the certificate you build with matches your `gcmSandbox` value. - -- If you build your app as development and set `gcmSandbox: false` it will fail. -- If you build your app as production and set `gcmSandbox: true` it will fail. -- If you build your app as development and set `gcmSandbox: true` but haven't uploaded the development certs to Google it will fail. -- If you build your app as production and set `gcmSandbox: false` but haven't uploaded the production certs to Google it will fail. - -> Note: The integration between GCM and APNS is a bit finicky. Personally, I feel it is much better to send pushes to Android using GCM and pushes to iOS using APNS which this plugin does support. - -### Example - -```javascript -var push = PushNotification.init({ - android: { - senderID: "12345679" - }, - browser: { - pushServiceURL: 'http://push.api.phonegap.com/v1/push' - }, - ios: { - alert: "true", - badge: true, - sound: 'false' - }, - windows: {} -}); -``` - -## PushNotification.hasPermission(successHandler) - Android & iOS only - -Checks whether the push notification permission has been granted. - -### Parameters - -Parameter | Type | Default | Description ---------- | ---- | ------- | ----------- -`successHandler` | `Function` | | Is called when the api successfully retrieves the details on the permission. - -### Callback parameters - -#### `successHandler` - -Parameter | Type | Description ---------- | ---- | ----------- -`data.isEnabled` | `Boolean` | Whether the permission for push notifications has been granted. - -### Example - -```javascript -PushNotification.hasPermission(function(data) { - if (data.isEnabled) { - console.log('isEnabled'); - } -}); -``` - -## push.on(event, callback) - -### Parameters - -Parameter | Type | Default | Description ---------- | ---- | ------- | ----------- -`event` | `string` | | Name of the event to listen to. See below for all the event names. -`callback` | `Function` | | Is called when the event is triggered. - -## push.on('registration', callback) - -The event `registration` will be triggered on each successful registration with the 3rd party push service. - -### Callback parameters - -Parameter | Type | Description ---------- | ---- | ----------- -`data.registrationId` | `string` | The registration ID provided by the 3rd party remote push service. - -### Example - -```javascript -push.on('registration', function(data) { - console.log(data.registrationId); -}); -``` - -For APNS users: the `registrationId` you will get will be a production or sandbox id according to how the app was built. ([Source](https://developer.apple.com/library/ios/technotes/tn2265/_index.html)) - -> Note: There is a separate persistent connection to the push service for each environment. The operating system establishes a persistent connection to the sandbox environment for development builds; ad hoc and distribution builds connect to the production environment. - - - -### Common Problems - -#### Got JSON Exception TIMEOUT - -If you run this plugin on older versions of Android and you get an error: - -``` -E/PushPlugin(20077): execute: Got JSON Exception TIMEOUT -``` - -It means you are running an older version of Google Play Services. You will need to open the Google Play Store app and update your version of Google Play Services. - -## push.on('notification', callback) - -The event `notification` will be triggered each time a push notification is received by a 3rd party push service on the device. - -### Callback parameters - -Parameter | Type | Description ---------- | ---- | ----------- -`data.message` | `string` | The text of the push message sent from the 3rd party service. -`data.title` | `string` | The optional title of the push message sent from the 3rd party service. -`data.count` | `string` | The number of messages to be displayed in the badge in iOS/Android or message count in the notification shade in Android. For windows, it represents the value in the badge notification which could be a number or a status glyph. -`data.sound` | `string` | The name of the sound file to be played upon receipt of the notification. -`data.image` | `string` | The path of the image file to be displayed in the notification. -`data.launchArgs` | `string` | The args to be passed to the application on launch from push notification. This works when notification is received in background. (Windows Only) -`data.additionalData` | `Object` | An optional collection of data sent by the 3rd party push service that does not fit in the above properties. -`data.additionalData.foreground` | `boolean` | Whether the notification was received while the app was in the foreground -`data.additionalData.coldstart` | `boolean` | Will be `true` if the application is started by clicking on the push notification, `false` if the app is already started. - -### Example - -```javascript -push.on('notification', function(data) { - console.log(data.message); - console.log(data.title); - console.log(data.count); - console.log(data.sound); - console.log(data.image); - console.log(data.additionalData); -}); -``` - -## push.on('error', callback) - -The event `error` will trigger when an internal error occurs and the cache is aborted. - -### Callback parameters - -Parameter | Type | Description ---------- | ---- | ----------- -`e` | `Error` | Standard JavaScript error object that describes the error. - -### Example - -```javascript -push.on('error', function(e) { - console.log(e.message); -}); -``` - -## push.off(event, callback) - -Removes a previously registered callback for an event. - -### Parameters - -Parameter | Type | Default | Description ---------- | ---- | ------- | ----------- -`event` | `string` | | Name of the event type. The possible event names are the same as for the `push.on` function. -`callback` | `Function` | | The same callback used to register with `push.on`. - -### Example -```javascript -var callback = function(data){ /*...*/}; - -//Adding handler for notification event -push.on('notification', callback); - -//Removing handler for notification event -push.off('notification', callback); -``` - -**WARNING**: As stated in the example, you will have to store your event handler if you are planning to remove it. - -## push.unregister(successHandler, errorHandler, topics) - -The unregister method is used when the application no longer wants to receive push notifications. Beware that this cleans up all event handlers previously registered, so you will need to re-register them if you want them to function again without an application reload. - -If you provide a list of topics as an optional parameter then the application will unsubscribe from these topics but continue to receive other push messages. - -### Parameters - -Parameter | Type | Default | Description ---------- | ---- | ------- | ----------- -`successHandler` | `Function` | | Is called when the api successfully unregisters. -`errorHandler` | `Function` | | Is called when the api encounters an error while unregistering. -`topics` | `Array` | | A list of topics to unsubscribe from. - -### Example - -```javascript -push.unregister(function() { - console.log('success'); -}, function() { - console.log('error'); -}); -``` - -## push.subscribe(topic, successHandler, errorHandler) - -The subscribe method is used when the application wants to subscribe a new topic to receive push notifications. - -### Parameters - -Parameter | Type | Default | Description ---------- | ---- | ------- | ----------- -`topic` | `String` | | Topic to subscribe to. -`successHandler` | `Function` | | Is called when the api successfully subscribes. -`errorHandler` | `Function` | | Is called when the api encounters an error while subscribing. - -### Example - -```javascript -push.subscribe('my-topic', function() { - console.log('success'); -}, function(e) { - console.log('error:'); - console.log(e); -}); -``` -## push.unsubscribe(topic, successHandler, errorHandler) - -The unsubscribe method is used when the application no longer wants to receive push notifications from a specific topic but continue to receive other push messages. - -### Parameters - -Parameter | Type | Default | Description ---------- | ---- | ------- | ----------- -`topic` | `String` | | Topic to unsubscribe from. -`successHandler` | `Function` | | Is called when the api successfully unsubscribe. -`errorHandler` | `Function` | | Is called when the api encounters an error while unsubscribing. - -### Example - -```javascript -push.unsubscribe('my-topic', function() { - console.log('success'); -}, function(e) { - console.log('error:'); - console.log(e); -}); -``` - -## push.setApplicationIconBadgeNumber(successHandler, errorHandler, count) - iOS & Android only - -Set the badge count visible when the app is not running - -> Note: badges are not supported on all Android devices. See [our payload documentation](PAYLOAD.md#badges) for more details. - -### Parameters - -Parameter | Type | Default | Description ---------- | ---- | ------- | ----------- -`successHandler` | `Function` | | Is called when the api successfully sets the icon badge number. -`errorHandler` | `Function` | | Is called when the api encounters an error while trying to set the icon badge number. -`count` | `number` | | Indicates what number should show up in the badge. Passing 0 will clear the badge. Each `notification` event contains a `data.count` value which can be used to set the badge to correct number. - -### Example - -```javascript -push.setApplicationIconBadgeNumber(function() { - console.log('success'); -}, function() { - console.log('error'); -}, 2); -``` - -## push.getApplicationIconBadgeNumber(successHandler, errorHandler) - iOS only - -Get the current badge count visible when the app is not running - -### Parameters - -Parameter | Type | Default | Description ---------- | ---- | ------- | ----------- -`successHandler` | `Function` | | Is called when the api successfully retrieves the icon badge number. -`errorHandler` | `Function` | | Is called when the api encounters an error while trying to retrieve the icon badge number. - -### Callback parameters - -#### `successHandler` - -Parameter | Type | Description ---------- | ---- | ----------- -`n` | `number` | An integer which is the current badge count. - -### Example - -```javascript -push.getApplicationIconBadgeNumber(function(n) { - console.log('success', n); -}, function() { - console.log('error'); -}); -``` - -## push.finish(successHandler, errorHandler, id) - iOS only - -Tells the OS that you are done processing a background push notification. - -### Parameters - -Parameter | Type | Default | Description ---------- | ---- | ------- | ----------- -`successHandler` | `Function` | | Is called when the api successfully completes background push processing. -`errorHandler` | `Function` | | Is called when the api encounters an error while processing and completing the background push. -`id` | `String` | | Tells the OS which background process is complete. - -### Example - -```javascript -push.finish(function() { - console.log('success'); -}, function() { - console.log('error'); -}, 'push-1'); -``` - -## push.clearAllNotifications(successHandler, errorHandler) - iOS & Android only - -Tells the OS to clear all notifications from the Notification Center - -### Parameters - -Parameter | Type | Default | Description ---------- | ---- | ------- | ----------- -`successHandler` | `Function` | | Is called when the api successfully clears the notifications. -`errorHandler` | `Function` | | Is called when the api encounters an error when attempting to clears the notifications. - -### Example - -```javascript -push.clearAllNotifications(function() { - console.log('success'); -}, function() { - console.log('error'); -}); -``` diff --git a/StoneIsland/plugins/phonegap-plugin-push/docs/EXAMPLES.md b/StoneIsland/plugins/phonegap-plugin-push/docs/EXAMPLES.md deleted file mode 100644 index 8481e7bc..00000000 --- a/StoneIsland/plugins/phonegap-plugin-push/docs/EXAMPLES.md +++ /dev/null @@ -1,43 +0,0 @@ -# Creating a Project From a Template - -If you want to get started with a sample project you can create a new project from the example template. - -``` -phonegap create my-app --template phonegap-template-push -``` - -## Quick Example - -```javascript -var push = PushNotification.init({ - android: { - senderID: "12345679" - }, - browser: { - pushServiceURL: 'http://push.api.phonegap.com/v1/push' - }, - ios: { - alert: "true", - badge: "true", - sound: "true" - }, - windows: {} -}); - -push.on('registration', function(data) { - // data.registrationId -}); - -push.on('notification', function(data) { - // data.message, - // data.title, - // data.count, - // data.sound, - // data.image, - // data.additionalData -}); - -push.on('error', function(e) { - // e.message -}); -``` diff --git a/StoneIsland/plugins/phonegap-plugin-push/docs/INSTALLATION.md b/StoneIsland/plugins/phonegap-plugin-push/docs/INSTALLATION.md deleted file mode 100644 index 830bbdd7..00000000 --- a/StoneIsland/plugins/phonegap-plugin-push/docs/INSTALLATION.md +++ /dev/null @@ -1,313 +0,0 @@ -# Installation - -- [Installation Requirements](#installation-requirements) -- [Android details](#android-details) - - [Compilation](#compilation) - - [Co-existing with Facebook Plugin](#co-existing-with-facebook-plugin) - - [Common errors](#common-errors) - - [minSdkVersion === 14](#minsdkversion--14) - - [Multidex](#multidex) - - [More than one library with package name 'com.google.android.gms'](#more-than-one-library-with-package-name-comgoogleandroidgms) -- [Browser details](#browser-details) - - [Browser quirks](#browser-quirks) - - [Browser Support](#browser-support) -- [iOS details](#ios-details) - - [Xcode](#xcode) - - [Bitcode](#bitcode) - - [CocoaPods](#cocoapods) - - [Common CocoaPod Installation issues](#common-cocoapod-installation-issues) -- [Additional Resources](#additional-resources) - -## Installation Requirements - -Plugin version | Cordova CLI | Cordova Android | Cordova iOS | CocoaPods ----- | ---- | ---- | ---- | ---- -1.9.0 | 6.4.0 | 6.0.0 | 4.3.0 | 1.1.1 -1.8.0 | 3.6.3 | 4.0.0 | 4.1.0 | N/A - -To install from the command line: - -``` -phonegap plugin add phonegap-plugin-push --variable SENDER_ID="XXXXXXX" -``` -or - -``` -cordova plugin add phonegap-plugin-push --variable SENDER_ID="XXXXXXX" -``` - -It is also possible to install via repo url directly ( unstable ) - -``` -phonegap plugin add https://github.com/phonegap/phonegap-plugin-push --variable SENDER_ID="XXXXXXX" -``` - -or - -``` -cordova plugin add https://github.com/phonegap/phonegap-plugin-push --variable SENDER_ID="XXXXXXX" -``` - -Where the `XXXXXXX` in `SENDER_ID="XXXXXXX"` maps to the project number in the [Google Developer Console](https://www.google.ca/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&cad=rja&uact=8&ved=0ahUKEwikqt3nyPjMAhXJ5iYKHR0qDcsQFggbMAA&url=https%3A%2F%2Fconsole.developers.google.com%2F&usg=AFQjCNF0eH059mv86nMIlRmfsf42kde-wA&sig2=BQ2BJpchw1CpGt87sk5p6w&bvm=bv.122852650,d.eWE). To find the project number login to the Google Developer Console, select your project and click the menu item in the screen shot below to display your project number. - - - -If you are not creating an Android application you can put in anything for this value. - -> Note: if you are using Ionic you may need to specify the SENDER_ID variable in your package.json. - -``` - "cordovaPlugins": [ - { - "variables": { - "SENDER_ID": "XXXXXXX" - }, - "locator": "phonegap-plugin-push" - } - ] -``` - -> Note: You need to specify the SENDER_ID variable in your config.xml if you plan on installing/restoring plugins using the prepare method. The prepare method will skip installing the plugin otherwise. - -``` -<plugin name="phonegap-plugin-push" spec="1.6.0"> - <param name="SENDER_ID" value="XXXXXXX" /> -</plugin> -``` - -## Android details - -### Compilation - -As of version 1.3.0 the plugin has been switched to using Gradle/Maven for building. - -You will need to ensure that you have installed the following items through the Android SDK Manager: - -- Android Support Library version 23 or greater -- Local Maven repository for Support Libraries (formerly Android Support Repository) version 20 or greater -- Google Play Services version 27 or greater -- Google Repository version 22 or greater - - - -For more detailed instructions on how to install the Android Support Library visit [Google's documentation](https://developer.android.com/tools/support-library/setup.html). - -*Note:* if you are using an IDE to like Eclipse, Xamarin, etc. then the Android SDK installed by those tools may not be the same version as the one used by the Cordova/PhoneGap CLI while building. Please make sure your command line tooling is up to date with the software versions above. An easy way to make sure you up to date is to run the following command: - -``` -android update sdk --no-ui --filter "extra" -``` - -### Co-existing with Facebook Plugin - -There are a number of Cordova Facebook Plugins available but the one that we recommend is [Jeduan's fork](https://github.com/jeduan/cordova-plugin-facebook4) of the original Wizcorp plugin. It is setup to use Gradle/Maven and the latest Facebook SDK properly. - -To add to your app: - -``` -phonegap plugin add --save cordova-plugin-facebook4 --variable APP_ID="App ID" --variable APP_NAME="App Name" -``` -or - -``` -cordova plugin add --save cordova-plugin-facebook4 --variable APP_ID="App ID" --variable APP_NAME="App Name" -``` - -### Common errors - -#### minSdkVersion === 14 - -If you have an issue compiling the app and you are getting an error similar to this: - -``` -* What went wrong: -Execution failed for task ':processDebugManifest'. -> Manifest merger failed : uses-sdk:minSdkVersion 14 cannot be smaller than version 15 declared in library .../platforms/android/build/intermediates/exploded-aar/com.facebook.android/facebook-android-sdk/4.6.0/AndroidManifest.xml - Suggestion: use tools:overrideLibrary="com.facebook" to force usage -``` - -Then you can add the following entry into your config.xml file in the android platform tag: - -```xml -<platform name="android"> - <preference name="android-minSdkVersion" value="15"/> - </platform> -``` - -or compile your project using the following command, if the solution above doesn't work for you. Basically add `-- --minSdkVersion=15` to the end of the command line (mind the extra `--`, it's needed): - -```bash -cordova compile android -- --minSdkVersion=15 -cordova build android -- --minSdkVersion=15 -cordova run android -- --minSdkVersion=15 -cordova emulate android -- --minSdkVersion=15 -``` - -#### Multidex - -If you have an issue compiling the app and you're getting an error similar to this (`com.android.dex.DexException: Multiple dex files define`): - -``` -UNEXPECTED TOP-LEVEL EXCEPTION: -com.android.dex.DexException: Multiple dex files define Landroid/support/annotation/AnimRes; - at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:596) - at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:554) - at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:535) - at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:171) - at com.android.dx.merge.DexMerger.merge(DexMerger.java:189) - at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:502) - at com.android.dx.command.dexer.Main.runMonoDex(Main.java:334) - at com.android.dx.command.dexer.Main.run(Main.java:277) - at com.android.dx.command.dexer.Main.main(Main.java:245) - at com.android.dx.command.Main.main(Main.java:106) -``` - -Then at least one other plugin you have installed is using an outdated way to declare dependencies such as `android-support` or `play-services-gcm`. -This causes gradle to fail, and you'll need to identify which plugin is causing it and request an update to the plugin author, so that it uses the proper way to declare dependencies for cordova. -See [this for the reference on the cordova plugin specification](https://cordova.apache.org/docs/en/5.4.0/plugin_ref/spec.html#link-18), it'll be usefull to mention it when creating an issue or requesting that plugin to be updated. - -Common plugins to suffer from this outdated dependency management are plugins related to *facebook*, *google+*, *notifications*, *crosswalk* and *google maps*. - -#### More than one library with package name 'com.google.android.gms' - -When some other packages include `cordova-google-play-services` as a dependency, such as is the case with the cordova-admob and cordova-plugin-analytics plugins, it is impossible to also add the phonegap-plugin-push, for the following error will rise during the build process: - -``` -:processDebugResources FAILED -FAILURE: Build failed with an exception. - -What went wrong: Execution failed for task ':processDebugResources'. > Error: more than one library with package name 'com.google.android.gms' -``` - -Those plugins should be using gradle to include the Google Play Services package but instead they include the play services jar directly or via a plugin dependency. So all of that is bad news. These plugins should be updated to use gradle. Please raise issues on those plugins as the change is not hard to make. - -In fact there is a PR open to do just that appfeel/analytics-google#11 for cordova-plugin-analytics. You should bug the team at appfeel to merge that PR. - -Alternatively, switch to another plugin that provides the same functionality but uses gradle: - -[https://github.com/danwilson/google-analytics-plugin](https://github.com/danwilson/google-analytics-plugin) -[https://github.com/cmackay/google-analytics-plugin](https://github.com/cmackay/google-analytics-plugin) - -## Browser details - -### Browser quirks - -For the time being push support on the browser will only work using the PhoneGap push server. - -When you run `phonegap serve` to test browser push point your browser at `http://localhost:3000`. The browser push implementation uses the W3C Push Spec's implementation which relies on ServiceWorkers and ServiceWorkers can only be accessed via the `https` protocol or via `http://localhost`. Pointing your browser at `localhost` will be the easiest way to test. - -### Browser Support - -Chrome 49+ -Firefox 46+ - -## iOS details - -### Xcode - -Xcode version 8.0 or greater is required for building this plugin. - -### Bitcode - -If you are running into a problem where the linker is complaining about bit code. For instance: - -``` -ld: '<file.o>' does not contain bitcode. You must rebuild it with bitcode enabled (Xcode setting ENABLE_BITCODE), obtain an updated library from the vendor, or disable bitcode for this target. for architecture arm64 clang: error: linker command failed with exit code 1 (use -v to see invocation) -``` - -You have two options. The first is to [disable bitcode as per this StackOverflow answer](http://stackoverflow.com/a/32466484/41679) or [upgrade to cordova-ios 4 or greater](https://cordova.apache.org/announcements/2015/12/08/cordova-ios-4.0.0.html). - -``` -cordova platform update ios@4.0.0 -``` - -### CocoaPods - -Required `cordova-cli` version: `6.4.0` - -Required `cordova-ios` version: `4.3.0` - -Version `1.9.0` (and above) of this plugin supports [CocoaPods](https://cocoapods.org) installation of the [Google Cloud Messaging](https://cocoapods.org/pods/GoogleCloudMessaging) library. - -If you are installing this plugin using `npm`, and you are using version `6.1.0` or greater of the `cordova-cli`, it will automatically download the right version of this plugin for both your platform and cli. - -If you are on a `cordova-cli` version less than `6.1.0`, you will either have to upgrade your `cordova-cli` version, or install the plugin explicitly: - -i.e. -``` -cordova plugin add phonegap-plugin-push@1.8.1 -``` - -If you are installing this plugin using a `local file reference` or a `git url`, you will have to specify the version of this plugin explicitly (see above) if you don't fulfill the `cordova-cli` and `cordova-ios` requirements. - -#### Common CocoaPod Installation issues - -If you are attempting to install this plugin and you run into this error: - -``` -Installing "phonegap-plugin-push" for ios -Failed to install 'phonegap-plugin-push':Error: pod: Command failed with exit code 1 - at ChildProcess.whenDone (/Users/smacdona/code/push151/platforms/ios/cordova/node_modules/cordova-common/src/superspawn.js:169:23) - at emitTwo (events.js:87:13) - at ChildProcess.emit (events.js:172:7) - at maybeClose (internal/child_process.js:818:16) - at Process.ChildProcess._handle.onexit (internal/child_process.js:211:5) -Error: pod: Command failed with exit code 1 -``` - -Please run the command `pod repo update` and re-install the plugin. - -## Additional Resources - -The push plugin enables you to play sounds and display different icons during push (Android only). These additional resources need to be added to your projects `platforms` directory in order for them to be included into your final application binary. One way of doing it is to create a hook to do the copying for you on each build. - -First create a `scripts` directory in the root of your project. Next add a file to the scripts directory called `copy_resource_files.js`. The contents of the file will look something like this: - -```javascript -#!/usr/bin/env node - -// each object in the array consists of a key which refers to the source and -// the value which is the destination. -var filestocopy = [{ - "resources/android/images/logo.png": - "platforms/android/res/drawable/logo.png" -}, { - "resources/android/sounds/ring.mp3": - "platforms/android/res/raw/ring.mp3" -}, { - "resources/ios/sounds/ring.caf": - "platforms/ios/YourAppName/ring.caf" -}, ]; - -var fs = require('fs'); -var path = require('path'); - -// no need to configure below -var rootdir = process.argv[2]; - -filestocopy.forEach(function(obj) { - Object.keys(obj).forEach(function(key) { - var val = obj[key]; - var srcfile = path.join(rootdir, key); - var destfile = path.join(rootdir, val); - //console.log("copying "+srcfile+" to "+destfile); - var destdir = path.dirname(destfile); - if (fs.existsSync(srcfile) && fs.existsSync(destdir)) { - fs.createReadStream(srcfile).pipe( - fs.createWriteStream(destfile)); - } - }); -}); -``` - -Obviously, you'll need to modify the `filestocopy` variable to suit your needs. Pay attention to the destination path on iOS where you will need to replace `YourAppName`. - -Next open up your `config.xml` file and add the following line: - -```xml -<hook type="before_build" src="scripts/copy_resource_files.js" /> -``` - -Now, when you build your app the files will get copied into your platforms directory for you. - -If you are using PhoneGap Build check out these instructions on [Additional Resources](PHONEGAP_BUILD.md#additional-resources) diff --git a/StoneIsland/plugins/phonegap-plugin-push/docs/ISSUES.md b/StoneIsland/plugins/phonegap-plugin-push/docs/ISSUES.md deleted file mode 100644 index 3b3021af..00000000 --- a/StoneIsland/plugins/phonegap-plugin-push/docs/ISSUES.md +++ /dev/null @@ -1,80 +0,0 @@ -# ISSUES - -- [Read the docs](#read-the-docs) -- [Search the issues](#search-the-issues) -- [Opening a new issue](#opening-a-new-issue) - - [Provide details](#provide-details) - - [An example issue](#an-example-issue) -- [Voting on an issue](#voting-on-an-issue) - -The following tips are for users of this plugin who want to get help. - -## Read the docs - -I'll be the first to admit that the docs are not perfect but start here at the [README](https://github.com/phonegap/phonegap-plugin-push/blob/master/README.md) to see if your problem is documented. If it isn't continue on but if you do get an answer then consider sending a documentation pull request. - -## Search the issues - -Your question may have already been answered. Make sure you search at least the repo's [issues](https://github.com/phonegap/phonegap-plugin-push/issues) before you create a new one. - -## Opening a new issue - -If you have searched the issues and haven't found anything that resembles your problem then follow these guidelines in creating a new issue. - -### Provide details - -Give as many details as possible. Issues without many details will be more difficult to debug and will encounter delays. - -Select a concise, informative title for the issue. Here's a good article on writing [subject lines](https://www.nngroup.com/articles/microcontent-how-to-write-headlines-page-titles-and-subject-lines/). - -Include the following at a minimum: -_ what version number of plugin are you using? -- which platform and version you are testing on? iOS 9.0, Android 5.0, etc. -- a detailed description of your problem. Including: - - steps to reproduce - - expected result - - actual result -- how you are sending the push data to the device, including an example payload - -You may also want to include: -- some sample code that illustrates the problem. -- logs taken while the problem was reproduced. -- screenshots! - -If the code or logs are huge, let's say over 20 lines please think about using a web service like [Gist](https://gist.github.com/) or [Pastebin](http://pastebin.com/). - -### An example issue - -**The wrong way** - -*Title:* This plugin does not work for me - -*Details:* Please fix quickly as my business depends on this plugin. - -**The right way** - -*Title:* Registration event never received on Samsung Galaxy S running Android 2.3 - -*Details:* I'm using version 1.5.2 of this plugin on my Samsung Galaxy S5 device which runs Android 4.4. I never receiving the `registration` event in my application when I expect it to return a value I can send to my push service. - -You can see the code I'm using in this gist: [https://gist.github.com/macdonst/191f74ac75b6802c047d](https://gist.github.com/macdonst/191f74ac75b6802c047d) - -And an output of the logs when trying to run the app are in this gist: [https://gist.github.com/macdonst/47549150c299080c455c](https://gist.github.com/macdonst/47549150c299080c455c) - -Please point me in the right direction. - -*Response:* - -Thanks for the detailed logs and example code by looking them over I'm sure of what your problem is. If you look at line [334](https://gist.github.com/macdonst/47549150c299080c455c#file-logcat-txt-L334) of your logcat you will see that it complains that: - -``` -I/chromium(11669): [INFO:CONSOLE(54)] "Uncaught ReferenceError: PushNotification is not defined", source: file:///android_asset/www/js/index.js (54) -``` - -This leads me to line [4](https://gist.github.com/macdonst/191f74ac75b6802c047d#file-app-js-L4) of your code where you are initializing push before you get the `deviceready` event. Like all Cordova API's you have to wait until you receive the `deviceready` event before you initialize Push. - -Check out [https://github.com/phonegap/phonegap-plugin-push/blob/20f489a90cf519f962fd957700f92115f142594b/example/www/js/index.js](https://github.com/phonegap/phonegap-plugin-push/blob/20f489a90cf519f962fd957700f92115f142594b/example/www/js/index.js) for an example of how to wait for `deviceready`. - -## Voting on an issue - -Did you know you can vote on issues in the phonegap-plugin-push repository? If you install the [ZenHub](https://chrome.google.com/webstore/detail/zenhub-for-github/ogcgkffhplmphkaahpmffcafajaocjbd) Chrome Extension you will be able to +1 issues to indicate how popular they are to the community. It's a way better way for the contributors to keep track of important issues. diff --git a/StoneIsland/plugins/phonegap-plugin-push/docs/PAYLOAD.md b/StoneIsland/plugins/phonegap-plugin-push/docs/PAYLOAD.md deleted file mode 100644 index b446612e..00000000 --- a/StoneIsland/plugins/phonegap-plugin-push/docs/PAYLOAD.md +++ /dev/null @@ -1,1400 +0,0 @@ -- [Overview](#overview) - - [Foreground Events](#push-message-arrives-with-app-in-foreground) - - [Background Events](#push-message-arrives-with-app-in-background) - - [Tap Events](#user-clicks-on-notification-in-notification-center) -- [Android Behaviour](#android-behaviour) - - [Localization](#localization) - - [Images](#images) - - [Sound](#sound) - - [Stacking](#stacking) - - [Inbox Stacking](#inbox-stacking) - - [Action Buttons](#action-buttons) - - [In Line Replies](#in-line-replies) - - [Led in Notifications](#led-in-notifications) - - [Vibration Pattern in Notifications](#vibration-pattern-in-notifications) - - [Priority in Notifications](#priority-in-notifications) - - [Picture Messages](#picture-messages) - - [Background Notifications](#background-notifications) - - [Use of content-available: true](#use-of-content-available-true) - - [Huawei and Xiaomi Phones](#huawei-and-xiaomi-phones) - - [Application force closed](#application-force-closed) - - [Visibility](#visibility-of-notifications) - - [Badges](#badges) - - [Support for Twilio Notify](#support-for-twilio-notify) -- [iOS Behaviour](#ios-behaviour) - - [Sound](#sound-1) - - [Background Notifications](#background-notifications-1) - - [Action Buttons](#action-buttons-1) - - [Action Buttons using GCM on iOS](#action-buttons-using-gcm-on-ios) - - [GCM and Additional Data](#gcm-and-additional-data) -- [Windows Behaviour](#windows-behaviour) - - [Notifications](#notifications) - - [Setting Toast Capable Option for Windows](#setting-toast-capable-option-for-windows) - - [Disabling the default processing of notifications by Windows](#disabling-the-default-processing-of-notifications-by-windows) - - [Background Notifications](#background-notifications-2) - - -# Overview - -The following flowchart attempts to give you a picture of what happens when a push message arrives on your device when you have an app using phonegap-plugin-push. - - - -## Push message arrives with app in foreground - -- The push plugin receives the data from the remote push service and calls all of your `notification` event handlers. -- The message is *not* displayed in the devices notification center as that is not normal behaviour for Android or iOS. - -## Push message arrives with app in background - -- The push plugin receives the data from the remote push service and checks to see if there is a title or message in the data received. If there is then the message will be displayed in the devices notification center. -- Then the push plugin checks to see if the app is running. If the user has killed the application then no further processing of the push data will occur. -- If the app is running in the background the push plugin then checks to see if `content-available` exists in the push data. -- If `content-available` is set to `1` then the plugin calls all of your `notification` event handlers. - -## User clicks on notification in notification center - -- The app starts. -- Then the plugin calls all of your `notification` event handlers. - -> Note: if the push payload contained `content-available: 1` then your `notification` event handler has already been called. It is up to you to handle the double event. - -Some ways to handle this *double* event are: - -- don't include title/message in the push so it doesn't show up in the shader. -- send two pushes, one to be processed in the background the other to show up in the shade. -- include a unique ID in your push so you can check to see if you've already processed this event. - -# Android Behaviour - -## Localization - -Plugin supported localization from resources for: title, message and summaryText. - -You may use simple link to locale constant. - -```javascript -{ - "registration_ids": ["my device id"], - "data": { - "title": {"locKey": "push_app_title"}, - "message": "Simple non-localizable text for message!" - } -} -``` - -Or use localization with formatted constants. - -```javascript -{ - "registration_ids": ["my device id"], - "data": { - "title": {"locKey": "push_app_title"}, - "message": {"locKey": "push_message_fox", "locData": ["fox", "dog"]} - } -} -``` - -Here is an example using node-gcm that sends the above JSON: - -```javascript -var gcm = require('node-gcm'); -// Replace these with your own values. -var apiKey = "replace with API key"; -var deviceID = "my device id"; -var service = new gcm.Sender(apiKey); -var message = new gcm.Message(); -message.addData('title', {"locKey": "push_app_title"}); -message.addData('message', 'Simple non-localizable text for message!'); -// Constant with formatted params -// message.addData('message', {"locKey": "push_message_fox", "locData": ["fox", "dog"]}); -service.send(message, { registrationTokens: [ deviceID ] }, function (err, response) { - if(err) console.error(err); - else console.log(response); -}); -``` - -Localization must store in strings.xml - -```xml -<string name="push_app_title">@string/app_name</string> -<string name="push_message_fox">The quick brown %1$s jumps over the lazy %2$s</string> -<string name="push_summary_text">%%n%% new message(s)</string> -``` - -## Images - -By default the icon displayed in your push notification will be your apps icon. So when you initialize the plugin like this: - -```javascript -var push = PushNotification.init({ - "android": { - "senderID": "12345679" - }, - browser: { - pushServiceURL: 'http://push.api.phonegap.com/v1/push' - }, - "ios": { - "alert": "true", - "badge": "true", - "sound": "true" - }, - "windows": {} -}); -``` - -The result will look much like this: - - - -This is because Android now uses Material design and the default icon for push will be completely white. - -In order to get a better user experience you can specify an alternate icon and background color to be shown when receiving a push notification. The code would look like this: - -```javascript -var push = PushNotification.init({ - "android": { - "senderID": "123456789", - "icon": "phonegap", - "iconColor": "blue" - }, - browser: { - pushServiceURL: 'http://push.api.phonegap.com/v1/push' - }, - "ios": { - "alert": "true", - "badge": "true", - "sound": "true" - }, - "windows": {} -}); -``` - -Where *icon* is the name of an image in the Android *drawables* folder. Writing a hook to describe how to copy an image to the Android *drawables* folder is out of scope for this README but there is an [excellent tutorial](http://devgirl.org/2013/11/12/three-hooks-your-cordovaphonegap-project-needs/) that you can copy. - -*iconColor* is one of the supported formats #RRGGBB or #AARRGGBB or one of the following names: 'red', 'blue', 'green', 'black', 'white', 'gray', 'cyan', 'magenta', 'yellow', 'lightgray', 'darkgray', 'grey', 'lightgrey', 'darkgrey', 'aqua', 'fuchsia', 'lime', 'maroon', 'navy', 'olive', 'purple', 'silver', 'teal'. *iconColor* is supported on Android 5.0 and greater. - -Please follow the [Android icon design guidelines](https://www.google.com/design/spec/style/icons.html#) when creating your icon. - - - -Additionally, each push can include a large icon which is used to personalize each push. The location of the image may one of three types. - -The first is the *drawables* folder in your app. This JSON sent from GCM: - -```javascript -{ - "registration_ids": ["my device id"], - "data": { - "title": "Large Icon", - "message": "Loaded from drawables folder", - "image": "twitter" - } -} -``` - -Here is an example using node-gcm that sends the above JSON: - -```javascript -var gcm = require('node-gcm'); -// Replace these with your own values. -var apiKey = "replace with API key"; -var deviceID = "my device id"; -var service = new gcm.Sender(apiKey); -var message = new gcm.Message(); -message.addData('title', 'Large Icon'); -message.addData('message', 'Loaded from drawables folder.'); -message.addData('image', 'twitter'); -service.send(message, { registrationTokens: [ deviceID ] }, function (err, response) { - if(err) console.error(err); - else console.log(response); -}); -``` - -Would look for the *twitter* image in the drawables folder and produce the following notification. - - - -The second is the *assets* folder in your app. This JSON sent from GCM: - -```javascript -{ - "registration_ids": ["my device id"], - "data": { - "title": "Large Icon", - "message": "Loaded from assets folder", - "image": "www/image/logo.png" - } -} -``` - -Here is an example using node-gcm that sends the above JSON: - -```javascript -var gcm = require('node-gcm'); -// Replace these with your own values. -var apiKey = "replace with API key"; -var deviceID = "my device id"; -var service = new gcm.Sender(apiKey); -var message = new gcm.Message(); -message.addData('title', 'Large Icon'); -message.addData('message', 'Loaded from assets folder.'); -message.addData('image', 'www/image/logo.png'); -service.send(message, { registrationTokens: [ deviceID ] }, function (err, response) { - if(err) console.error(err); - else console.log(response); -}); -``` - -Would look for the *logo.png* file in the assets/www/img folder. Since your apps www folder gets copied into the Android assets folder it is an excellent spot to store the images without needing to write a hook to copy them to the *drawables* folder. It produces the following notification. - - - - -The third is the remote *URL*. This JSON sent from GCM: - -```javascript -{ - "registration_ids": ["my device id"], - "data": { - "title": "Large Icon", - "message": "Loaded from URL", - "image": "https://dl.dropboxusercontent.com/u/887989/antshot.png" - } -} -``` - -Here is an example using node-gcm that sends the above JSON: - -```javascript -var gcm = require('node-gcm'); -// Replace these with your own values. -var apiKey = "replace with API key"; -var deviceID = "my device id"; -var service = new gcm.Sender(apiKey); -var message = new gcm.Message(); -message.addData('title', 'Large Icon'); -message.addData('message', 'Loaded from URL'); -message.addData('image', 'https://dl.dropboxusercontent.com/u/887989/antshot.png'); -service.send(message, { registrationTokens: [ deviceID ] }, function (err, response) { - if(err) console.error(err); - else console.log(response); -}); -``` - -Produces the following notification. - - - -## Sound - -For Android there are three special values for sound you can use. The first is `default` which will play the phones default notification sound. - -```javascript -{ - "registration_ids": ["my device id"], - "data": { - "title": "Default", - "message": "Plays default notification sound", - "soundname": "default" - } -} -``` - -Then second is `ringtone` which will play the phones default ringtone sound. - -```javascript -{ - "registration_ids": ["my device id"], - "data": { - "title": "Ringtone", - "message": "Plays default ringtone sound", - "soundname": "ringtone" - } -} -``` -The third is the empty string which will cause for the playing of sound to be skipped. - -```javascript -{ - "registration_ids": ["my device id"], - "data": { - "title": "Silece", - "message": "Skips playing any sound", - "soundname": "" - } -} -``` - -In order for your your notification to play a custom sound you will need to add the files to your Android project's `res/raw` directory. Then send the follow JSON from GCM: - -```javascript -{ - "registration_ids": ["my device id"], - "data": { - "title": "Sound Test", - "message": "Loaded res/raw", - "soundname": "test" - } -} -``` - -Here is an example using node-gcm that sends the above JSON: - -```javascript -var gcm = require('node-gcm'); -// Replace these with your own values. -var apiKey = "replace with API key"; -var deviceID = "my device id"; -var service = new gcm.Sender(apiKey); -var message = new gcm.Message(); -message.addData('title', 'Sound Test'); -message.addData('message', 'Loaded res/raw'); -message.addData('soundname', 'test'); -service.send(message, { registrationTokens: [ deviceID ] }, function (err, response) { - if(err) console.error(err); - else console.log(response); -}); -``` - -*Note:* when you specify the custom sound file name omit the file's extension. - -## Stacking - -By default when using this plugin on Android each notification that your app receives will replace the previous notification in the shade. - -If you want to see multiple notifications in the shade you will need to provide a notification ID as part of the push data sent to the app. For instance if you send: - -```javascript -{ - "registration_ids": ["my device id"], - "data": { - "title": "Test Push", - "message": "Push number 1" - } -} -``` - -Here is an example using node-gcm that sends the above JSON: - -```javascript -var gcm = require('node-gcm'); -// Replace these with your own values. -var apiKey = "replace with API key"; -var deviceID = "my device id"; -var service = new gcm.Sender(apiKey); -var message = new gcm.Message(); -message.addData('title', 'Test Push'); -message.addData('message', 'Push number 1'); -service.send(message, { registrationTokens: [ deviceID ] }, function (err, response) { - if(err) console.error(err); - else console.log(response); -}); -``` - -Followed by: - -```javascript -{ - "registration_ids": ["my device id"], - "data": { - "title": "Test Push", - "message": "Push number 2" - } -} -``` - -Here is an example using node-gcm that sends the above JSON: - -```javascript -var gcm = require('node-gcm'); -// Replace these with your own values. -var apiKey = "replace with API key"; -var deviceID = "my device id"; -var service = new gcm.Sender(apiKey); -var message = new gcm.Message(); -message.addData('title', 'Test Push'); -message.addData('message', 'Push number 2'); -service.send(message, { registrationTokens: [ deviceID ] }, function (err, response) { - if(err) console.error(err); - else console.log(response); -}); -``` - -You will only see "Push number 2" in the shade. However, if you send: - -```javascript -{ - "registration_ids": ["my device id"], - "data": { - "title": "Test Push", - "message": "Push number 1", - "notId": 1 - } -} -``` - -Here is an example using node-gcm that sends the above JSON: - -```javascript -var gcm = require('node-gcm'); -// Replace these with your own values. -var apiKey = "replace with API key"; -var deviceID = "my device id"; -var service = new gcm.Sender(apiKey); -var message = new gcm.Message(); -message.addData('title', 'Test Push'); -message.addData('message', 'Push number 1'); -message.addData('notId', 1); -service.send(message, { registrationTokens: [ deviceID ] }, function (err, response) { - if(err) console.error(err); - else console.log(response); -}); -``` - -and: - -```javascript -{ - "registration_ids": ["my device id"], - "data": { - "title": "Test Push", - "message": "Push number 2", - "notId": 2 - } -} -``` - -Here is an example using node-gcm that sends the above JSON: - -```javascript -var gcm = require('node-gcm'); -// Replace these with your own values. -var apiKey = "replace with API key"; -var deviceID = "my device id"; -var service = new gcm.Sender(apiKey); -var message = new gcm.Message(); -message.addData('title', 'Test Push'); -message.addData('message', 'Push number 2'); -message.addData('notId', 2); -service.send(message, { registrationTokens: [ deviceID ] }, function (err, response) { - if(err) console.error(err); - else console.log(response); -}); -``` - -You will see both "Push number 1" and "Push number 2" in the shade. - -## Inbox Stacking - -A better alternative to stacking your notifications is to use the inbox style to have up to 8 lines of notification text in a single notification. If you send the following JSON from GCM you will see: - -```javascript -{ - "registration_ids": ["my device id"], - "data": { - "title": "My Title", - "message": "My first message", - "style": "inbox", - "summaryText": "There are %n% notifications" - } -} -``` - -Here is an example using node-gcm that sends the above JSON: - -```javascript -var gcm = require('node-gcm'); -// Replace these with your own values. -var apiKey = "replace with API key"; -var deviceID = "my device id"; -var service = new gcm.Sender(apiKey); -var message = new gcm.Message(); -message.addData('title', 'My Title'); -message.addData('message', 'My first message'); -message.addData('style', 'inbox'); -message.addData('summaryText', 'There are %n% notifications'); -service.send(message, { registrationTokens: [ deviceID ] }, function (err, response) { - if(err) console.error(err); - else console.log(response); -}); -``` - -It will produce a normal looking notification: - - - -But, if you follow it up with subsequent notifications like: - -```javascript -{ - "registration_ids": ["my device id"], - "data": { - "title": "My Title", - "message": "My second message", - "style": "inbox", - "summaryText": "There are %n% notifications" - } -} -``` - -Here is an example using node-gcm that sends the above JSON: - -```javascript -var gcm = require('node-gcm'); -// Replace these with your own values. -var apiKey = "replace with API key"; -var deviceID = "my device id"; -var service = new gcm.Sender(apiKey); -var message = new gcm.Message(); -message.addData('title', 'My Title'); -message.addData('message', 'My second message'); -message.addData('style', 'inbox'); -message.addData('summaryText', 'There are %n% notifications'); -service.send(message, { registrationTokens: [ deviceID ] }, function (err, response) { - if(err) console.error(err); - else console.log(response); -}); -``` - -You will get an inbox view so you can display multiple notifications in a single panel. - - - -If you use `%n%` in the `summaryText` of the JSON coming down from GCM it will be replaced by the number of messages that are currently in the queue. - -## Action Buttons - -Your notification can include a maximum of three action buttons. If you wish to include an icon along with the button name they must be placed in the `res/drawable` directory of your Android project. Then you can send the following JSON from GCM: - -```javascript -{ - "registration_ids": ["my device id"], - "data": { - "title": "AUX Scrum", - "message": "Scrum: Daily touchbase @ 10am Please be on time so we can cover everything on the agenda.", - "actions": [ - { "icon": "emailGuests", "title": "EMAIL GUESTS", "callback": "app.emailGuests", "foreground": true}, - { "icon": "snooze", "title": "SNOOZE", "callback": "app.snooze", "foreground": false} - ] - } -} -``` - -Here is an example using node-gcm that sends the above JSON: - -```javascript -var gcm = require('node-gcm'); -// Replace these with your own values. -var apiKey = "replace with API key"; -var deviceID = "my device id"; -var service = new gcm.Sender(apiKey); -var message = new gcm.Message(); -message.addData('title', 'AUX Scrum'); -message.addData('message', 'Scrum: Daily touchbase @ 10am Please be on time so we can cover everything on the agenda.'); -message.addData('actions', [ - { "icon": "emailGuests", "title": "EMAIL GUESTS", "callback": "app.emailGuests", "foreground": true}, - { "icon": "snooze", "title": "SNOOZE", "callback": "app.snooze", "foreground": false}, -]); -service.send(message, { registrationTokens: [ deviceID ] }, function (err, response) { - if(err) console.error(err); - else console.log(response); -}); -``` - -This will produce the following notification in your tray: - - - -If your user clicks on the main body of the notification your app will be opened. However if they click on either of the action buttons the app will open (or start) and the specified JavaScript callback will be executed if there is a function defined, and if there isn't an event will be emitted with the callback name. In this case it is `app.emailGuests` and `app.snooze` respectively. If you set the `foreground` property to `true` the app will be brought to the front, if `foreground` is `false` then the callback is run without the app being brought to the foreground. - -### In Line Replies - -Android N introduces a new capability for push notifications, the in line reply text field. If you wish to get some text data from the user when the action button is called send the following type of payload: - -Your notification can include action buttons. If you wish to include an icon along with the button name they must be placed in the `res/drawable` directory of your Android project. Then you can send the following JSON from GCM: - -```javascript -{ - "registration_ids": ["my device id"], - "data": { - "title": "AUX Scrum", - "message": "Scrum: Daily touchbase @ 10am Please be on time so we can cover everything on the agenda.", - "actions": [ - { "icon": "emailGuests", "title": "EMAIL GUESTS", "callback": "app.emailGuests", "foreground": false, "inline": true }, - { "icon": "snooze", "title": "SNOOZE", "callback": "app.snooze", "foreground": false} - ] - } -} -``` - -Here is an example using node-gcm that sends the above JSON: - -```javascript -var gcm = require('node-gcm'); -// Replace these with your own values. -var apiKey = "replace with API key"; -var deviceID = "my device id"; -var service = new gcm.Sender(apiKey); -var message = new gcm.Message(); -message.addData('title', 'AUX Scrum'); -message.addData('message', 'Scrum: Daily touchbase @ 10am Please be on time so we can cover everything on the agenda.'); -message.addData('actions', [ - { "icon": "emailGuests", "title": "EMAIL GUESTS", "callback": "app.emailGuests", "foreground": false, "inline": true}, - { "icon": "snooze", "title": "SNOOZE", "callback": "app.snooze", "foreground": false}, -]); -service.send(message, { registrationTokens: [ deviceID ] }, function (err, response) { - if(err) console.error(err); - else console.log(response); -}); -``` - -On Android N and greater when the user clicks on the Email Guests button they will see the following: - - - -Then your app's `on('notification')` event handler will be called without the app being brought to the foreground and the event data would be: - -``` -{ - "title": "AUX Scrum", - "message": "Scrum: Daily touchbase @ 10am Please be on time so we can cover everything on the agenda.", - "additionalData": { - "inlineReply": "Sounds good", - "actions": [ - { - "inline": true, - "callback": "app.accept", - "foreground": false, - "title": "Accept" - }, - { - "icon": "snooze", - "callback": "app.reject", - "foreground": false, - "title": "Reject" - } - ], - "actionCallback": "app.accept", - "coldstart": false, - "collapse_key": "do_not_collapse", - "foreground": false - } -} -``` - -and the text data that the user typed would be located in `data.additionalData.inlineReply`. - -**Note:** On Android M and earlier the above in line behavior is not supported. As a fallback when `inline` is set to `true` the `foreground` setting will be changed to the default `true` setting. This allows your app to be launched from a closed state into the foreground where any behavior desired as a result of the user selecting the in line reply action button can be handled through the associated `callback`. - -#### Attributes - -Attribute | Type | Default | Description ---------- | ---- | ------- | ----------- -`icon` | `string` | | Optional. The name of a drawable resource to use as the small-icon. The name should not include the extension. -`title` | `string` | | Required. The label to display for the action button. -`callback` | `string` | | Required. The function to be executed or the event to be emitted when the action button is pressed. The function must be accessible from the global namespace. If you provide `myCallback` then it amounts to calling `window.myCallback`. If you provide `app.myCallback` then there needs to be an object call `app`, with a function called `myCallback` accessible from the global namespace, i.e. `window.app.myCallback`. If there isn't a function with the specified name an event will be emitted with the callback name. -`foreground` | `boolean` | `true` | Optional. Whether or not to bring the app to the foreground when the action button is pressed. -`inline` | `boolean` | `false` | Optional. Whether or not to provide a quick reply text field to the user when the button is clicked. - -## Led in Notifications - -You can use a Led notifcation and choose the color of it. Just add a `ledColor` field in your notification in the ARGB format array: - -```javascript -{ - "registration_ids": ["my device id"], - "data": { - "title": "Green LED", - "message": "This is my message with a Green LED", - "ledColor": [0, 0, 255, 0] - } -} -``` - -Here is an example using node-gcm that sends the above JSON: - -```javascript -var gcm = require('node-gcm'); -// Replace these with your own values. -var apiKey = "replace with API key"; -var deviceID = "my device id"; -var service = new gcm.Sender(apiKey); -var message = new gcm.Message(); -message.addData('title', 'Green LED'); -message.addData('message', 'This is my message with a Green LED'); -message.addData('ledColor', [0, 0, 255, 0]); -service.send(message, { registrationTokens: [ deviceID ] }, function (err, response) { - if(err) console.error(err); - else console.log(response); -}); -``` - -## Vibration Pattern in Notifications - -You can set a Vibration Pattern for your notifications. Just add a `vibrationPattern` field in your notification: - -```javascript -{ - "registration_ids": ["my device id"], - "data": { - "title": "Vibration Pattern", - "message": "Device should wait for 2 seconds, vibrate for 1 second then be silent for 500 ms then vibrate for 500 ms", - "vibrationPattern": [2000, 1000, 500, 500] - } -} -``` - -Here is an example using node-gcm that sends the above JSON: - -```javascript -var gcm = require('node-gcm'); -// Replace these with your own values. -var apiKey = "replace with API key"; -var deviceID = "my device id"; -var service = new gcm.Sender(apiKey); -var message = new gcm.Message(); -message.addData('title', 'Vibration Pattern'); -message.addData('message', 'Device should wait for 2 seconds, vibrate for 1 second then be silent for 500 ms then vibrate for 500 ms'); -message.addData('vibrationPattern', [2000, 1000, 500, 500]); -service.send(message, { registrationTokens: [ deviceID ] }, function (err, response) { - if(err) console.error(err); - else console.log(response); -}); -``` - -## Priority in Notifications - -You can set a priority parameter for your notifications. This priority value determines where the push notification will be put in the notification shade. Low-priority notifications may be hidden from the user in certain situations, while the user might be interrupted for a higher-priority notification. Add a `priority` field in your notification. -2: minimum, -1: low, 0: default , 1: high, 2: maximum priority. - -```javascript -{ - "registration_ids": ["my device id"], - "data": { - "title": "This is a maximum priority Notification", - "message": "This notification should appear in front of all others", - "priority": 2 - } -} -``` - -Here is an example using node-gcm that sends the above JSON: - -```javascript -var gcm = require('node-gcm'); -// Replace these with your own values. -var apiKey = "replace with API key"; -var deviceID = "my device id"; -var service = new gcm.Sender(apiKey); -var message = new gcm.Message(); -message.addData('title', 'This is a maximum priority Notification'); -message.addData('message', 'This notification should appear in front of all others'); -message.addData('priority', 2); -service.send(message, { registrationTokens: [ deviceID ] }, function (err, response) { - if(err) console.error(err); - else console.log(response); -}); -``` - -Do not confuse this with the GCM option of setting the [delivery priority of the message](https://developers.google.com/cloud-messaging/concept-options#setting-the-priority-of-a-message). Which is used by GCM to tell the device whether or not it should wake up to deal with the message. - -## Picture Messages - -Perhaps you want to include a large picture in the notification that you are sending to your users. Luckily you can do that too by sending the following JSON from GCM. - -```javascript -{ - "registration_ids": ["my device id"], - "data": { - "title": "Big Picture", - "message": "This is my big picture message", - "style": "picture", - "picture": "http://36.media.tumblr.com/c066cc2238103856c9ac506faa6f3bc2/tumblr_nmstmqtuo81tssmyno1_1280.jpg", - "summaryText": "The internet is built on cat pictures" - } -} -``` - -Here is an example using node-gcm that sends the above JSON: - -```javascript -var gcm = require('node-gcm'); -// Replace these with your own values. -var apiKey = "replace with API key"; -var deviceID = "my device id"; -var service = new gcm.Sender(apiKey); -var message = new gcm.Message(); -message.addData('title', 'Big Picture'); -message.addData('message', 'This is my big picture message'); -message.addData('style', 'picture'); -message.addData('picture', 'http://36.media.tumblr.com/c066cc2238103856c9ac506faa6f3bc2/tumblr_nmstmqtuo81tssmyno1_1280.jpg'); -message.addData('summaryText', 'The internet is built on cat pictures'); -service.send(message, { registrationTokens: [ deviceID ] }, function (err, response) { - if(err) console.error(err); - else console.log(response); -}); -``` - -This will produce the following notification in your tray: - - - -> Note: When the notification arrives you will see the title and message like normally. You will only see the picture when the notification is expanded. Once expanded not only will you see the picture but the message portion will disappear and you'll see the summary text portion. - -## Background Notifications - -On Android if you want your `on('notification')` event handler to be called when your app is in the background it is relatively simple. - -First the JSON you send from GCM will need to include `"content-available": "1"`. This will tell the push plugin to call your `on('notification')` event handler no matter what other data is in the push notification. - -```javascript -{ - "registration_ids": ["my device id"], - "data": { - "title": "Test Push", - "message": "Push number 1", - "info": "super secret info", - "content-available": "1" - } -} -``` - -Here is an example using node-gcm that sends the above JSON: - -```javascript -var gcm = require('node-gcm'); -// Replace these with your own values. -var apiKey = "replace with API key"; -var deviceID = "my device id"; -var service = new gcm.Sender(apiKey); -var message = new gcm.Message(); -message.addData('title', 'Test Push'); -message.addData('message', 'Push number 1'); -message.addData('info', 'super secret info'); -message.addData('content-available', '1'); -service.send(message, { registrationTokens: [ deviceID ] }, function (err, response) { - if(err) console.error(err); - else console.log(response); -}); -``` - -or if you want the payload to be delivered directly to your app without anything showing up in the notification center omit the tite/message from the payload like so: - - -```javascript -{ - "registration_ids": ["my device id"], - "data": { - "info": "super secret info", - "content-available": "1" - } -} -``` - -Here is an example using node-gcm that sends the above JSON: - -```javascript -var gcm = require('node-gcm'); -// Replace these with your own values. -var apiKey = "replace with API key"; -var deviceID = "my device id"; -var service = new gcm.Sender(apiKey); -var message = new gcm.Message(); -message.addData('info', 'super secret info'); -message.addData('content-available', '1'); -service.send(message, { registrationTokens: [ deviceID ] }, function (err, response) { - if(err) console.error(err); - else console.log(response); -}); -``` - -If do not want this type of behaviour just omit `"content-available": 1` from your push data and your `on('notification')` event handler will not be called. - -### Use of content-available: true - -The GCM docs will tell you to send a data payload of: - -```javascript -{ - "registration_ids": ["my device id"], - "content_available": true, - "data": { - "title": "Test Push", - "message": "Push number 1", - "info": "super secret info", - } -} -``` - -Where the `content-available` property is part of the main payload object. Setting the property in this part of the payload will result in the PushPlugin not getting the data correctly. Setting `content-available: true` will cause the Android OS to handle the push payload for you and not pass the data to the PushPlugin. - -Instead move `content-available: true` into the `data` object of the payload and set it to `1` as per the example below: - -```javascript -{ - "registration_ids": ["my device id"], - "data": { - "title": "Test Push", - "message": "Push number 1", - "info": "super secret info", - "content-available": "1" - } -} -``` - -### Huawei and Xiaomi Phones - -These phones have a particular quirk that when the app is force closed that you will no longer be able to receive notifications until the app is restarted. In order for you to receive background notifications: - -- On your Huawei device go to Settings > Protected apps > check "My App" where. -- On your Xiaomi makes sure your phone has the "Auto-start" property enabled for your app. - -### Application force closed - -In order to take advantage of this feature you will need to be using cordova-android 6.0.0 or higher. In order to check if the change has been properly applied look at `platforms/android/**/MainActivity.java`. You should see an `onCreate` method that looks like this: - -```java -@Override -public void onCreate(Bundle savedInstanceState) -{ - super.onCreate(savedInstanceState); - - // enable Cordova apps to be started in the background - Bundle extras = getIntent().getExtras(); - if (extras != null && extras.getBoolean("cdvStartInBackground", false)) { - moveTaskToBack(true); - } - - // Set by <content src="index.html" /> in config.xml - loadUrl(launchUrl); -} -``` - -If you don't see the `if` statement that checks for the appearance of `cdvStartInBackground` you will probably need to do: - -``` -phonegap platform rm android -phonegap platform add android -phonegap build android -``` - -This should add the correct code to the `MainActivity` class. - -If you add `force-start: 1` to the data payload the application will be restarted in background even if it was force closed. - -```javascript -{ - "registration_ids": ["my device id"], - "data": { - "title": "Force Start", - "message": "This notification should restart the app", - "force-start": 1 - } -} -``` - -Here is an example using node-gcm that sends the above JSON: - -```javascript -var gcm = require('node-gcm'); -// Replace these with your own values. -var apiKey = "replace with API key"; -var deviceID = "my device id"; -var service = new gcm.Sender(apiKey); -var message = new gcm.Message(); -message.addData('title', 'Force Start'); -message.addData('message', 'This notification should restart the app'); -message.addData('force-start', 1); -service.send(message, { registrationTokens: [ deviceID ] }, function (err, response) { - if(err) console.error(err); - else console.log(response); -}); -``` - -## Visibility of Notifications - -You can set a visibility parameter for your notifications. Just add a `visibility` field in your notification. -1: secret, 0: private (default), 1: public. `Secret` shows only the most minimal information, excluding even the notification's icon. `Private` shows basic information about the existence of this notification, including its icon and the name of the app that posted it. The rest of the notification's details are not displayed. `Public` Shows the notification's full content. - -```javascript -{ - "registration_ids": ["my device id"], - "data": { - "title": "This is a maximum public Notification", - "message": "This notification should appear in front of all others", - "visibility": 1 - } -} -``` - -Here is an example using node-gcm that sends the above JSON: - -```javascript -var gcm = require('node-gcm'); -// Replace these with your own values. -var apiKey = "replace with API key"; -var deviceID = "my device id"; -var service = new gcm.Sender(apiKey); -var message = new gcm.Message(); -message.addData('title', 'This is a public Notification'); -message.addData('message', 'You should be able to read this notification on your lock screen'); -message.addData('visibility', 1); -service.send(message, { registrationTokens: [ deviceID ] }, function (err, response) { - if(err) console.error(err); - else console.log(response); -}); -``` - -## Badges - -On Android not all launchers support badges. In order for us to set badges we use [ShortcutBadger](https://github.com/leolin310148/ShortcutBadger) in order to set the badge. Check out their website to see which launchers are supported. - -In order to set the badge number you will need to include the `badge` property in your push payload as below: - -```javascript -{ - "registration_ids": ["my device id"], - "data": { - "title": "Badge Test", - "message": "Badges, we don't need no stinking badges", - "badge": 7 - } -} -``` - -Here is an example using node-gcm that sends the above JSON: - -```javascript -var gcm = require('node-gcm'); -// Replace these with your own values. -var apiKey = "replace with API key"; -var deviceID = "my device id"; -var service = new gcm.Sender(apiKey); -var message = new gcm.Message(); -message.addData('title', 'Badge Test'); -message.addData('message', 'Badges, we don\'t need no stinking badges'); -message.addData('badge', 7); -service.send(message, { registrationTokens: [ deviceID ] }, function (err, response) { - if(err) console.error(err); - else console.log(response); -}); -``` - -## Support for Twilio Notify - -This plugin seamlessly supports payloads generated by Twilio Notify on Android. Specifically the parameters passed in to the Twilio REST API are available in the message payload passed to your app as follows: - -- `Title` --> `data.title` -- `Body` --> `data.message` -- `Sound` --> `data.sound` - -Here is an example request to Twilio REST API and the corresponding JSON received by your app. - -``` -curl 'https://notify.twilio.com/v1/Services/IS1e928b239609199df31d461071fd3d23/Notifications' -X POST \ ---data-urlencode 'Identity=Bob' \ ---data-urlencode 'Body=Hello Bob! Twilio Notify + Phonegap is awesome!' \ ---data-urlencode 'Title=Hello Bob!' \ ---data-urlencode 'Sound=chime' \ --u [AccountSID]:[AuthToken] -``` - -The JSON received by your app will comply with the standards described in the sections above: - -```javascript -{ - "registration_ids": ["my device id"], - "data": { - "title": "Hello Bob!", - "message": "Hello Bob! Twilio Notify + Phonegap is awesome!", - "sound": "chime" - } -} -``` - -Note: "sound" and "soundname" are equivalent and are considered to be the same by the plugin. - -# iOS Behaviour - -## Sound - -In order for your notification to play a custom sound you will need to add the files to root of your iOS project. The files must be in the proper format. See the [Local and Remote Notification Programming Guide](https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Chapters/IPhoneOSClientImp.html#//apple_ref/doc/uid/TP40008194-CH103-SW6) for more info on proper file formats and how to convert existing sound files. - -Then send the follow JSON from APNS: - -```javascript -{ - "aps": { - "alert": "Test sound", - "sound": "sub.caf" - } -} -``` - -If you want the default sound to play upon receipt of push use this payload: - -``` -{ - "aps": { - "alert": "Test sound", - "sound": "default" - } -} -``` - -## Background Notifications - -On iOS if you want your `on('notification')` event handler to be called when your app is in the background you will need to do a few things. - -First the JSON you send from APNS will need to include `"content-available": 1` to the `aps` object. The `"content-available": 1` property in your push message is a signal to iOS to wake up your app and give it up to 30 seconds of background processing. If do not want this type of behaviour just omit `"content-available": 1` from your push data. As well you *should* set a `notId` property in the root of payload object. This is the parameter you pass to the `finish` method in order to tell the operating system that the processing of the push event is done. - -For instance the following JSON: - -```javascript -{ - "aps": { - "alert": "Test background push", - "content-available": 1 - }, - "notId": 1 // unique ID you generate -} -``` - -will produce a notification in the notification shade and call your `on('notification')` event handler. - -**NOTE:** The `on('notification')` event handler will **not** be called if Background App Refresh is disabled on the user's iOS device. (Settings > General > Background App Refresh) - -However if you want your `on('notification')` event handler called but no notification to be shown in the shader you would omit the `alert` property and send the following JSON to APNS: - -```javascript -{ - "aps": { - "data": "Test silent background push", - "moredata": "Do more stuff", - "content-available": 1 - }, - "notId": 2 // unique ID you generate -} -``` - -That covers what you need to do on the server side to accept background pushes on iOS. However, it is critically important that you continue reading as there will be a change in your `on('notification')`. When you receive a background push on iOS you will be given 30 seconds of time in which to complete a task. If you spend longer than 30 seconds on the task the OS may decide that your app is misbehaving and kill it. In order to signal iOS that your `on('notification')` handler is done you will need to call the new `push.finish()` method. - -For example: - -```javascript -var push = PushNotification.init({ - "ios": { - "sound": "true", - "alert": "true", - "badge": "true", - "clearBadge": "true" - } -}); - -push.on('registration', function(data) { - // send data.registrationId to push service -}); - - -push.on('notification', function(data) { - // do something with the push data - // then call finish to let the OS know we are done - push.finish(function() { - console.log("processing of push data is finished"); - }, function() { - console.log("something went wrong with push.finish for ID = " + data.additionalData.notId) - }, data.additionalData.notId); -}); -``` - -It is absolutely critical that you call `push.finish()` when you have successfully processed your background push data. - -## Action Buttons - -Your notification can include action buttons. For iOS 8+ you must setup the possible actions when you initialize the plugin: - -```javascript -var push = PushNotification.init({ - "ios": { - "sound": true, - "alert": true, - "badge": true, - "categories": { - "invite": { - "yes": { - "callback": "app.accept", "title": "Accept", "foreground": true, "destructive": false - }, - "no": { - "callback": "app.reject", "title": "Reject", "foreground": true, "destructive": false - }, - "maybe": { - "callback": "app.maybe", "title": "Maybe", "foreground": true, "destructive": false - } - }, - "delete": { - "yes": { - "callback": "app.doDelete", "title": "Delete", "foreground": true, "destructive": true - }, - "no": { - "callback": "app.cancel", "title": "Cancel", "foreground": true, "destructive": false - } - } - } - } -}); -``` - -You’ll notice that we’ve added a new parameter to the iOS object of our init code called categories. Each category is a named object, invite and delete in this case. These names will need to match the one you send via your payload to APNS if you want the action buttons to be displayed. Each category can have up to three buttons which must be labeled `yes`, `no` and `maybe`. In turn each of these buttons has four properties, `callback` the javascript function you want to call, `title` the label for the button, `foreground` whether or not to bring your app to the foreground and `destructive` which doesn’t actually do anything destructive it just colors the button red as a warning to the user that the action may be destructive. - -Just like with background notifications it is absolutely critical that you call `push.finish()` when you have successfully processed the button callback. For instance: - -```javascript -app.accept = function(data) { - // do something with the notification data - - push.finish(function() { - console.log('accept callback finished'); - }, function() { - console.log('accept callback failed'); - }, data.additionalData.notId); -}; -``` - -You may notice that the `finish` method now takes `success`, `failure` and `id` parameters. The `id` parameter let's the operating system know which background process to stop. You'll set it in the next step. - -Then you will need to set the `category` value in your `aps` payload to match one of the objects in the `categories` object. As well you *should* set a `notId` property in the root of payload object. This is the parameter you pass to the `finish` method in order to tell the operating system that the processing of the push event is done. - -```javascript -{ - "aps": { - "alert": "This is a notification that will be displayed ASAP.", - "category": "invite" - }, - "notId": "1" -} -``` - -This will produce the following notification in your tray: - - - -If your users clicks on the main body of the notification your app will be opened. However if they click on either of the action buttons the app will open (or start) and the specified JavaScript callback will be executed. - -### Action Buttons using GCM on iOS - -If you are using GCM to send push messages on iOS you will need to send a different payload in order for the action buttons to be present in the notification shade. You'll need to use the `click-action` property in order to specify the category. - -```javascript -{ - "registration_ids": ["my device id"], - "notification": { - "title": "AUX Scrum", - "body": "Scrum: Daily touchbase @ 10am Please be on time so we can cover everything on the agenda.", - "click-action": "invite" - } -} -``` - -## GCM and Additional Data - -GCM on iOS is a different animal. The way you send data via GCM on Android is like: - -```javascript -{ - "registration_ids": ["my device id"], - "data": { - "title": "My Title", - "message": "My message", - "key1": "data 1", - "key2": "data 2" - } -} -``` - -will produce a `notification` event with the following data: - -```javascript -{ - "title": "My Title", - "message": "My message", - "additionalData": { - "key1": "data 1", - "key2": "data 2" - } -} -``` - -but in order for the same `notification` event you would need to send your push to GCM iOS in a slight different format: - -```javascript -{ - "registration_ids": ["my device id"], - "notification": { - "title": "My Title", - "body": "My message" - } - "data": { - "key1": "data 1", - "key2": "data 2" - } -} -``` - -The `title` and `body` need to be in the `notification` part of the payload in order for the OS to pick them up correctly. Everything else should be in the `data` part of the payload. - -## GCM Messages Not Arriving - -For some users of the plugin they are unable to get messages sent via GCM to show up on their devices. If you are running into this issue try setting the `priority` of the message to `high` in the payload. - -```javascript -{ - "registration_ids": ["my device id"], - "notification": { - "title": "My Title", - "body": "My message" - }, - "priority": "high" -} -``` - -# Windows Behaviour - -## Notifications - -The plugin supports all types of windows platform notifications namely [Tile, Toast, Badge and Raw](https://msdn.microsoft.com/en-us/library/windows/apps/Hh779725.aspx). The API supports the basic cases of the notification templates with title corresponding to the first text element and message corresponding to the second if title is present else the first one. The image corresponds to the first image element of the notification xml. - -The count is present only for the badge notification in which it represent the value of the notification which could be a number from 0-99 or a status glyph. - -For advanced templates and usage, the notification object is included in [`data.additionalData.pushNotificationReceivedEventArgs`](https://msdn.microsoft.com/en-us/library/windows/apps/windows.networking.pushnotifications.pushnotificationreceivedeventargs). - -## Setting Toast Capable Option for Windows - -This plugin automatically sets the toast capable flag to be true for Cordova 5.1.1+. For lower versions, you must declare that it is Toast Capable in your app's manifest file. - -## Disabling the default processing of notifications by Windows - -The default handling can be disabled by setting the 'cancel' property in the notification object. - -```javascript -data.additionalData.pushNotificationReceivedEventArgs.cancel = true -``` - -## Background Notifications - -On Windows, to trigger the on('notification') event handler when your app is in the background and it is launched through the push notification, you will have to include `activation` data in the payload of the notification. This is done by using the `launch` attribute, which can be any string that can be understood by the app. However it should not cause the XML payload to become invalid. - -If you do not include a launch attribute string, your app will be launched normally, as though the user had launched it from the Start screen, and the notification event handler won't be called. - -Here is an example of a sample toast notification payload containing the launch attribute: - -```xml -<toast launch="{"myContext":"12345"}"> - <visual> - <binding template="ToastImageAndText01"> - <image id="1" src="ms-appx:///images/redWide.png" alt="red graphic"/> - <text id="1">Hello World!</text> - </binding> - </visual> -</toast> -``` - -This launch attribute string is passed on to the app as data.launchArgs through the on('notification') handler. It's important to note that due to the Windows platform design, the other visual payload is not available to the handler on cold start. So notification attributes like message, title etc. which are available through the on('notification') handler when the app is running, won't be available for background notifications. diff --git a/StoneIsland/plugins/phonegap-plugin-push/docs/PHONEGAP_BUILD.md b/StoneIsland/plugins/phonegap-plugin-push/docs/PHONEGAP_BUILD.md deleted file mode 100644 index 8a95d6a1..00000000 --- a/StoneIsland/plugins/phonegap-plugin-push/docs/PHONEGAP_BUILD.md +++ /dev/null @@ -1,93 +0,0 @@ -# Cloud Build Services - -- [PhoneGap Build Support](#phonegap-build-support) - - [Including the plugin](#including-the-plugin) - - [Adding Resources](#adding-resources) -- [IntelXDK Support](#intelxdk-support) - -## PhoneGap Build Support - -> Currently PhoneGap Build does not support version 1.9.0 of the plugin. Updates are being made to PGB to support the latest release. - -### Including the plugin - -Including this plugin in a project that is built by PhoneGap Build is as easy as adding: - -```xml -<preference name="android-build-tool" value="gradle" /> -<plugin name="phonegap-plugin-push" source="npm"> - <param name="SENDER_ID" value="<Your Sender ID>" /> -</plugin> -``` - -into your app's `config.xml` file. PhoneGap Build will pick up the latest version of phonegap-plugin-push published on npm. If you want to specify a particular version of the plugin you can add the `spec` attribute to the `plugin` tag. - -```xml -<preference name="android-build-tool" value="gradle" /> -<plugin name="phonegap-plugin-push" spec="~1.4.5" source="npm" /> -``` - -Note: version 1.3.0 of this plugin begins to use Gradle to install the Android Support Framework. Support for Gradle has recently been added to PhoneGap Build. Please read [this blog post](http://phonegap.com/blog/2015/09/28/android-using-gradle/) for more information. - -### Adding resources - -Because PhoneGap Build does not support running hooks if you want to include custom image or sounds you will need to use a *beta* feature to include these files. - -#### Android - -To add custom files, create a directory called `locales/android/` in the root of your PGB application zip / repo, and place your resource files there. The contents will be copied into the Android `res/` directory, and any nested sub-directory structures will persist. Here's an example of how these files will be compiled into your APK: - -``` -<www.zip>/locales/android/drawables/logo.png --> <android_apk>/res/drawables/logo.png -<www.zip>/locales/android/raw/beep.mp3 --> <android_apk>/res/raw/beep.mp3 -<www.zip>/locales/android/values-fr/strings.xml --> <android_apk>/res/values-fr/strings.xml -``` - -Existing directories will be merged, but at this time any individual files you include will overwrite their target if it exists. - -## IntelXDK Support - -1. Do pre-requisite setup on [the iOS Provisioning Portal](https://developer.apple.com/account/ios/identifier/bundle). Refer to [this guide](https://www.raywenderlich.com/123862/push-notifications-tutorial) or Apple docs for detailed steps. -a. make a new App ID (you'll need to set this in Intel XDK config later) -b. enable push notifications -c. iOS Distribution cert: create (if needed), download and install (if needed), export as a .p12 (set and remember the password as you'll need this to import into Intel XDK later) -**NOTE**: Intel XDK does not support Development certs, so you MUST use your Distribution cert. -d. Make an AdHoc Provisioning Profile using your App ID from (1a) and your cert from (1c). Make sure your test device is enabled. Download and save with a name you will recognize. (you'll need to add this to your Intel XDK project later) -e. make a push cert, download it, install it, export it to .p12, convert it to .pem (this is for the push server that will send the notification - you'll need this later to test your Intel XDK app) - -2. In Intel XDK, make a new Cordova CLI 5.4.1 project using the HTML5+Cordova Blank Template, then replace the contents of www with [the contents of www from the PhoneGap Push Template](https://github.com/phonegap/phonegap-template-push/tree/master/template_src/www). - -3. Delete www/config.xml (optional? Intel XDK does not use config.xml) - -4. Intel XDK Project Settings -a. set the iOS App ID to match the App ID from (1a) -b. (if needed) import your .p12 from (1c) - Account Settings->Developer Certificates->iOS, then select it as the Developer Certificate for the project -c. Select "adhoc" for Provisioning Profile -d. copy your provisioning profile from (1d) into www/, then click "Ad hoc Provisioning Profile" and select the profile -e. Add the latest version of phonegap-plugin-push as a "Third-Party Plugin" (at time of testing this was 1.6.4) -f. **After the plugin is added, you will need to edit plugins/phonegap-plugin-push/plugin.xml**. Intel XDK 3357 does not support plugins with gradle references, so the gradle reference must be commented out (this will prevent this version of the plugin from working for Android but is needed for the iOS build to succeed): -`<!--framework src="push.gradle" custom="true" type="gradleReference" /-->` -A future version of Intel XDK will support gradle references. - -5. XDK Build Tab -a. Enable iOS build (click the checkmark) -b. Unlock your iOS certificate (click the lock and enter the password from (1c)) -c. click Start Builds -d. once the build completes, download and install the app - -6. connect test device by USB and open XCode Devices window (probably could also use Safari Web Inspector + Cordova Console plugin) - start the app and a log message should be written into the console that looks like "Push Plugin register success: \<XXXXXXXX 19b101a3 71590c03 9ea7f446 50eb8409 19ac24bb c1ec1320 XXXXXXXX\>" - -7. exit the app (close with home button then swipe it off the multitask view) - -8. The angle brackets and everything between (from (5)) is the device token - copy it into a text file - -9. Add the device token to your server and send a push notification -a. I used [phonegap-plugin-push/example/server/pushAPNS.rb](https://github.com/phonegap/phonegap-plugin-push/blob/master/example/server/pushAPNS.rb) for this -b. APNS.host = 'gateway.push.apple.com' -c. APNS.pem = 'PGPush926Prod.pem' #path to your pem file from (1e) -d. device_token = '\<XXXXXXXX 19b101a3 71590c03 9ea7f446 50eb8409 19ac24bb c1ec1320 XXXXXXXX\>' #the device token from (7) -e. edit the alert message and badge number -f. you probably need to install the required gem (`gem install pushmeup`) -g. send the notification (`ruby pushAPNS.rb`) - -10. See notification on device! diff --git a/StoneIsland/plugins/phonegap-plugin-push/docs/PLATFORM_SUPPORT.md b/StoneIsland/plugins/phonegap-plugin-push/docs/PLATFORM_SUPPORT.md deleted file mode 100644 index 3a4e2969..00000000 --- a/StoneIsland/plugins/phonegap-plugin-push/docs/PLATFORM_SUPPORT.md +++ /dev/null @@ -1,17 +0,0 @@ -## Supported Platforms - -### Version 1.9.x - -- Cordova CLI (6.4.0 or newer) -- Android (`cordova-android` 6.0.0 or higher) -- Browser -- iOS (`cordova-ios` 4.3.0 or higher) -- Windows Universal (not Windows Phone 8) - -### Version 1.8.x - -- Cordova CLI (3.6.3 or newer) -- Android (`cordova-android` 4.0.0 or higher) -- Browser -- iOS (`cordova-ios` 4.1.0 or higher) -- Windows Universal (not Windows Phone 8) diff --git a/StoneIsland/plugins/phonegap-plugin-push/docs/TYPESCRIPT.md b/StoneIsland/plugins/phonegap-plugin-push/docs/TYPESCRIPT.md deleted file mode 100644 index 37117d16..00000000 --- a/StoneIsland/plugins/phonegap-plugin-push/docs/TYPESCRIPT.md +++ /dev/null @@ -1,72 +0,0 @@ -# Typescript definition file - -For those of you who use typescript, we're glad to say that we have the complete definition file available at [DefinitelyTyped](https://github.com/DefinitelyTyped/DefinitelyTyped). -Search for `phonegap-plugin-push` there, or simply grab it directly [here](https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/phonegap-plugin-push/phonegap-plugin-push.d.ts). - -## Example usage - -All objects will be understood as having a defined type, including init options and eventHandler parameters. -All available attributes and properties will have autocomplete support and type checkings. - -```typescript -let push = PushNotification.init({ - android: { - senderID: "12345679" - }, - ios: { - alert: "true", - badge: true, - sound: 'false' - }, - windows: {} -}); - -push.on('registration', (data) => { - console.log(data.registrationId); -}); - -push.on('notification', (data) => { - console.log(data.message); - console.log(data.title); - console.log(data.count); - console.log(data.sound); - console.log(data.image); - console.log(data.additionalData); -}); - -push.on('error', (e) => { - console.log(e.message); -}); -``` - -If you have custom attributes being sent from the server on the payload, you can define them on a custom interface extending the standard one: - -```typescript -module my.custom { - export interface NotificationEventResponse extends PhonegapPluginPush.NotificationEventResponse { - additionalData: NotificationEventAdditionalData; - } - - export interface NotificationEventAdditionalData extends PhonegapPluginPush.NotificationEventAdditionalData { - bacon?: boolean; - } -} - -push.on('notification', (data: my.custom.NotificationEventResponse) => { - //standard attributes - console.log(data.message); - console.log(data.title); - console.log(data.count); - console.log(data.sound); - console.log(data.image); - console.log(data.additionalData); - - //custom attributes - console.log(data.additionalData.bacon); -}); -``` - -## Outdated definitions - -Is our definition file at DefinitelyTyped outdated? Is there any improvements that could be done? -We welcome any contribution, and they should be done through issues created [there](https://github.com/DefinitelyTyped/DefinitelyTyped/issues/new).
\ No newline at end of file diff --git a/StoneIsland/plugins/phonegap-plugin-push/hooks/windows/setToastCapable.js b/StoneIsland/plugins/phonegap-plugin-push/hooks/windows/setToastCapable.js deleted file mode 100644 index b8cbcbc0..00000000 --- a/StoneIsland/plugins/phonegap-plugin-push/hooks/windows/setToastCapable.js +++ /dev/null @@ -1,12 +0,0 @@ -module.exports = function(context) { - console.log('Updating appxmanifests with ToastCapable=true...'); - var path = require('path'); - var platformProjPath = path.join(context.opts.projectRoot, 'platforms/windows'); - var AppxManifest = require(path.join(platformProjPath, 'cordova/lib/AppxManifest')); - - ['package.phone.appxmanifest', 'package.windows.appxmanifest'].forEach(function(manifestPath) { - var manifest = AppxManifest.get(path.join(platformProjPath, manifestPath)); - manifest.getVisualElements().setToastCapable(true); - manifest.write(); - }); -} diff --git a/StoneIsland/plugins/phonegap-plugin-push/package.json b/StoneIsland/plugins/phonegap-plugin-push/package.json deleted file mode 100644 index 01287217..00000000 --- a/StoneIsland/plugins/phonegap-plugin-push/package.json +++ /dev/null @@ -1,86 +0,0 @@ -{ - "_from": "phonegap-plugin-push@1.9.2", - "_id": "phonegap-plugin-push@1.9.2", - "_inBundle": false, - "_integrity": "sha1-3PktbNuZLcs3iUCyIbfwjoKcn8E=", - "_location": "/phonegap-plugin-push", - "_phantomChildren": {}, - "_requested": { - "type": "version", - "registry": true, - "raw": "phonegap-plugin-push@1.9.2", - "name": "phonegap-plugin-push", - "escapedName": "phonegap-plugin-push", - "rawSpec": "1.9.2", - "saveSpec": null, - "fetchSpec": "1.9.2" - }, - "_requiredBy": [ - "#USER", - "/" - ], - "_resolved": "https://registry.npmjs.org/phonegap-plugin-push/-/phonegap-plugin-push-1.9.2.tgz", - "_shasum": "dcf92d6cdb992dcb378940b221b7f08e829c9fc1", - "_spec": "phonegap-plugin-push@1.9.2", - "_where": "/Users/user/Sites/stone-island/StoneIsland", - "author": { - "name": "Adobe PhoneGap Team" - }, - "bugs": { - "url": "https://github.com/phonegap/phonegap-plugin-push/issues" - }, - "bundleDependencies": false, - "cordova": { - "id": "phonegap-plugin-push", - "platforms": [ - "ios", - "android", - "windows", - "browser" - ] - }, - "deprecated": false, - "description": "Register and receive push notifications.", - "devDependencies": { - "jasmine-node": "1.14.5", - "pluginpub": "^0.0.5" - }, - "engines": { - "cordovaDependencies": { - "1.8.2": { - "cordova": ">=3.6.3", - "cordova-android": ">=4.0.0", - "cordova-ios": ">=4.1.0" - }, - "1.9.0": { - "cordova": ">=6.4.0", - "cordova-android": ">=6.0.0", - "cordova-ios": ">=4.3.0" - }, - "2.0.0": { - "cordova": ">100" - } - } - }, - "homepage": "http://github.com/phonegap/phonegap-plugin-push#readme", - "keywords": [ - "ecosystem:cordova", - "ecosystem:phonegap", - "cordova-ios", - "cordova-android", - "cordova-windows8", - "cordova-windows", - "cordova-wp8", - "cordova-browser" - ], - "license": "APL", - "name": "phonegap-plugin-push", - "repository": { - "type": "git", - "url": "git://github.com/phonegap/phonegap-plugin-push.git" - }, - "scripts": { - "test": "jasmine-node --color spec" - }, - "version": "1.9.2" -} diff --git a/StoneIsland/plugins/phonegap-plugin-push/plugin.xml b/StoneIsland/plugins/phonegap-plugin-push/plugin.xml deleted file mode 100755 index bf9c659a..00000000 --- a/StoneIsland/plugins/phonegap-plugin-push/plugin.xml +++ /dev/null @@ -1,123 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" standalone="yes"?> -<plugin xmlns="http://www.phonegap.com/ns/plugins/1.0" xmlns:android="http://schemas.android.com/apk/res/android" xmlns:amazon="http://schemas.android.com/apk/lib/com.amazon.device.ads" xmlns:rim="http://www.blackberry.com/ns/widgets" id="phonegap-plugin-push" version="1.9.2"> - <name>PushPlugin</name> - <description> - This plugin allows your application to receive push notifications on Android, iOS and Windows devices. - Android uses Google Cloud Messaging. - iOS uses Apple APNS Notifications. - Windows uses Microsoft WNS Notifications. - </description> - <license>MIT</license> - <js-module src="www/push.js" name="PushNotification"> - <clobbers target="PushNotification"/> - </js-module> - <engines> - <engine name="cordova" version=">=6.4.0"/> - <engine name="cordova-android" version=">=6.0.0"/> - <engine name="cordova-ios" version=">=4.3.0"/> - </engines> - <preference name="SENDER_ID" default="85075801930"/> - <platform name="android"> - <config-file target="res/xml/config.xml" parent="/*"> - <feature name="PushNotification"> - <param name="android-package" value="com.adobe.phonegap.push.PushPlugin"/> - </feature> - </config-file> - <config-file target="res/values/strings.xml" parent="/resources"> - <string name="google_app_id">$SENDER_ID</string> - </config-file> - <config-file target="AndroidManifest.xml" parent="/manifest"> - <uses-permission android:name="android.permission.INTERNET"/> - <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/> - <uses-permission android:name="android.permission.WAKE_LOCK"/> - <uses-permission android:name="android.permission.VIBRATE"/> - <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE"/> - <uses-permission android:name="${applicationId}.permission.C2D_MESSAGE"/> - <uses-permission android:name="${applicationId}.permission.PushHandlerActivity"/> - <permission android:name="${applicationId}.permission.C2D_MESSAGE" android:protectionLevel="signature"/> - <permission android:name="${applicationId}.permission.PushHandlerActivity" android:protectionLevel="signature"/> - </config-file> - <config-file target="AndroidManifest.xml" parent="/manifest/application"> - <activity android:name="com.adobe.phonegap.push.PushHandlerActivity" android:exported="true" android:permission="${applicationId}.permission.PushHandlerActivity"/> - <receiver android:name="com.adobe.phonegap.push.BackgroundActionButtonHandler"/> - <receiver android:name="com.google.android.gms.gcm.GcmReceiver" android:exported="true" android:permission="com.google.android.c2dm.permission.SEND"> - <intent-filter> - <action android:name="com.google.android.c2dm.intent.RECEIVE"/> - <category android:name="${applicationId}"/> - </intent-filter> - </receiver> - <service android:name="com.adobe.phonegap.push.GCMIntentService" android:exported="false"> - <intent-filter> - <action android:name="com.google.android.c2dm.intent.RECEIVE"/> - </intent-filter> - </service> - <service android:name="com.adobe.phonegap.push.PushInstanceIDListenerService" android:exported="false"> - <intent-filter> - <action android:name="com.google.android.gms.iid.InstanceID"/> - </intent-filter> - </service> - <service android:name="com.adobe.phonegap.push.RegistrationIntentService" android:exported="false"/> - </config-file> - <framework src="push.gradle" custom="true" type="gradleReference"/> - <framework src="com.android.support:support-v13:23+"/> - <framework src="com.google.android.gms:play-services-gcm:9.8+"/> - <framework src="me.leolin:ShortcutBadger:1.1.11@aar"/> - <source-file src="src/android/com/adobe/phonegap/push/GCMIntentService.java" target-dir="src/com/adobe/phonegap/push/"/> - <source-file src="src/android/com/adobe/phonegap/push/PushConstants.java" target-dir="src/com/adobe/phonegap/push/"/> - <source-file src="src/android/com/adobe/phonegap/push/PushHandlerActivity.java" target-dir="src/com/adobe/phonegap/push/"/> - <source-file src="src/android/com/adobe/phonegap/push/PushInstanceIDListenerService.java" target-dir="src/com/adobe/phonegap/push/"/> - <source-file src="src/android/com/adobe/phonegap/push/PushPlugin.java" target-dir="src/com/adobe/phonegap/push/"/> - <source-file src="src/android/com/adobe/phonegap/push/RegistrationIntentService.java" target-dir="src/com/adobe/phonegap/push/"/> - <source-file src="src/android/com/adobe/phonegap/push/PermissionUtils.java" target-dir="src/com/adobe/phonegap/push/"/> - <source-file src="src/android/com/adobe/phonegap/push/BackgroundActionButtonHandler.java" target-dir="src/com/adobe/phonegap/push/"/> - </platform> - <platform name="browser"> - <js-module src="www/browser/push.js" name="BrowserPush"> - <clobbers target="PushNotification"/> - </js-module> - <asset src="src/browser/ServiceWorker.js" target="ServiceWorker.js"/> - <asset src="src/browser/manifest.json" target="manifest.json"/> - </platform> - <platform name="ios"> - <config-file target="config.xml" parent="/*"> - <feature name="PushNotification"> - <param name="ios-package" value="PushPlugin"/> - </feature> - </config-file> - <config-file target="*-Info.plist" parent="UIBackgroundModes"> - <array> - <string>remote-notification</string> - </array> - </config-file> - <config-file target="*-Info.plist" parent="GCM_SENDER_ID"> - <string>$SENDER_ID</string> - </config-file> - <config-file target="*-Info.plist" parent="IS_GCM_ENABLED"> - <true/> - </config-file> - <config-file target="*-Debug.plist" parent="aps-environment"> - <string>development</string> - </config-file> - <config-file target="*-Release.plist" parent="aps-environment"> - <string>production</string> - </config-file> - <source-file src="src/ios/AppDelegate+notification.m"/> - <source-file src="src/ios/PushPlugin.m"/> - <header-file src="src/ios/AppDelegate+notification.h"/> - <header-file src="src/ios/PushPlugin.h"/> - <framework src="AddressBook.framework"/> - <framework src="libsqlite3.tbd"/> - <framework src="libz.tbd"/> - <framework src="GoogleCloudMessaging" type="podspec" spec="~> 1.2.0"/> - <framework src="GGLInstanceID" type="podspec" spec="~> 1.2.1"/> - </platform> - <platform name="windows"> - <hook type="after_plugin_install" src="hooks/windows/setToastCapable.js"/> - <js-module src="src/windows/PushPluginProxy.js" name="PushPlugin"> - <merges target=""/> - </js-module> - <config-file target="config.xml" parent="/*"> - <preference name="WindowsToastCapable" value="true"/> - </config-file> - </platform> -</plugin>
\ No newline at end of file diff --git a/StoneIsland/plugins/phonegap-plugin-push/push.gradle b/StoneIsland/plugins/phonegap-plugin-push/push.gradle deleted file mode 100644 index 11e735ae..00000000 --- a/StoneIsland/plugins/phonegap-plugin-push/push.gradle +++ /dev/null @@ -1,21 +0,0 @@ -import java.util.regex.Pattern - -def doExtractStringFromManifest(name) { - def manifestFile = file(android.sourceSets.main.manifest.srcFile) - def pattern = Pattern.compile(name + "=\"(.*?)\"") - def matcher = pattern.matcher(manifestFile.getText()) - matcher.find() - return matcher.group(1) -} - -android { - sourceSets { - main { - manifest.srcFile 'AndroidManifest.xml' - } - } - - defaultConfig { - applicationId = doExtractStringFromManifest("package") - } -} diff --git a/StoneIsland/plugins/phonegap-plugin-push/spec/helper/cordova.js b/StoneIsland/plugins/phonegap-plugin-push/spec/helper/cordova.js deleted file mode 100644 index 02bdee5f..00000000 --- a/StoneIsland/plugins/phonegap-plugin-push/spec/helper/cordova.js +++ /dev/null @@ -1,83 +0,0 @@ -/* global cordova:true */ - -/*! - * Module dependencies. - */ - -/** - * cordova.js for node. - * - * Think of this as cordova-node, which would be simliar to cordova-android - * or cordova-browser. The purpose of this module is to enable testing - * of a plugin's JavaScript interface. - * - * When this module is first required, it will insert a global cordova - * instance, which can hijack cordova-specific commands within the pluin's - * implementation. - * - * Remember to require this module before the plugin that you want to test. - * - * Example: - * - * var cordova = require('./helper/cordova'), - * myPlugin = require('../www/myPlugin'); - */ - -module.exports = global.cordova = cordova = { - - /** - * cordova.require Mock. - * - * Hijacks all cordova.requires. By default, it returns an empty function. - * You can define your own implementation of each required module before - * or after it has been required. - * - * See `cordova.required` to learn how to add your own module implemtnation. - */ - - require: function(moduleId) { - // define a default function if it doesn't exist - if (!cordova.required[moduleId]) { - cordova.required[moduleId] = function() {}; - } - // create a new module mapping between the module Id and cordova.required. - return new ModuleMap(moduleId); - }, - - /** - * Cordova module implementations. - * - * A key-value hash, where the key is the module such as 'cordova/exec' - * and the value is the function or object returned. - * - * For example: - * - * var exec = require('cordova/exec'); - * - * Will map to: - * - * cordova.required['cordova/exec']; - */ - - required: { - // populated at runtime - } -}; - -/** - * Module Mapper. - * - * Returns a function that when executed will lookup the implementation - * in cordova.required[id]. - * - * @param {String} moduleId is the module name/path, such as 'cordova/exec' - * @return {Function}. - */ - -function ModuleMap(moduleId) { - return function() { - // lookup and execute the module's mock implementation, passing - // in any parameters that were provided. - return cordova.required[moduleId].apply(this, arguments); - }; -} diff --git a/StoneIsland/plugins/phonegap-plugin-push/spec/index.spec.js b/StoneIsland/plugins/phonegap-plugin-push/spec/index.spec.js deleted file mode 100644 index 8e1c2665..00000000 --- a/StoneIsland/plugins/phonegap-plugin-push/spec/index.spec.js +++ /dev/null @@ -1,405 +0,0 @@ -/* globals require */ - -/*! - * Module dependencies. - */ - -var cordova = require('./helper/cordova'), - PushNotification = require('../www/push'), - execSpy, - execWin, - options; - -/*! - * Specification. - */ - -describe('phonegap-plugin-push', function () { - beforeEach(function () { - options = {android: {}, ios: {}, windows: {}}; - execWin = jasmine.createSpy(); - execSpy = spyOn(cordova.required, 'cordova/exec').andCallFake(execWin); - }); - - describe('PushNotification', function () { - it('should exist', function () { - expect(PushNotification).toBeDefined(); - expect(typeof PushNotification === 'object').toBe(true); - }); - - it('should contain a init function', function () { - expect(PushNotification.init).toBeDefined(); - expect(typeof PushNotification.init === 'function').toBe(true); - }); - - it('should contain a unregister function', function () { - var push = PushNotification.init({}); - expect(push.unregister).toBeDefined(); - expect(typeof push.unregister === 'function').toBe(true); - }); - - it('should contain a getApplicationIconBadgeNumber function', function () { - var push = PushNotification.init({}); - expect(push.getApplicationIconBadgeNumber).toBeDefined(); - expect(typeof push.getApplicationIconBadgeNumber === 'function').toBe(true); - }); - - it('should contain a setApplicationIconBadgeNumber function', function () { - var push = PushNotification.init({}); - expect(push.setApplicationIconBadgeNumber).toBeDefined(); - expect(typeof push.setApplicationIconBadgeNumber === 'function').toBe(true); - }); - - it('should contain a clearAllNotifications function', function () { - var push = PushNotification.init({}); - expect(push.clearAllNotifications).toBeDefined(); - expect(typeof push.clearAllNotifications === 'function').toBe(true); - }); - - it('should contain a subscribe function', function () { - var push = PushNotification.init({}); - expect(push.subscribe).toBeDefined(); - expect(typeof push.subscribe === 'function').toBe(true); - }); - - it('should contain a unsubscribe function', function () { - var push = PushNotification.init({}); - expect(push.unsubscribe).toBeDefined(); - expect(typeof push.unsubscribe === 'function').toBe(true); - }); - }); - - describe('PushNotification instance', function () { - describe('cordova.exec', function () { - it('should call cordova.exec on next process tick', function (done) { - PushNotification.init(options); - setTimeout(function () { - expect(execSpy).toHaveBeenCalledWith( - jasmine.any(Function), - jasmine.any(Function), - 'PushNotification', - 'init', - jasmine.any(Object) - ); - done(); - }, 100); - }); - }); - - describe('on "registration" event', function () { - it('should be emitted with an argument', function (done) { - execSpy.andCallFake(function (win, fail, service, id, args) { - win({'registrationId': 1}); - }); - var push = PushNotification.init(options); - push.on('registration', function (data) { - expect(data.registrationId).toEqual(1); - done(); - }); - }); - }); - - describe('on "notification" event', function () { - beforeEach(function () { - execSpy.andCallFake(function (win, fail, service, id, args) { - win({ - message: 'Message', - title: 'Title', - count: 1, - sound: 'beep', - image: 'Image', - additionalData: {} - }); - }); - }); - - it('should be emitted on success', function (done) { - var push = PushNotification.init(options); - push.on('notification', function (data) { - done(); - }); - }); - - it('should provide the data.message argument', function (done) { - var push = PushNotification.init(options); - push.on('notification', function (data) { - expect(data.message).toEqual('Message'); - done(); - }); - }); - - it('should provide the data.title argument', function (done) { - var push = PushNotification.init(options); - push.on('notification', function (data) { - expect(data.title).toEqual('Title'); - done(); - }); - }); - - it('should provide the data.count argument', function (done) { - var push = PushNotification.init(options); - push.on('notification', function (data) { - expect(data.count).toEqual(1); - done(); - }); - }); - - it('should provide the data.sound argument', function (done) { - var push = PushNotification.init(options); - push.on('notification', function (data) { - expect(data.sound).toEqual('beep'); - done(); - }); - }); - - it('should provide the data.image argument', function (done) { - var push = PushNotification.init(options); - push.on('notification', function (data) { - expect(data.image).toEqual('Image'); - done(); - }); - }); - - it('should provide the data.additionalData argument', function (done) { - var push = PushNotification.init(options); - push.on('notification', function (data) { - expect(data.additionalData).toEqual({}); - done(); - }); - }); - }); - - describe('on "error" event', function () { - it('should be emitted with an Error', function (done) { - execSpy.andCallFake(function (win, fail, service, id, args) { - fail('something went wrong'); - }); - var push = PushNotification.init(options); - push.on('error', function (e) { - expect(e).toEqual(jasmine.any(Error)); - expect(e.message).toEqual('something went wrong'); - done(); - }); - }); - }); - - describe('off "notification" event', function () { - it('should exist and be registered a callback handle', function (done) { - var push = PushNotification.init(options), - eventHandler = function () { - }; - - push.on('notification', eventHandler); - - push.off('notification', eventHandler); - - expect(push._handlers.notification.indexOf(eventHandler)).toEqual(-1); - done(); - }); - }); - - describe('off "registration" event', function () { - it('should exist and be registered a callback handle', function (done) { - var push = PushNotification.init(options), - eventHandler = function () { - }; - - push.on('registration', eventHandler); - - push.off('registration', eventHandler); - - expect(push._handlers.registration.indexOf(eventHandler)).toEqual(-1); - done(); - }); - }); - - describe('off "error" event', function () { - it('should exist and be registered a callback handle', function (done) { - var push = PushNotification.init(options), - eventHandler = function () { - }; - - push.on('error', eventHandler); - push.off('error', eventHandler); - - expect(push._handlers.error.indexOf(eventHandler)).toEqual(-1); - done(); - }); - }); - - describe('unregister method', function () { - it('should clear "registration" event handlers', function (done) { - var push = PushNotification.init(options), - eventHandler = function () { - }; - - expect(push._handlers.registration.length).toEqual(0); - - push.on('registration',eventHandler); - - expect(push._handlers.registration.length).toEqual(1); - expect(push._handlers.registration.indexOf(eventHandler)).toBeGreaterThan(-1); - - execSpy.andCallFake(function (win, fail, service, id, args) { - win(); - }); - push.unregister(function() { - expect(push._handlers.registration.length).toEqual(0); - expect(push._handlers.registration.indexOf(eventHandler)).toEqual(-1); - done(); - }); - }); - - it('should clear "notification" event handlers', function (done) { - var push = PushNotification.init(options), - eventHandler = function () { - }; - - expect(push._handlers.notification.length).toEqual(0); - - push.on('notification', eventHandler); - - expect(push._handlers.notification.length).toEqual(1); - expect(push._handlers.notification.indexOf(eventHandler)).toBeGreaterThan(-1); - - execSpy.andCallFake(function (win, fail, service, id, args) { - win(); - }); - push.unregister(function() { - expect(push._handlers.notification.length).toEqual(0); - expect(push._handlers.notification.indexOf(eventHandler)).toEqual(-1); - done(); - }); - }); - - it('should clear "error" event handlers', function (done) { - var push = PushNotification.init(options), - eventHandler = function () { - }; - - expect(push._handlers.error.length).toEqual(0); - - push.on('error', eventHandler); - - expect(push._handlers.error.length).toEqual(1); - expect(push._handlers.error.indexOf(eventHandler)).toBeGreaterThan(-1); - - execSpy.andCallFake(function (win, fail, service, id, args) { - win(); - }); - push.unregister(function() { - expect(push._handlers.error.length).toEqual(0); - expect(push._handlers.error.indexOf(eventHandler)).toEqual(-1); - done(); - }); - }); - }); - - describe('unregister topics method', function () { - it('should not clear "registration" event handlers', function (done) { - var push = PushNotification.init(options), - eventHandler = function () { - }; - - expect(push._handlers.registration.length).toEqual(0); - - push.on('registration',eventHandler); - - expect(push._handlers.registration.length).toEqual(1); - expect(push._handlers.registration.indexOf(eventHandler)).toBeGreaterThan(-1); - - execSpy.andCallFake(function (win, fail, service, id, args) { - win(); - }); - push.unregister(function() { - expect(push._handlers.registration.length).toEqual(1); - expect(push._handlers.registration.indexOf(eventHandler)).toBeGreaterThan(-1); - done(); - }, null, ['foo', 'bar']); - }); - - it('should not clear "notification" event handlers', function (done) { - var push = PushNotification.init(options), - eventHandler = function () { - }; - - expect(push._handlers.notification.length).toEqual(0); - - push.on('notification', eventHandler); - - expect(push._handlers.notification.length).toEqual(1); - expect(push._handlers.notification.indexOf(eventHandler)).toBeGreaterThan(-1); - - execSpy.andCallFake(function (win, fail, service, id, args) { - win(); - }); - push.unregister(function() { - expect(push._handlers.notification.length).toEqual(1); - expect(push._handlers.notification.indexOf(eventHandler)).toBeGreaterThan(-1); - done(); - }, null, ['foo', 'bar']); - }); - - it('should not clear "error" event handlers', function (done) { - var push = PushNotification.init(options), - eventHandler = function () { - }; - - expect(push._handlers.error.length).toEqual(0); - - push.on('error', eventHandler); - - expect(push._handlers.error.length).toEqual(1); - expect(push._handlers.error.indexOf(eventHandler)).toBeGreaterThan(-1); - - execSpy.andCallFake(function (win, fail, service, id, args) { - win(); - }); - push.unregister(function() { - expect(push._handlers.error.length).toEqual(1); - expect(push._handlers.error.indexOf(eventHandler)).toBeGreaterThan(-1); - done(); - }, null, ['foo', 'bar']); - }); - }); - - describe('subscribe topic method', function () { - describe('cordova.exec', function () { - it('should call cordova.exec on next process tick', function (done) { - var push = PushNotification.init(options); - push.subscribe('foo', function() {}, function() {}); - setTimeout(function () { - expect(execSpy).toHaveBeenCalledWith( - jasmine.any(Function), - jasmine.any(Function), - 'PushNotification', - 'subscribe', - jasmine.any(Object) - ); - done(); - }, 100); - }); - }); - }); - - - describe('unsubscribe topic method', function () { - describe('cordova.exec', function () { - it('should call cordova.exec on next process tick', function (done) { - var push = PushNotification.init(options); - push.unsubscribe('foo', function() {}, function() {}); - setTimeout(function () { - expect(execSpy).toHaveBeenCalledWith( - jasmine.any(Function), - jasmine.any(Function), - 'PushNotification', - 'unsubscribe', - jasmine.any(Object) - ); - done(); - }, 100); - }); - }); - }); - }); -}); diff --git a/StoneIsland/plugins/phonegap-plugin-push/src/android/com/adobe/phonegap/push/BackgroundActionButtonHandler.java b/StoneIsland/plugins/phonegap-plugin-push/src/android/com/adobe/phonegap/push/BackgroundActionButtonHandler.java deleted file mode 100644 index 3ccea6cb..00000000 --- a/StoneIsland/plugins/phonegap-plugin-push/src/android/com/adobe/phonegap/push/BackgroundActionButtonHandler.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.adobe.phonegap.push; - -import android.app.NotificationManager; -import android.content.BroadcastReceiver; -import android.content.Context; -import android.content.Intent; -import android.os.Bundle; -import android.util.Log; -import android.support.v4.app.RemoteInput; - -public class BackgroundActionButtonHandler extends BroadcastReceiver implements PushConstants { - private static String LOG_TAG = "PushPlugin_BackgroundActionButtonHandler"; - - @Override - public void onReceive(Context context, Intent intent) { - Bundle extras = intent.getExtras(); - Log.d(LOG_TAG, "BackgroundActionButtonHandler = " + extras); - - int notId = intent.getIntExtra(NOT_ID, 0); - Log.d(LOG_TAG, "not id = " + notId); - NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); - notificationManager.cancel(GCMIntentService.getAppName(context), notId); - - if (extras != null) { - Bundle originalExtras = extras.getBundle(PUSH_BUNDLE); - - originalExtras.putBoolean(FOREGROUND, false); - originalExtras.putBoolean(COLDSTART, false); - originalExtras.putString(ACTION_CALLBACK, extras.getString(CALLBACK)); - - Bundle remoteInput = RemoteInput.getResultsFromIntent(intent); - if (remoteInput != null) { - String inputString = remoteInput.getCharSequence(INLINE_REPLY).toString(); - Log.d(LOG_TAG, "response: " + inputString); - originalExtras.putString(INLINE_REPLY, inputString); - } - - PushPlugin.sendExtras(originalExtras); - } - } -} diff --git a/StoneIsland/plugins/phonegap-plugin-push/src/android/com/adobe/phonegap/push/GCMIntentService.java b/StoneIsland/plugins/phonegap-plugin-push/src/android/com/adobe/phonegap/push/GCMIntentService.java deleted file mode 100644 index e1a2b75c..00000000 --- a/StoneIsland/plugins/phonegap-plugin-push/src/android/com/adobe/phonegap/push/GCMIntentService.java +++ /dev/null @@ -1,802 +0,0 @@ -package com.adobe.phonegap.push; - -import android.annotation.SuppressLint; -import android.app.Notification; -import android.app.NotificationManager; -import android.app.PendingIntent; -import android.content.ContentResolver; -import android.content.Context; -import android.content.Intent; -import android.content.SharedPreferences; -import android.content.res.AssetManager; -import android.content.res.Resources; -import android.graphics.Bitmap; -import android.graphics.BitmapFactory; -import android.graphics.Color; -import android.net.Uri; -import android.os.Bundle; -import android.support.v4.app.NotificationCompat; -import android.support.v4.app.NotificationManagerCompat; -import android.support.v4.app.NotificationCompat.WearableExtender; -import android.support.v4.app.RemoteInput; -import android.text.Html; -import android.text.Spanned; -import android.util.Log; - -import com.google.android.gms.gcm.GcmListenerService; - -import org.json.JSONArray; -import org.json.JSONException; -import org.json.JSONObject; - -import java.io.IOException; -import java.io.InputStream; -import java.net.HttpURLConnection; -import java.net.URL; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.Random; - -@SuppressLint("NewApi") -public class GCMIntentService extends GcmListenerService implements PushConstants { - - private static final String LOG_TAG = "PushPlugin_GCMIntentService"; - private static HashMap<Integer, ArrayList<String>> messageMap = new HashMap<Integer, ArrayList<String>>(); - - public void setNotification(int notId, String message){ - ArrayList<String> messageList = messageMap.get(notId); - if(messageList == null) { - messageList = new ArrayList<String>(); - messageMap.put(notId, messageList); - } - - if(message.isEmpty()){ - messageList.clear(); - }else{ - messageList.add(message); - } - } - - @Override - public void onMessageReceived(String from, Bundle extras) { - Log.d(LOG_TAG, "onMessage - from: " + from); - - if (extras != null) { - Context applicationContext = getApplicationContext(); - - SharedPreferences prefs = applicationContext.getSharedPreferences(PushPlugin.COM_ADOBE_PHONEGAP_PUSH, Context.MODE_PRIVATE); - boolean forceShow = prefs.getBoolean(FORCE_SHOW, false); - boolean clearBadge = prefs.getBoolean(CLEAR_BADGE, false); - - extras = normalizeExtras(applicationContext, extras); - - if (clearBadge) { - PushPlugin.setApplicationIconBadgeNumber(getApplicationContext(), 0); - } - - // if we are in the foreground and forceShow is `false` only send data - if (!forceShow && PushPlugin.isInForeground()) { - Log.d(LOG_TAG, "foreground"); - extras.putBoolean(FOREGROUND, true); - extras.putBoolean(COLDSTART, false); - PushPlugin.sendExtras(extras); - } - // if we are in the foreground and forceShow is `true`, force show the notification if the data has at least a message or title - else if (forceShow && PushPlugin.isInForeground()) { - Log.d(LOG_TAG, "foreground force"); - extras.putBoolean(FOREGROUND, true); - extras.putBoolean(COLDSTART, false); - - showNotificationIfPossible(applicationContext, extras); - } - // if we are not in the foreground always send notification if the data has at least a message or title - else { - Log.d(LOG_TAG, "background"); - extras.putBoolean(FOREGROUND, false); - extras.putBoolean(COLDSTART, PushPlugin.isActive()); - - showNotificationIfPossible(applicationContext, extras); - } - } - } - - /* - * Change a values key in the extras bundle - */ - private void replaceKey(Context context, String oldKey, String newKey, Bundle extras, Bundle newExtras) { - Object value = extras.get(oldKey); - if ( value != null ) { - if (value instanceof String) { - value = localizeKey(context, newKey, (String) value); - - newExtras.putString(newKey, (String) value); - } else if (value instanceof Boolean) { - newExtras.putBoolean(newKey, (Boolean) value); - } else if (value instanceof Number) { - newExtras.putDouble(newKey, ((Number) value).doubleValue()); - } else { - newExtras.putString(newKey, String.valueOf(value)); - } - } - } - - /* - * Normalize localization for key - */ - private String localizeKey(Context context, String key, String value) { - if (key.equals(TITLE) || key.equals(MESSAGE) || key.equals(SUMMARY_TEXT)) { - try { - JSONObject localeObject = new JSONObject(value); - - String localeKey = localeObject.getString(LOC_KEY); - - ArrayList<String> localeFormatData = new ArrayList<String>(); - if (!localeObject.isNull(LOC_DATA)) { - String localeData = localeObject.getString(LOC_DATA); - JSONArray localeDataArray = new JSONArray(localeData); - for (int i = 0 ; i < localeDataArray.length(); i++) { - localeFormatData.add(localeDataArray.getString(i)); - } - } - - String packageName = context.getPackageName(); - Resources resources = context.getResources(); - - int resourceId = resources.getIdentifier(localeKey, "string", packageName); - - if (resourceId != 0) { - return resources.getString(resourceId, localeFormatData.toArray()); - } - else { - Log.d(LOG_TAG, "can't find resource for locale key = " + localeKey); - - return value; - } - } - catch(JSONException e) { - Log.d(LOG_TAG, "no locale found for key = " + key + ", error " + e.getMessage()); - - return value; - } - } - - return value; - } - - /* - * Replace alternate keys with our canonical value - */ - private String normalizeKey(String key) { - if (key.equals(BODY) || key.equals(ALERT) || key.equals(GCM_NOTIFICATION_BODY) || key.equals(TWILIO_BODY)) { - return MESSAGE; - } else if (key.equals(TWILIO_TITLE)) { - return TITLE; - }else if (key.equals(MSGCNT) || key.equals(BADGE)) { - return COUNT; - } else if (key.equals(SOUNDNAME) || key.equals(TWILIO_SOUND)) { - return SOUND; - } else if (key.startsWith(GCM_NOTIFICATION)) { - return key.substring(GCM_NOTIFICATION.length()+1, key.length()); - } else if (key.startsWith(GCM_N)) { - return key.substring(GCM_N.length()+1, key.length()); - } else if (key.startsWith(UA_PREFIX)) { - key = key.substring(UA_PREFIX.length()+1, key.length()); - return key.toLowerCase(); - } else { - return key; - } - } - - /* - * Parse bundle into normalized keys. - */ - private Bundle normalizeExtras(Context context, Bundle extras) { - Log.d(LOG_TAG, "normalize extras"); - Iterator<String> it = extras.keySet().iterator(); - Bundle newExtras = new Bundle(); - - while (it.hasNext()) { - String key = it.next(); - - Log.d(LOG_TAG, "key = " + key); - - // If normalizeKeythe key is "data" or "message" and the value is a json object extract - // This is to support parse.com and other services. Issue #147 and pull #218 - if (key.equals(PARSE_COM_DATA) || key.equals(MESSAGE)) { - Object json = extras.get(key); - // Make sure data is json object stringified - if ( json instanceof String && ((String) json).startsWith("{") ) { - Log.d(LOG_TAG, "extracting nested message data from key = " + key); - try { - // If object contains message keys promote each value to the root of the bundle - JSONObject data = new JSONObject((String) json); - if ( data.has(ALERT) || data.has(MESSAGE) || data.has(BODY) || data.has(TITLE) ) { - Iterator<String> jsonIter = data.keys(); - while (jsonIter.hasNext()) { - String jsonKey = jsonIter.next(); - - Log.d(LOG_TAG, "key = data/" + jsonKey); - - String value = data.getString(jsonKey); - jsonKey = normalizeKey(jsonKey); - value = localizeKey(context, jsonKey, value); - - newExtras.putString(jsonKey, value); - } - } - } catch( JSONException e) { - Log.e(LOG_TAG, "normalizeExtras: JSON exception"); - } - } - } else if (key.equals(("notification"))) { - Bundle value = extras.getBundle(key); - Iterator<String> iterator = value.keySet().iterator(); - while (iterator.hasNext()) { - String notifkey = iterator.next(); - - Log.d(LOG_TAG, "notifkey = " + notifkey); - String newKey = normalizeKey(notifkey); - Log.d(LOG_TAG, "replace key " + notifkey + " with " + newKey); - - String valueData = value.getString(notifkey); - valueData = localizeKey(context, newKey, valueData); - - newExtras.putString(newKey, valueData); - } - continue; - } - - String newKey = normalizeKey(key); - Log.d(LOG_TAG, "replace key " + key + " with " + newKey); - replaceKey(context, key, newKey, extras, newExtras); - - } // while - - return newExtras; - } - - private int extractBadgeCount(Bundle extras) { - int count = -1; - String msgcnt = extras.getString(COUNT); - - try { - if (msgcnt != null) { - count = Integer.parseInt(msgcnt); - } - } catch (NumberFormatException e) { - Log.e(LOG_TAG, e.getLocalizedMessage(), e); - } - - return count; - } - - private void showNotificationIfPossible (Context context, Bundle extras) { - - // Send a notification if there is a message or title, otherwise just send data - String message = extras.getString(MESSAGE); - String title = extras.getString(TITLE); - String contentAvailable = extras.getString(CONTENT_AVAILABLE); - String forceStart = extras.getString(FORCE_START); - int badgeCount = extractBadgeCount(extras); - if (badgeCount >= 0) { - Log.d(LOG_TAG, "count =[" + badgeCount + "]"); - PushPlugin.setApplicationIconBadgeNumber(context, badgeCount); - } - - Log.d(LOG_TAG, "message =[" + message + "]"); - Log.d(LOG_TAG, "title =[" + title + "]"); - Log.d(LOG_TAG, "contentAvailable =[" + contentAvailable + "]"); - Log.d(LOG_TAG, "forceStart =[" + forceStart + "]"); - - if ((message != null && message.length() != 0) || - (title != null && title.length() != 0)) { - - Log.d(LOG_TAG, "create notification"); - - if(title == null || title.isEmpty()){ - extras.putString(TITLE, getAppName(this)); - } - - createNotification(context, extras); - } - - if(!PushPlugin.isActive() && "1".equals(forceStart)){ - Log.d(LOG_TAG, "app is not running but we should start it and put in background"); - Intent intent = new Intent(this, PushHandlerActivity.class); - intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - intent.putExtra(PUSH_BUNDLE, extras); - intent.putExtra(START_IN_BACKGROUND, true); - intent.putExtra(FOREGROUND, false); - startActivity(intent); - } else if ("1".equals(contentAvailable)) { - Log.d(LOG_TAG, "app is not running and content available true"); - Log.d(LOG_TAG, "send notification event"); - PushPlugin.sendExtras(extras); - } - } - - public void createNotification(Context context, Bundle extras) { - NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); - String appName = getAppName(this); - String packageName = context.getPackageName(); - Resources resources = context.getResources(); - - int notId = parseInt(NOT_ID, extras); - Intent notificationIntent = new Intent(this, PushHandlerActivity.class); - notificationIntent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP); - notificationIntent.putExtra(PUSH_BUNDLE, extras); - notificationIntent.putExtra(NOT_ID, notId); - - int requestCode = new Random().nextInt(); - PendingIntent contentIntent = PendingIntent.getActivity(this, requestCode, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT); - - NotificationCompat.Builder mBuilder = - new NotificationCompat.Builder(context) - .setWhen(System.currentTimeMillis()) - .setContentTitle(fromHtml(extras.getString(TITLE))) - .setTicker(fromHtml(extras.getString(TITLE))) - .setContentIntent(contentIntent) - .setAutoCancel(true); - - SharedPreferences prefs = context.getSharedPreferences(PushPlugin.COM_ADOBE_PHONEGAP_PUSH, Context.MODE_PRIVATE); - String localIcon = prefs.getString(ICON, null); - String localIconColor = prefs.getString(ICON_COLOR, null); - boolean soundOption = prefs.getBoolean(SOUND, true); - boolean vibrateOption = prefs.getBoolean(VIBRATE, true); - Log.d(LOG_TAG, "stored icon=" + localIcon); - Log.d(LOG_TAG, "stored iconColor=" + localIconColor); - Log.d(LOG_TAG, "stored sound=" + soundOption); - Log.d(LOG_TAG, "stored vibrate=" + vibrateOption); - - /* - * Notification Vibration - */ - - setNotificationVibration(extras, vibrateOption, mBuilder); - - /* - * Notification Icon Color - * - * Sets the small-icon background color of the notification. - * To use, add the `iconColor` key to plugin android options - * - */ - setNotificationIconColor(extras.getString("color"), mBuilder, localIconColor); - - /* - * Notification Icon - * - * Sets the small-icon of the notification. - * - * - checks the plugin options for `icon` key - * - if none, uses the application icon - * - * The icon value must be a string that maps to a drawable resource. - * If no resource is found, falls - * - */ - setNotificationSmallIcon(context, extras, packageName, resources, mBuilder, localIcon); - - /* - * Notification Large-Icon - * - * Sets the large-icon of the notification - * - * - checks the gcm data for the `image` key - * - checks to see if remote image, loads it. - * - checks to see if assets image, Loads It. - * - checks to see if resource image, LOADS IT! - * - if none, we don't set the large icon - * - */ - setNotificationLargeIcon(extras, packageName, resources, mBuilder); - - /* - * Notification Sound - */ - if (soundOption) { - setNotificationSound(context, extras, mBuilder); - } - - /* - * LED Notification - */ - setNotificationLedColor(extras, mBuilder); - - /* - * Priority Notification - */ - setNotificationPriority(extras, mBuilder); - - /* - * Notification message - */ - setNotificationMessage(notId, extras, mBuilder); - - /* - * Notification count - */ - setNotificationCount(context, extras, mBuilder); - - /* - * Notification count - */ - setVisibility(context, extras, mBuilder); - - /* - * Notification add actions - */ - createActions(extras, mBuilder, resources, packageName, notId); - - mNotificationManager.notify(appName, notId, mBuilder.build()); - } - - private void updateIntent(Intent intent, String callback, Bundle extras, boolean foreground, int notId) { - intent.putExtra(CALLBACK, callback); - intent.putExtra(PUSH_BUNDLE, extras); - intent.putExtra(FOREGROUND, foreground); - intent.putExtra(NOT_ID, notId); - } - - private void createActions(Bundle extras, NotificationCompat.Builder mBuilder, Resources resources, String packageName, int notId) { - Log.d(LOG_TAG, "create actions: with in-line"); - String actions = extras.getString(ACTIONS); - if (actions != null) { - try { - JSONArray actionsArray = new JSONArray(actions); - ArrayList<NotificationCompat.Action> wActions = new ArrayList<NotificationCompat.Action>(); - for (int i=0; i < actionsArray.length(); i++) { - int min = 1; - int max = 2000000000; - Random random = new Random(); - int uniquePendingIntentRequestCode = random.nextInt((max - min) + 1) + min; - Log.d(LOG_TAG, "adding action"); - JSONObject action = actionsArray.getJSONObject(i); - Log.d(LOG_TAG, "adding callback = " + action.getString(CALLBACK)); - boolean foreground = action.optBoolean(FOREGROUND, true); - boolean inline = action.optBoolean("inline", false); - Intent intent = null; - PendingIntent pIntent = null; - if (inline) { - Log.d(LOG_TAG, "Version: " + android.os.Build.VERSION.SDK_INT + " = " + android.os.Build.VERSION_CODES.M); - if (android.os.Build.VERSION.SDK_INT <= android.os.Build.VERSION_CODES.M) { - Log.d(LOG_TAG, "push activity"); - intent = new Intent(this, PushHandlerActivity.class); - } else { - Log.d(LOG_TAG, "push receiver"); - intent = new Intent(this, BackgroundActionButtonHandler.class); - } - - updateIntent(intent, action.getString(CALLBACK), extras, foreground, notId); - - if (android.os.Build.VERSION.SDK_INT <= android.os.Build.VERSION_CODES.M) { - Log.d(LOG_TAG, "push activity for notId " + notId); - pIntent = PendingIntent.getActivity(this, uniquePendingIntentRequestCode, intent, PendingIntent.FLAG_ONE_SHOT); - } else { - Log.d(LOG_TAG, "push receiver for notId " + notId); - pIntent = PendingIntent.getBroadcast(this, uniquePendingIntentRequestCode, intent, PendingIntent.FLAG_ONE_SHOT); - } - } else if (foreground) { - intent = new Intent(this, PushHandlerActivity.class); - updateIntent(intent, action.getString(CALLBACK), extras, foreground, notId); - pIntent = PendingIntent.getActivity(this, uniquePendingIntentRequestCode, intent, PendingIntent.FLAG_UPDATE_CURRENT); - } else { - intent = new Intent(this, BackgroundActionButtonHandler.class); - updateIntent(intent, action.getString(CALLBACK), extras, foreground, notId); - pIntent = PendingIntent.getBroadcast(this, uniquePendingIntentRequestCode, intent, PendingIntent.FLAG_UPDATE_CURRENT); - } - - NotificationCompat.Action.Builder actionBuilder = - new NotificationCompat.Action.Builder(resources.getIdentifier(action.optString(ICON, ""), DRAWABLE, packageName), - action.getString(TITLE), pIntent); - - RemoteInput remoteInput = null; - if (inline) { - Log.d(LOG_TAG, "create remote input"); - String replyLabel = "Enter your reply here"; - remoteInput = - new RemoteInput.Builder(INLINE_REPLY) - .setLabel(replyLabel) - .build(); - actionBuilder.addRemoteInput(remoteInput); - } - - NotificationCompat.Action wAction = actionBuilder.build(); - wActions.add(actionBuilder.build()); - - if (inline) { - mBuilder.addAction(wAction); - } else { - mBuilder.addAction(resources.getIdentifier(action.optString(ICON, ""), DRAWABLE, packageName), - action.getString(TITLE), pIntent); - } - wAction = null; - pIntent = null; - } - mBuilder.extend(new WearableExtender().addActions(wActions)); - wActions.clear(); - } catch(JSONException e) { - // nope - } - } - } - - private void setNotificationCount(Context context, Bundle extras, NotificationCompat.Builder mBuilder) { - int count = extractBadgeCount(extras); - if (count >= 0) { - Log.d(LOG_TAG, "count =[" + count + "]"); - mBuilder.setNumber(count); - } - } - - - private void setVisibility(Context context, Bundle extras, NotificationCompat.Builder mBuilder) { - String visibilityStr = extras.getString(VISIBILITY); - if (visibilityStr != null) { - try { - Integer visibility = Integer.parseInt(visibilityStr); - if (visibility >= NotificationCompat.VISIBILITY_SECRET && visibility <= NotificationCompat.VISIBILITY_PUBLIC) { - mBuilder.setVisibility(visibility); - } else { - Log.e(LOG_TAG, "Visibility parameter must be between -1 and 1"); - } - } catch (NumberFormatException e) { - e.printStackTrace(); - } - } - } - - private void setNotificationVibration(Bundle extras, Boolean vibrateOption, NotificationCompat.Builder mBuilder) { - String vibrationPattern = extras.getString(VIBRATION_PATTERN); - if (vibrationPattern != null) { - String[] items = vibrationPattern.replaceAll("\\[", "").replaceAll("\\]", "").split(","); - long[] results = new long[items.length]; - for (int i = 0; i < items.length; i++) { - try { - results[i] = Long.parseLong(items[i].trim()); - } catch (NumberFormatException nfe) {} - } - mBuilder.setVibrate(results); - } else { - if (vibrateOption) { - mBuilder.setDefaults(Notification.DEFAULT_VIBRATE); - } - } - } - - private void setNotificationMessage(int notId, Bundle extras, NotificationCompat.Builder mBuilder) { - String message = extras.getString(MESSAGE); - - String style = extras.getString(STYLE, STYLE_TEXT); - if(STYLE_INBOX.equals(style)) { - setNotification(notId, message); - - mBuilder.setContentText(fromHtml(message)); - - ArrayList<String> messageList = messageMap.get(notId); - Integer sizeList = messageList.size(); - if (sizeList > 1) { - String sizeListMessage = sizeList.toString(); - String stacking = sizeList + " more"; - if (extras.getString(SUMMARY_TEXT) != null) { - stacking = extras.getString(SUMMARY_TEXT); - stacking = stacking.replace("%n%", sizeListMessage); - } - NotificationCompat.InboxStyle notificationInbox = new NotificationCompat.InboxStyle() - .setBigContentTitle(fromHtml(extras.getString(TITLE))) - .setSummaryText(fromHtml(stacking)); - - for (int i = messageList.size() - 1; i >= 0; i--) { - notificationInbox.addLine(fromHtml(messageList.get(i))); - } - - mBuilder.setStyle(notificationInbox); - } else { - NotificationCompat.BigTextStyle bigText = new NotificationCompat.BigTextStyle(); - if (message != null) { - bigText.bigText(fromHtml(message)); - bigText.setBigContentTitle(fromHtml(extras.getString(TITLE))); - mBuilder.setStyle(bigText); - } - } - } else if (STYLE_PICTURE.equals(style)) { - setNotification(notId, ""); - - NotificationCompat.BigPictureStyle bigPicture = new NotificationCompat.BigPictureStyle(); - bigPicture.bigPicture(getBitmapFromURL(extras.getString(PICTURE))); - bigPicture.setBigContentTitle(fromHtml(extras.getString(TITLE))); - bigPicture.setSummaryText(fromHtml(extras.getString(SUMMARY_TEXT))); - - mBuilder.setContentTitle(fromHtml(extras.getString(TITLE))); - mBuilder.setContentText(fromHtml(message)); - - mBuilder.setStyle(bigPicture); - } else { - setNotification(notId, ""); - - NotificationCompat.BigTextStyle bigText = new NotificationCompat.BigTextStyle(); - - if (message != null) { - mBuilder.setContentText(fromHtml(message)); - - bigText.bigText(fromHtml(message)); - bigText.setBigContentTitle(fromHtml(extras.getString(TITLE))); - - String summaryText = extras.getString(SUMMARY_TEXT); - if (summaryText != null) { - bigText.setSummaryText(fromHtml(summaryText)); - } - - mBuilder.setStyle(bigText); - } - /* - else { - mBuilder.setContentText("<missing message content>"); - } - */ - } - } - - private void setNotificationSound(Context context, Bundle extras, NotificationCompat.Builder mBuilder) { - String soundname = extras.getString(SOUNDNAME); - if (soundname == null) { - soundname = extras.getString(SOUND); - } - if (SOUND_RINGTONE.equals(soundname)) { - mBuilder.setSound(android.provider.Settings.System.DEFAULT_RINGTONE_URI); - } else if (soundname != null && !soundname.contentEquals(SOUND_DEFAULT)) { - Uri sound = Uri.parse(ContentResolver.SCHEME_ANDROID_RESOURCE - + "://" + context.getPackageName() + "/raw/" + soundname); - Log.d(LOG_TAG, sound.toString()); - mBuilder.setSound(sound); - } else { - mBuilder.setSound(android.provider.Settings.System.DEFAULT_NOTIFICATION_URI); - } - } - - private void setNotificationLedColor(Bundle extras, NotificationCompat.Builder mBuilder) { - String ledColor = extras.getString(LED_COLOR); - if (ledColor != null) { - // Converts parse Int Array from ledColor - String[] items = ledColor.replaceAll("\\[", "").replaceAll("\\]", "").split(","); - int[] results = new int[items.length]; - for (int i = 0; i < items.length; i++) { - try { - results[i] = Integer.parseInt(items[i].trim()); - } catch (NumberFormatException nfe) {} - } - if (results.length == 4) { - mBuilder.setLights(Color.argb(results[0], results[1], results[2], results[3]), 500, 500); - } else { - Log.e(LOG_TAG, "ledColor parameter must be an array of length == 4 (ARGB)"); - } - } - } - - private void setNotificationPriority(Bundle extras, NotificationCompat.Builder mBuilder) { - String priorityStr = extras.getString(PRIORITY); - if (priorityStr != null) { - try { - Integer priority = Integer.parseInt(priorityStr); - if (priority >= NotificationCompat.PRIORITY_MIN && priority <= NotificationCompat.PRIORITY_MAX) { - mBuilder.setPriority(priority); - } else { - Log.e(LOG_TAG, "Priority parameter must be between -2 and 2"); - } - } catch (NumberFormatException e) { - e.printStackTrace(); - } - } - } - - private void setNotificationLargeIcon(Bundle extras, String packageName, Resources resources, NotificationCompat.Builder mBuilder) { - String gcmLargeIcon = extras.getString(IMAGE); // from gcm - if (gcmLargeIcon != null && !"".equals(gcmLargeIcon)) { - if (gcmLargeIcon.startsWith("http://") || gcmLargeIcon.startsWith("https://")) { - mBuilder.setLargeIcon(getBitmapFromURL(gcmLargeIcon)); - Log.d(LOG_TAG, "using remote large-icon from gcm"); - } else { - AssetManager assetManager = getAssets(); - InputStream istr; - try { - istr = assetManager.open(gcmLargeIcon); - Bitmap bitmap = BitmapFactory.decodeStream(istr); - mBuilder.setLargeIcon(bitmap); - Log.d(LOG_TAG, "using assets large-icon from gcm"); - } catch (IOException e) { - int largeIconId = 0; - largeIconId = resources.getIdentifier(gcmLargeIcon, DRAWABLE, packageName); - if (largeIconId != 0) { - Bitmap largeIconBitmap = BitmapFactory.decodeResource(resources, largeIconId); - mBuilder.setLargeIcon(largeIconBitmap); - Log.d(LOG_TAG, "using resources large-icon from gcm"); - } else { - Log.d(LOG_TAG, "Not setting large icon"); - } - } - } - } - } - - private void setNotificationSmallIcon(Context context, Bundle extras, String packageName, Resources resources, NotificationCompat.Builder mBuilder, String localIcon) { - int iconId = 0; - String icon = extras.getString(ICON); - if (icon != null && !"".equals(icon)) { - iconId = resources.getIdentifier(icon, DRAWABLE, packageName); - Log.d(LOG_TAG, "using icon from plugin options"); - } - else if (localIcon != null && !"".equals(localIcon)) { - iconId = resources.getIdentifier(localIcon, DRAWABLE, packageName); - Log.d(LOG_TAG, "using icon from plugin options"); - } - if (iconId == 0) { - Log.d(LOG_TAG, "no icon resource found - using application icon"); - iconId = context.getApplicationInfo().icon; - } - mBuilder.setSmallIcon(iconId); - } - - private void setNotificationIconColor(String color, NotificationCompat.Builder mBuilder, String localIconColor) { - int iconColor = 0; - if (color != null && !"".equals(color)) { - try { - iconColor = Color.parseColor(color); - } catch (IllegalArgumentException e) { - Log.e(LOG_TAG, "couldn't parse color from android options"); - } - } - else if (localIconColor != null && !"".equals(localIconColor)) { - try { - iconColor = Color.parseColor(localIconColor); - } catch (IllegalArgumentException e) { - Log.e(LOG_TAG, "couldn't parse color from android options"); - } - } - if (iconColor != 0) { - mBuilder.setColor(iconColor); - } - } - - public Bitmap getBitmapFromURL(String strURL) { - try { - URL url = new URL(strURL); - HttpURLConnection connection = (HttpURLConnection) url.openConnection(); - connection.setDoInput(true); - connection.connect(); - InputStream input = connection.getInputStream(); - return BitmapFactory.decodeStream(input); - } catch (IOException e) { - e.printStackTrace(); - return null; - } - } - - public static String getAppName(Context context) { - CharSequence appName = context.getPackageManager().getApplicationLabel(context.getApplicationInfo()); - return (String)appName; - } - - private int parseInt(String value, Bundle extras) { - int retval = 0; - - try { - retval = Integer.parseInt(extras.getString(value)); - } - catch(NumberFormatException e) { - Log.e(LOG_TAG, "Number format exception - Error parsing " + value + ": " + e.getMessage()); - } - catch(Exception e) { - Log.e(LOG_TAG, "Number format exception - Error parsing " + value + ": " + e.getMessage()); - } - - return retval; - } - - private Spanned fromHtml(String source) { - if (source != null) - return Html.fromHtml(source); - else - return null; - } -} diff --git a/StoneIsland/plugins/phonegap-plugin-push/src/android/com/adobe/phonegap/push/PermissionUtils.java b/StoneIsland/plugins/phonegap-plugin-push/src/android/com/adobe/phonegap/push/PermissionUtils.java deleted file mode 100644 index 6aa5c9bf..00000000 --- a/StoneIsland/plugins/phonegap-plugin-push/src/android/com/adobe/phonegap/push/PermissionUtils.java +++ /dev/null @@ -1,55 +0,0 @@ -package com.adobe.phonegap.push; - -import android.content.Context; -import android.content.pm.ApplicationInfo; - -import java.lang.reflect.Field; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; - -public class PermissionUtils { - - private static final String CHECK_OP_NO_THROW = "checkOpNoThrow"; - - public static boolean hasPermission(Context appContext, String appOpsServiceId) throws UnknownError { - - ApplicationInfo appInfo = appContext.getApplicationInfo(); - - String pkg = appContext.getPackageName(); - int uid = appInfo.uid; - Class appOpsClass = null; - Object appOps = appContext.getSystemService("appops"); - - try { - - appOpsClass = Class.forName("android.app.AppOpsManager"); - - Method checkOpNoThrowMethod = appOpsClass.getMethod( - CHECK_OP_NO_THROW, - Integer.TYPE, - Integer.TYPE, - String.class - ); - - Field opValue = appOpsClass.getDeclaredField(appOpsServiceId); - - int value = (int) opValue.getInt(Integer.class); - Object result = checkOpNoThrowMethod.invoke(appOps, value, uid, pkg); - - return Integer.parseInt(result.toString()) == 0; // AppOpsManager.MODE_ALLOWED - - } catch (ClassNotFoundException e) { - throw new UnknownError("class not found"); - } catch (NoSuchMethodException e) { - throw new UnknownError("no such method"); - } catch (NoSuchFieldException e) { - throw new UnknownError("no such field"); - } catch (InvocationTargetException e) { - throw new UnknownError("invocation target"); - } catch (IllegalAccessException e) { - throw new UnknownError("illegal access"); - } - - } - -} diff --git a/StoneIsland/plugins/phonegap-plugin-push/src/android/com/adobe/phonegap/push/PushConstants.java b/StoneIsland/plugins/phonegap-plugin-push/src/android/com/adobe/phonegap/push/PushConstants.java deleted file mode 100644 index 37874e04..00000000 --- a/StoneIsland/plugins/phonegap-plugin-push/src/android/com/adobe/phonegap/push/PushConstants.java +++ /dev/null @@ -1,72 +0,0 @@ -package com.adobe.phonegap.push; - -public interface PushConstants { - public static final String COM_ADOBE_PHONEGAP_PUSH = "com.adobe.phonegap.push"; - public static final String REGISTRATION_ID = "registrationId"; - public static final String FOREGROUND = "foreground"; - public static final String TITLE = "title"; - public static final String NOT_ID = "notId"; - public static final String PUSH_BUNDLE = "pushBundle"; - public static final String ICON = "icon"; - public static final String ICON_COLOR = "iconColor"; - public static final String SOUND = "sound"; - public static final String SOUND_DEFAULT = "default"; - public static final String SOUND_RINGTONE = "ringtone"; - public static final String VIBRATE = "vibrate"; - public static final String ACTIONS = "actions"; - public static final String CALLBACK = "callback"; - public static final String ACTION_CALLBACK = "actionCallback"; - public static final String DRAWABLE = "drawable"; - public static final String MSGCNT = "msgcnt"; - public static final String VIBRATION_PATTERN = "vibrationPattern"; - public static final String STYLE = "style"; - public static final String SUMMARY_TEXT = "summaryText"; - public static final String PICTURE = "picture"; - public static final String GCM_N = "gcm.n."; - public static final String GCM_NOTIFICATION = "gcm.notification"; - public static final String GCM_NOTIFICATION_BODY = "gcm.notification.body"; - public static final String UA_PREFIX = "com.urbanairship.push"; - public static final String PARSE_COM_DATA = "data"; - public static final String ALERT = "alert"; - public static final String MESSAGE = "message"; - public static final String BODY = "body"; - public static final String SOUNDNAME = "soundname"; - public static final String LED_COLOR = "ledColor"; - public static final String PRIORITY = "priority"; - public static final String IMAGE = "image"; - public static final String STYLE_INBOX = "inbox"; - public static final String STYLE_PICTURE = "picture"; - public static final String STYLE_TEXT = "text"; - public static final String BADGE = "badge"; - public static final String INITIALIZE = "init"; - public static final String SUBSCRIBE = "subscribe"; - public static final String UNSUBSCRIBE = "unsubscribe"; - public static final String UNREGISTER = "unregister"; - public static final String EXIT = "exit"; - public static final String FINISH = "finish"; - public static final String HAS_PERMISSION = "hasPermission"; - public static final String ANDROID = "android"; - public static final String SENDER_ID = "senderID"; - public static final String CLEAR_BADGE = "clearBadge"; - public static final String CLEAR_NOTIFICATIONS = "clearNotifications"; - public static final String COLDSTART = "coldstart"; - public static final String ADDITIONAL_DATA = "additionalData"; - public static final String COUNT = "count"; - public static final String FROM = "from"; - public static final String COLLAPSE_KEY = "collapse_key"; - public static final String FORCE_SHOW = "forceShow"; - public static final String GCM = "GCM"; - public static final String CONTENT_AVAILABLE = "content-available"; - public static final String TOPICS = "topics"; - public static final String SET_APPLICATION_ICON_BADGE_NUMBER = "setApplicationIconBadgeNumber"; - public static final String CLEAR_ALL_NOTIFICATIONS = "clearAllNotifications"; - public static final String VISIBILITY = "visibility"; - public static final String INLINE_REPLY = "inlineReply"; - public static final String LOC_KEY = "locKey"; - public static final String LOC_DATA = "locData"; - public static final String TWILIO_BODY = "twi_body"; - public static final String TWILIO_TITLE = "twi_title"; - public static final String TWILIO_SOUND = "twi_sound"; - public static final String START_IN_BACKGROUND = "cdvStartInBackground"; - public static final String FORCE_START = "force-start"; -} diff --git a/StoneIsland/plugins/phonegap-plugin-push/src/android/com/adobe/phonegap/push/PushHandlerActivity.java b/StoneIsland/plugins/phonegap-plugin-push/src/android/com/adobe/phonegap/push/PushHandlerActivity.java deleted file mode 100644 index 23682ac8..00000000 --- a/StoneIsland/plugins/phonegap-plugin-push/src/android/com/adobe/phonegap/push/PushHandlerActivity.java +++ /dev/null @@ -1,120 +0,0 @@ -package com.adobe.phonegap.push; - -import android.app.Activity; -import android.app.NotificationManager; -import android.content.Context; -import android.content.Intent; -import android.content.pm.PackageManager; -import android.os.Bundle; -import android.util.Log; -import android.support.v4.app.RemoteInput; - - -public class PushHandlerActivity extends Activity implements PushConstants { - private static String LOG_TAG = "PushPlugin_PushHandlerActivity"; - - /* - * this activity will be started if the user touches a notification that we own. - * We send it's data off to the push plugin for processing. - * If needed, we boot up the main activity to kickstart the application. - * @see android.app.Activity#onCreate(android.os.Bundle) - */ - @Override - public void onCreate(Bundle savedInstanceState) { - GCMIntentService gcm = new GCMIntentService(); - - Intent intent = getIntent(); - - int notId = intent.getExtras().getInt(NOT_ID, 0); - Log.d(LOG_TAG, "not id = " + notId); - gcm.setNotification(notId, ""); - super.onCreate(savedInstanceState); - Log.v(LOG_TAG, "onCreate"); - String callback = getIntent().getExtras().getString("callback"); - Log.d(LOG_TAG, "callback = " + callback); - boolean foreground = getIntent().getExtras().getBoolean("foreground", true); - boolean startOnBackground = getIntent().getExtras().getBoolean(START_IN_BACKGROUND, false); - - if(!startOnBackground){ - NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); - notificationManager.cancel(GCMIntentService.getAppName(this), notId); - } - - boolean isPushPluginActive = PushPlugin.isActive(); - boolean inline = processPushBundle(isPushPluginActive, intent); - - if(inline && android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.N){ - foreground = true; - } - - Log.d(LOG_TAG, "bringToForeground = " + foreground); - - finish(); - - Log.d(LOG_TAG, "isPushPluginActive = " + isPushPluginActive); - if (!isPushPluginActive && foreground && inline) { - Log.d(LOG_TAG, "forceMainActivityReload"); - forceMainActivityReload(false); - } else if(startOnBackground) { - Log.d(LOG_TAG, "startOnBackgroundTrue"); - forceMainActivityReload(true); - } else { - Log.d(LOG_TAG, "don't want main activity"); - } - } - - /** - * Takes the pushBundle extras from the intent, - * and sends it through to the PushPlugin for processing. - */ - private boolean processPushBundle(boolean isPushPluginActive, Intent intent) { - Bundle extras = getIntent().getExtras(); - Bundle remoteInput = null; - - if (extras != null) { - Bundle originalExtras = extras.getBundle(PUSH_BUNDLE); - - originalExtras.putBoolean(FOREGROUND, false); - originalExtras.putBoolean(COLDSTART, !isPushPluginActive); - originalExtras.putString(ACTION_CALLBACK, extras.getString(CALLBACK)); - - remoteInput = RemoteInput.getResultsFromIntent(intent); - if (remoteInput != null) { - String inputString = remoteInput.getCharSequence(INLINE_REPLY).toString(); - Log.d(LOG_TAG, "response: " + inputString); - originalExtras.putString(INLINE_REPLY, inputString); - } - - PushPlugin.sendExtras(originalExtras); - } - return remoteInput == null; - } - - /** - * Forces the main activity to re-launch if it's unloaded. - */ - private void forceMainActivityReload(boolean startOnBackground) { - PackageManager pm = getPackageManager(); - Intent launchIntent = pm.getLaunchIntentForPackage(getApplicationContext().getPackageName()); - - Bundle extras = getIntent().getExtras(); - if (extras != null) { - Bundle originalExtras = extras.getBundle(PUSH_BUNDLE); - if (originalExtras != null) { - launchIntent.putExtras(originalExtras); - } - launchIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); - launchIntent.addFlags(Intent.FLAG_FROM_BACKGROUND); - launchIntent.putExtra(START_IN_BACKGROUND, startOnBackground); - } - - startActivity(launchIntent); - } - - @Override - protected void onResume() { - super.onResume(); - final NotificationManager notificationManager = (NotificationManager) this.getSystemService(Context.NOTIFICATION_SERVICE); - notificationManager.cancelAll(); - } -} diff --git a/StoneIsland/plugins/phonegap-plugin-push/src/android/com/adobe/phonegap/push/PushInstanceIDListenerService.java b/StoneIsland/plugins/phonegap-plugin-push/src/android/com/adobe/phonegap/push/PushInstanceIDListenerService.java deleted file mode 100644 index eaa39a48..00000000 --- a/StoneIsland/plugins/phonegap-plugin-push/src/android/com/adobe/phonegap/push/PushInstanceIDListenerService.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.adobe.phonegap.push; - -import android.content.Intent; -import android.content.Context; -import android.content.SharedPreferences; -import android.util.Log; - -import com.google.android.gms.iid.InstanceID; -import com.google.android.gms.iid.InstanceIDListenerService; - -import org.json.JSONException; - -import java.io.IOException; - -public class PushInstanceIDListenerService extends InstanceIDListenerService implements PushConstants { - public static final String LOG_TAG = "PushPlugin_PushInstanceIDListenerService"; - - @Override - public void onTokenRefresh() { - SharedPreferences sharedPref = getApplicationContext().getSharedPreferences(COM_ADOBE_PHONEGAP_PUSH, Context.MODE_PRIVATE); - String senderID = sharedPref.getString(SENDER_ID, ""); - if (!"".equals(senderID)) { - Intent intent = new Intent(this, RegistrationIntentService.class); - startService(intent); - } - } -} diff --git a/StoneIsland/plugins/phonegap-plugin-push/src/android/com/adobe/phonegap/push/PushPlugin.java b/StoneIsland/plugins/phonegap-plugin-push/src/android/com/adobe/phonegap/push/PushPlugin.java deleted file mode 100644 index f6faaa2b..00000000 --- a/StoneIsland/plugins/phonegap-plugin-push/src/android/com/adobe/phonegap/push/PushPlugin.java +++ /dev/null @@ -1,458 +0,0 @@ -package com.adobe.phonegap.push; - -import android.app.NotificationManager; -import android.content.Context; -import android.content.SharedPreferences; -import android.os.Bundle; -import android.util.Log; - -import com.google.android.gms.gcm.GcmPubSub; -import com.google.android.gms.iid.InstanceID; - -import org.apache.cordova.CallbackContext; -import org.apache.cordova.CordovaInterface; -import org.apache.cordova.CordovaPlugin; -import org.apache.cordova.CordovaWebView; -import org.apache.cordova.PluginResult; -import org.json.JSONArray; -import org.json.JSONException; -import org.json.JSONObject; - -import java.io.IOException; -import java.util.Collections; -import java.util.HashSet; -import java.util.Iterator; -import java.util.ArrayList; -import java.util.List; - -import me.leolin.shortcutbadger.ShortcutBadger; - -public class PushPlugin extends CordovaPlugin implements PushConstants { - - public static final String LOG_TAG = "PushPlugin"; - - private static CallbackContext pushContext; - private static CordovaWebView gWebView; - private static List<Bundle> gCachedExtras = Collections.synchronizedList(new ArrayList<Bundle>()); - private static boolean gForeground = false; - - private static String registration_id = ""; - - /** - * Gets the application context from cordova's main activity. - * @return the application context - */ - private Context getApplicationContext() { - return this.cordova.getActivity().getApplicationContext(); - } - - @Override - public boolean execute(final String action, final JSONArray data, final CallbackContext callbackContext) { - Log.v(LOG_TAG, "execute: action=" + action); - gWebView = this.webView; - - if (INITIALIZE.equals(action)) { - cordova.getThreadPool().execute(new Runnable() { - public void run() { - pushContext = callbackContext; - JSONObject jo = null; - - Log.v(LOG_TAG, "execute: data=" + data.toString()); - SharedPreferences sharedPref = getApplicationContext().getSharedPreferences(COM_ADOBE_PHONEGAP_PUSH, Context.MODE_PRIVATE); - String senderID = null; - - try { - jo = data.getJSONObject(0).getJSONObject(ANDROID); - - Log.v(LOG_TAG, "execute: jo=" + jo.toString()); - - senderID = jo.getString(SENDER_ID); - - Log.v(LOG_TAG, "execute: senderID=" + senderID); - - String savedSenderID = sharedPref.getString(SENDER_ID, ""); - registration_id = InstanceID.getInstance(getApplicationContext()).getToken(senderID, GCM); - - if (!"".equals(registration_id)) { - JSONObject json = new JSONObject().put(REGISTRATION_ID, registration_id); - - Log.v(LOG_TAG, "onRegistered: " + json.toString()); - - JSONArray topics = jo.optJSONArray(TOPICS); - subscribeToTopics(topics, registration_id); - - PushPlugin.sendEvent( json ); - } else { - callbackContext.error("Empty registration ID received from GCM"); - return; - } - } catch (JSONException e) { - Log.e(LOG_TAG, "execute: Got JSON Exception " + e.getMessage()); - callbackContext.error(e.getMessage()); - } catch (IOException e) { - Log.e(LOG_TAG, "execute: Got JSON Exception " + e.getMessage()); - callbackContext.error(e.getMessage()); - } - - if (jo != null) { - SharedPreferences.Editor editor = sharedPref.edit(); - try { - editor.putString(ICON, jo.getString(ICON)); - } catch (JSONException e) { - Log.d(LOG_TAG, "no icon option"); - } - try { - editor.putString(ICON_COLOR, jo.getString(ICON_COLOR)); - } catch (JSONException e) { - Log.d(LOG_TAG, "no iconColor option"); - } - - boolean clearBadge = jo.optBoolean(CLEAR_BADGE, false); - if (clearBadge) { - setApplicationIconBadgeNumber(getApplicationContext(), 0); - } - - editor.putBoolean(SOUND, jo.optBoolean(SOUND, true)); - editor.putBoolean(VIBRATE, jo.optBoolean(VIBRATE, true)); - editor.putBoolean(CLEAR_BADGE, clearBadge); - editor.putBoolean(CLEAR_NOTIFICATIONS, jo.optBoolean(CLEAR_NOTIFICATIONS, true)); - editor.putBoolean(FORCE_SHOW, jo.optBoolean(FORCE_SHOW, false)); - editor.putString(SENDER_ID, senderID); - editor.commit(); - - } - - if (!gCachedExtras.isEmpty()) { - Log.v(LOG_TAG, "sending cached extras"); - synchronized(gCachedExtras) { - Iterator<Bundle> gCachedExtrasIterator = gCachedExtras.iterator(); - while (gCachedExtrasIterator.hasNext()) { - sendExtras(gCachedExtrasIterator.next()); - } - } - gCachedExtras.clear(); - } - } - }); - } else if (UNREGISTER.equals(action)) { - cordova.getThreadPool().execute(new Runnable() { - public void run() { - try { - SharedPreferences sharedPref = getApplicationContext().getSharedPreferences(COM_ADOBE_PHONEGAP_PUSH, Context.MODE_PRIVATE); - JSONArray topics = data.optJSONArray(0); - if (topics != null && !"".equals(registration_id)) { - unsubscribeFromTopics(topics, registration_id); - } else { - InstanceID.getInstance(getApplicationContext()).deleteInstanceID(); - Log.v(LOG_TAG, "UNREGISTER"); - - // Remove shared prefs - SharedPreferences.Editor editor = sharedPref.edit(); - editor.remove(SOUND); - editor.remove(VIBRATE); - editor.remove(CLEAR_BADGE); - editor.remove(CLEAR_NOTIFICATIONS); - editor.remove(FORCE_SHOW); - editor.remove(SENDER_ID); - editor.commit(); - } - - callbackContext.success(); - } catch (IOException e) { - Log.e(LOG_TAG, "execute: Got JSON Exception " + e.getMessage()); - callbackContext.error(e.getMessage()); - } - } - }); - } else if (FINISH.equals(action)) { - callbackContext.success(); - } else if (HAS_PERMISSION.equals(action)) { - cordova.getThreadPool().execute(new Runnable() { - public void run() { - JSONObject jo = new JSONObject(); - try { - jo.put("isEnabled", PermissionUtils.hasPermission(getApplicationContext(), "OP_POST_NOTIFICATION")); - PluginResult pluginResult = new PluginResult(PluginResult.Status.OK, jo); - pluginResult.setKeepCallback(true); - callbackContext.sendPluginResult(pluginResult); - } catch (UnknownError e) { - callbackContext.error(e.getMessage()); - } catch (JSONException e) { - callbackContext.error(e.getMessage()); - } - } - }); - } else if (SET_APPLICATION_ICON_BADGE_NUMBER.equals(action)) { - cordova.getThreadPool().execute(new Runnable() { - public void run() { - Log.v(LOG_TAG, "setApplicationIconBadgeNumber: data=" + data.toString()); - try { - setApplicationIconBadgeNumber(getApplicationContext(), data.getJSONObject(0).getInt(BADGE)); - } catch (JSONException e) { - callbackContext.error(e.getMessage()); - } - callbackContext.success(); - } - }); - } else if (CLEAR_ALL_NOTIFICATIONS.equals(action)) { - cordova.getThreadPool().execute(new Runnable() { - public void run() { - Log.v(LOG_TAG, "clearAllNotifications"); - clearAllNotifications(); - callbackContext.success(); - } - }); - } else if (SUBSCRIBE.equals(action)){ - // Subscribing for a topic - cordova.getThreadPool().execute(new Runnable() { - public void run() { - try { - String topic = data.getString(0); - subscribeToTopic(topic, registration_id); - callbackContext.success(); - } catch (JSONException e) { - callbackContext.error(e.getMessage()); - } catch (IOException e) { - callbackContext.error(e.getMessage()); - } - } - }); - } else if (UNSUBSCRIBE.equals(action)){ - // un-subscribing for a topic - cordova.getThreadPool().execute(new Runnable(){ - public void run() { - try { - String topic = data.getString(0); - unsubscribeFromTopic(topic, registration_id); - callbackContext.success(); - } catch (JSONException e) { - callbackContext.error(e.getMessage()); - } catch (IOException e) { - callbackContext.error(e.getMessage()); - } - } - }); - } else { - Log.e(LOG_TAG, "Invalid action : " + action); - callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.INVALID_ACTION)); - return false; - } - - return true; - } - - public static void sendEvent(JSONObject _json) { - PluginResult pluginResult = new PluginResult(PluginResult.Status.OK, _json); - pluginResult.setKeepCallback(true); - if (pushContext != null) { - pushContext.sendPluginResult(pluginResult); - } - } - - public static void sendError(String message) { - PluginResult pluginResult = new PluginResult(PluginResult.Status.ERROR, message); - pluginResult.setKeepCallback(true); - if (pushContext != null) { - pushContext.sendPluginResult(pluginResult); - } - } - - /* - * Sends the pushbundle extras to the client application. - * If the client application isn't currently active, it is cached for later processing. - */ - public static void sendExtras(Bundle extras) { - if (extras != null) { - if (gWebView != null) { - sendEvent(convertBundleToJson(extras)); - } else { - Log.v(LOG_TAG, "sendExtras: caching extras to send at a later time."); - gCachedExtras.add(extras); - } - } - } - - public static void setApplicationIconBadgeNumber(Context context, int badgeCount) { - if (badgeCount > 0) { - ShortcutBadger.applyCount(context, badgeCount); - } else { - ShortcutBadger.removeCount(context); - } - } - - @Override - public void initialize(CordovaInterface cordova, CordovaWebView webView) { - super.initialize(cordova, webView); - gForeground = true; - } - - @Override - public void onPause(boolean multitasking) { - super.onPause(multitasking); - gForeground = false; - - SharedPreferences prefs = getApplicationContext().getSharedPreferences(COM_ADOBE_PHONEGAP_PUSH, Context.MODE_PRIVATE); - if (prefs.getBoolean(CLEAR_NOTIFICATIONS, true)) { - clearAllNotifications(); - } - } - - @Override - public void onResume(boolean multitasking) { - super.onResume(multitasking); - gForeground = true; - } - - @Override - public void onDestroy() { - super.onDestroy(); - gForeground = false; - gWebView = null; - } - - private void clearAllNotifications() { - final NotificationManager notificationManager = (NotificationManager) cordova.getActivity().getSystemService(Context.NOTIFICATION_SERVICE); - notificationManager.cancelAll(); - } - - /** - * Transform `topic name` to `topic path` - * Normally, the `topic` inputed from end-user is `topic name` only. - * We should convert them to GCM `topic path` - * Example: - * when topic name = 'my-topic' - * then topic path = '/topics/my-topic' - * - * @param String topic The topic name - * @return The topic path - */ - private String getTopicPath(String topic) - { - return "/topics/" + topic; - } - - private void subscribeToTopics(JSONArray topics, String registrationToken) throws IOException { - if (topics != null) { - String topic = null; - for (int i=0; i<topics.length(); i++) { - topic = topics.optString(i, null); - subscribeToTopic(topic, registrationToken); - } - } - } - - private void subscribeToTopic(String topic, String registrationToken) throws IOException - { - try { - if (topic != null) { - Log.d(LOG_TAG, "Subscribing to topic: " + topic); - GcmPubSub.getInstance(getApplicationContext()).subscribe(registrationToken, getTopicPath(topic), null); - } - } catch (IOException e) { - Log.e(LOG_TAG, "Failed to subscribe to topic: " + topic, e); - throw e; - } - } - - private void unsubscribeFromTopics(JSONArray topics, String registrationToken) { - if (topics != null) { - String topic = null; - for (int i=0; i<topics.length(); i++) { - try { - topic = topics.optString(i, null); - if (topic != null) { - Log.d(LOG_TAG, "Unsubscribing to topic: " + topic); - GcmPubSub.getInstance(getApplicationContext()).unsubscribe(registrationToken, getTopicPath(topic)); - } - } catch (IOException e) { - Log.e(LOG_TAG, "Failed to unsubscribe to topic: " + topic, e); - } - } - } - } - - private void unsubscribeFromTopic(String topic, String registrationToken) throws IOException - { - try { - if (topic != null) { - Log.d(LOG_TAG, "Unsubscribing to topic: " + topic); - GcmPubSub.getInstance(getApplicationContext()).unsubscribe(registrationToken, getTopicPath(topic)); - } - } catch (IOException e) { - Log.e(LOG_TAG, "Failed to unsubscribe to topic: " + topic, e); - throw e; - } - } - - /* - * serializes a bundle to JSON. - */ - private static JSONObject convertBundleToJson(Bundle extras) { - Log.d(LOG_TAG, "convert extras to json"); - try { - JSONObject json = new JSONObject(); - JSONObject additionalData = new JSONObject(); - - // Add any keys that need to be in top level json to this set - HashSet<String> jsonKeySet = new HashSet(); - Collections.addAll(jsonKeySet, TITLE,MESSAGE,COUNT,SOUND,IMAGE); - - Iterator<String> it = extras.keySet().iterator(); - while (it.hasNext()) { - String key = it.next(); - Object value = extras.get(key); - - Log.d(LOG_TAG, "key = " + key); - - if (jsonKeySet.contains(key)) { - json.put(key, value); - } - else if (key.equals(COLDSTART)) { - additionalData.put(key, extras.getBoolean(COLDSTART)); - } - else if (key.equals(FOREGROUND)) { - additionalData.put(key, extras.getBoolean(FOREGROUND)); - } - else if ( value instanceof String ) { - String strValue = (String)value; - try { - // Try to figure out if the value is another JSON object - if (strValue.startsWith("{")) { - additionalData.put(key, new JSONObject(strValue)); - } - // Try to figure out if the value is another JSON array - else if (strValue.startsWith("[")) { - additionalData.put(key, new JSONArray(strValue)); - } - else { - additionalData.put(key, value); - } - } catch (Exception e) { - additionalData.put(key, value); - } - } - } // while - - json.put(ADDITIONAL_DATA, additionalData); - Log.v(LOG_TAG, "extrasToJSON: " + json.toString()); - - return json; - } - catch( JSONException e) { - Log.e(LOG_TAG, "extrasToJSON: JSON exception"); - } - return null; - } - - public static boolean isInForeground() { - return gForeground; - } - - public static boolean isActive() { - return gWebView != null; - } - - protected static void setRegistrationID(String token) { - registration_id = token; - } -} diff --git a/StoneIsland/plugins/phonegap-plugin-push/src/android/com/adobe/phonegap/push/RegistrationIntentService.java b/StoneIsland/plugins/phonegap-plugin-push/src/android/com/adobe/phonegap/push/RegistrationIntentService.java deleted file mode 100644 index b181e88e..00000000 --- a/StoneIsland/plugins/phonegap-plugin-push/src/android/com/adobe/phonegap/push/RegistrationIntentService.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.adobe.phonegap.push; - -import android.content.Context; - -import android.app.IntentService; -import android.content.Intent; -import android.content.SharedPreferences; -import android.util.Log; - -import com.google.android.gms.gcm.GoogleCloudMessaging; -import com.google.android.gms.iid.InstanceID; - -import java.io.IOException; - -public class RegistrationIntentService extends IntentService implements PushConstants { - public static final String LOG_TAG = "PushPlugin_RegistrationIntentService"; - - public RegistrationIntentService() { - super(LOG_TAG); - } - - @Override - protected void onHandleIntent(Intent intent) { - SharedPreferences sharedPreferences = getApplicationContext().getSharedPreferences(COM_ADOBE_PHONEGAP_PUSH, Context.MODE_PRIVATE); - - try { - InstanceID instanceID = InstanceID.getInstance(this); - String senderID = sharedPreferences.getString(SENDER_ID, ""); - String token = instanceID.getToken(senderID, - GoogleCloudMessaging.INSTANCE_ID_SCOPE, null); - PushPlugin.setRegistrationID(token); - Log.i(LOG_TAG, "new GCM Registration Token: " + token); - - } catch (Exception e) { - Log.d(LOG_TAG, "Failed to complete token refresh", e); - } - } -} diff --git a/StoneIsland/plugins/phonegap-plugin-push/src/browser/ServiceWorker.js b/StoneIsland/plugins/phonegap-plugin-push/src/browser/ServiceWorker.js deleted file mode 100644 index 0fc06d09..00000000 --- a/StoneIsland/plugins/phonegap-plugin-push/src/browser/ServiceWorker.js +++ /dev/null @@ -1,51 +0,0 @@ -var messageChannel; - -self.addEventListener('install', function(event) { - self.skipWaiting(); -}); - -self.addEventListener('push', function(event) { - // parse incoming message - var obj = {}; - var pushData = { - image: 'https://avatars1.githubusercontent.com/u/60365?v=3&s=200', - additionalData: {} - }; - if (event.data) { - obj = event.data.json(); - } - - console.log(obj); - - // convert to push plugin API - for (var key in obj) { - if (key === 'title') { - pushData.title = obj[key]; - } else if (key === 'message' || key === 'body') { - pushData.message = obj[key]; - } else if (key === 'count' || key === 'msgcnt' || key === 'badge') { - pushData.count = obj[key]; - } else if (key === 'sound' || key === 'soundname') { - pushData.sound = obj[key]; - } else if (key === 'image') { - pushData.image = obj[key]; - } else { - pushData.additionalData[key] = obj[key]; - } - } - - event.waitUntil( - self.registration.showNotification(pushData.title, { - body: pushData.message, - icon: pushData.image, - tag: 'simple-push-demo-notification-tag' - }) - ); - - messageChannel.ports[0].postMessage(pushData); - -}); - -self.addEventListener('message', function(event) { - messageChannel = event; -}); diff --git a/StoneIsland/plugins/phonegap-plugin-push/src/browser/manifest.json b/StoneIsland/plugins/phonegap-plugin-push/src/browser/manifest.json deleted file mode 100644 index ce8390ab..00000000 --- a/StoneIsland/plugins/phonegap-plugin-push/src/browser/manifest.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "name": "Push Demo", - "gcm_sender_id": "85075801930" -} diff --git a/StoneIsland/plugins/phonegap-plugin-push/src/ios/AppDelegate+notification.h b/StoneIsland/plugins/phonegap-plugin-push/src/ios/AppDelegate+notification.h deleted file mode 100644 index 9970762b..00000000 --- a/StoneIsland/plugins/phonegap-plugin-push/src/ios/AppDelegate+notification.h +++ /dev/null @@ -1,22 +0,0 @@ -// -// AppDelegate+notification.h -// pushtest -// -// Created by Robert Easterday on 10/26/12. -// -// - -#import "AppDelegate.h" - -@interface AppDelegate (notification) -- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken; -- (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error; -- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:( void (^)(UIBackgroundFetchResult))completionHandler; -- (void)pushPluginOnApplicationDidBecomeActive:(UIApplication *)application; -- (void)application:(UIApplication *)application handleActionWithIdentifier:(NSString *)identifier forRemoteNotification:(NSDictionary *)userInfo completionHandler:(void(^)())completionHandler; -- (id) getCommandInstance:(NSString*)className; - -@property (nonatomic, retain) NSDictionary *launchNotification; -@property (nonatomic, retain) NSNumber *coldstart; - -@end diff --git a/StoneIsland/plugins/phonegap-plugin-push/src/ios/AppDelegate+notification.m b/StoneIsland/plugins/phonegap-plugin-push/src/ios/AppDelegate+notification.m deleted file mode 100644 index fc18dd79..00000000 --- a/StoneIsland/plugins/phonegap-plugin-push/src/ios/AppDelegate+notification.m +++ /dev/null @@ -1,278 +0,0 @@ -// -// AppDelegate+notification.m -// pushtest -// -// Created by Robert Easterday on 10/26/12. -// -// - -#import "AppDelegate+notification.h" -#import "PushPlugin.h" -#import <objc/runtime.h> - -static char launchNotificationKey; -static char coldstartKey; - -@implementation AppDelegate (notification) - -- (id) getCommandInstance:(NSString*)className -{ - return [self.viewController getCommandInstance:className]; -} - -// its dangerous to override a method from within a category. -// Instead we will use method swizzling. we set this up in the load call. -+ (void)load -{ - static dispatch_once_t onceToken; - dispatch_once(&onceToken, ^{ - Class class = [self class]; - - SEL originalSelector = @selector(init); - SEL swizzledSelector = @selector(pushPluginSwizzledInit); - - Method original = class_getInstanceMethod(class, originalSelector); - Method swizzled = class_getInstanceMethod(class, swizzledSelector); - - BOOL didAddMethod = - class_addMethod(class, - originalSelector, - method_getImplementation(swizzled), - method_getTypeEncoding(swizzled)); - - if (didAddMethod) { - class_replaceMethod(class, - swizzledSelector, - method_getImplementation(original), - method_getTypeEncoding(original)); - } else { - method_exchangeImplementations(original, swizzled); - } - }); -} - -- (AppDelegate *)pushPluginSwizzledInit -{ - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(createNotificationChecker:) - name:UIApplicationDidFinishLaunchingNotification - object:nil]; - [[NSNotificationCenter defaultCenter]addObserver:self - selector:@selector(pushPluginOnApplicationDidBecomeActive:) - name:UIApplicationDidBecomeActiveNotification - object:nil]; - - // This actually calls the original init method over in AppDelegate. Equivilent to calling super - // on an overrided method, this is not recursive, although it appears that way. neat huh? - return [self pushPluginSwizzledInit]; -} - -// This code will be called immediately after application:didFinishLaunchingWithOptions:. We need -// to process notifications in cold-start situations -- (void)createNotificationChecker:(NSNotification *)notification -{ - NSLog(@"createNotificationChecker"); - if (notification) - { - NSDictionary *launchOptions = [notification userInfo]; - if (launchOptions) { - NSLog(@"coldstart"); - self.launchNotification = [launchOptions objectForKey: @"UIApplicationLaunchOptionsRemoteNotificationKey"]; - self.coldstart = [NSNumber numberWithBool:YES]; - } else { - NSLog(@"not coldstart"); - self.coldstart = [NSNumber numberWithBool:NO]; - } - } -} - -- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken { - PushPlugin *pushHandler = [self getCommandInstance:@"PushNotification"]; - [pushHandler didRegisterForRemoteNotificationsWithDeviceToken:deviceToken]; -} - -- (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error { - PushPlugin *pushHandler = [self getCommandInstance:@"PushNotification"]; - [pushHandler didFailToRegisterForRemoteNotificationsWithError:error]; -} - -- (void) application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo { - NSLog(@"clicked on the shade"); - PushPlugin *pushHandler = [self getCommandInstance:@"PushNotification"]; - pushHandler.notificationMessage = userInfo; - pushHandler.isInline = NO; - [pushHandler notificationReceived]; -} - -- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler { - NSLog(@"didReceiveNotification with fetchCompletionHandler"); - - // app is in the foreground so call notification callback - if (application.applicationState == UIApplicationStateActive) { - NSLog(@"app active"); - PushPlugin *pushHandler = [self getCommandInstance:@"PushNotification"]; - pushHandler.notificationMessage = userInfo; - pushHandler.isInline = YES; - [pushHandler notificationReceived]; - - completionHandler(UIBackgroundFetchResultNewData); - } - // app is in background or in stand by - else { - NSLog(@"app in-active"); - - // do some convoluted logic to find out if this should be a silent push. - long silent = 0; - id aps = [userInfo objectForKey:@"aps"]; - id contentAvailable = [aps objectForKey:@"content-available"]; - if ([contentAvailable isKindOfClass:[NSString class]] && [contentAvailable isEqualToString:@"1"]) { - silent = 1; - } else if ([contentAvailable isKindOfClass:[NSNumber class]]) { - silent = [contentAvailable integerValue]; - } - - if (silent == 1) { - NSLog(@"this should be a silent push"); - void (^safeHandler)(UIBackgroundFetchResult) = ^(UIBackgroundFetchResult result){ - dispatch_async(dispatch_get_main_queue(), ^{ - completionHandler(result); - }); - }; - - PushPlugin *pushHandler = [self getCommandInstance:@"PushNotification"]; - - if (pushHandler.handlerObj == nil) { - pushHandler.handlerObj = [NSMutableDictionary dictionaryWithCapacity:2]; - } - - id notId = [userInfo objectForKey:@"notId"]; - if (notId != nil) { - NSLog(@"Push Plugin notId %@", notId); - [pushHandler.handlerObj setObject:safeHandler forKey:notId]; - } else { - NSLog(@"Push Plugin notId handler"); - [pushHandler.handlerObj setObject:safeHandler forKey:@"handler"]; - } - - pushHandler.notificationMessage = userInfo; - pushHandler.isInline = NO; - [pushHandler notificationReceived]; - } else { - NSLog(@"just put it in the shade"); - //save it for later - self.launchNotification = userInfo; - - completionHandler(UIBackgroundFetchResultNewData); - } - } -} - -- (BOOL)userHasRemoteNotificationsEnabled { - UIApplication *application = [UIApplication sharedApplication]; - if ([[UIApplication sharedApplication] respondsToSelector:@selector(registerUserNotificationSettings:)]) { - return application.currentUserNotificationSettings.types != UIUserNotificationTypeNone; - } else { -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wdeprecated-declarations" - return application.enabledRemoteNotificationTypes != UIRemoteNotificationTypeNone; -#pragma GCC diagnostic pop - } -} - -- (void)pushPluginOnApplicationDidBecomeActive:(NSNotification *)notification { - - NSLog(@"active"); - - UIApplication *application = notification.object; - - PushPlugin *pushHandler = [self getCommandInstance:@"PushNotification"]; - if (pushHandler.clearBadge) { - NSLog(@"PushPlugin clearing badge"); - //zero badge - application.applicationIconBadgeNumber = 0; - } else { - NSLog(@"PushPlugin skip clear badge"); - } - - if (self.launchNotification) { - pushHandler.isInline = NO; - pushHandler.coldstart = [self.coldstart boolValue]; - pushHandler.notificationMessage = self.launchNotification; - self.launchNotification = nil; - self.coldstart = [NSNumber numberWithBool:NO]; - [pushHandler performSelectorOnMainThread:@selector(notificationReceived) withObject:pushHandler waitUntilDone:NO]; - } -} - - -- (void)application:(UIApplication *) application handleActionWithIdentifier: (NSString *) identifier -forRemoteNotification: (NSDictionary *) notification completionHandler: (void (^)()) completionHandler { - - NSLog(@"Push Plugin handleActionWithIdentifier %@", identifier); - NSMutableDictionary *userInfo = [notification mutableCopy]; - [userInfo setObject:identifier forKey:@"actionCallback"]; - NSLog(@"Push Plugin userInfo %@", userInfo); - - if (application.applicationState == UIApplicationStateActive) { - PushPlugin *pushHandler = [self getCommandInstance:@"PushNotification"]; - pushHandler.notificationMessage = userInfo; - pushHandler.isInline = NO; - [pushHandler notificationReceived]; - } else { - void (^safeHandler)() = ^(void){ - dispatch_async(dispatch_get_main_queue(), ^{ - completionHandler(); - }); - }; - - PushPlugin *pushHandler = [self getCommandInstance:@"PushNotification"]; - - if (pushHandler.handlerObj == nil) { - pushHandler.handlerObj = [NSMutableDictionary dictionaryWithCapacity:2]; - } - - id notId = [userInfo objectForKey:@"notId"]; - if (notId != nil) { - NSLog(@"Push Plugin notId %@", notId); - [pushHandler.handlerObj setObject:safeHandler forKey:notId]; - } else { - NSLog(@"Push Plugin notId handler"); - [pushHandler.handlerObj setObject:safeHandler forKey:@"handler"]; - } - - pushHandler.notificationMessage = userInfo; - pushHandler.isInline = NO; - - [pushHandler performSelectorOnMainThread:@selector(notificationReceived) withObject:pushHandler waitUntilDone:NO]; - } -} - -// The accessors use an Associative Reference since you can't define a iVar in a category -// http://developer.apple.com/library/ios/#documentation/cocoa/conceptual/objectivec/Chapters/ocAssociativeReferences.html -- (NSMutableArray *)launchNotification -{ - return objc_getAssociatedObject(self, &launchNotificationKey); -} - -- (void)setLaunchNotification:(NSDictionary *)aDictionary -{ - objc_setAssociatedObject(self, &launchNotificationKey, aDictionary, OBJC_ASSOCIATION_RETAIN_NONATOMIC); -} - -- (NSNumber *)coldstart -{ - return objc_getAssociatedObject(self, &coldstartKey); -} - -- (void)setColdstart:(NSNumber *)aNumber -{ - objc_setAssociatedObject(self, &coldstartKey, aNumber, OBJC_ASSOCIATION_RETAIN_NONATOMIC); -} - -- (void)dealloc -{ - self.launchNotification = nil; // clear the association and release the object - self.coldstart = nil; -} - -@end diff --git a/StoneIsland/plugins/phonegap-plugin-push/src/ios/PushPlugin.h b/StoneIsland/plugins/phonegap-plugin-push/src/ios/PushPlugin.h deleted file mode 100644 index 276a0080..00000000 --- a/StoneIsland/plugins/phonegap-plugin-push/src/ios/PushPlugin.h +++ /dev/null @@ -1,80 +0,0 @@ -/* - Copyright 2009-2011 Urban Airship Inc. All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - 1. Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - 2. Redistributions in binaryform must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided withthe distribution. - - THIS SOFTWARE IS PROVIDED BY THE URBAN AIRSHIP INC``AS IS'' AND ANY EXPRESS OR - IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO - EVENT SHALL URBAN AIRSHIP INC OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#import <Foundation/Foundation.h> -#import <Cordova/CDV.h> -#import <Cordova/CDVPlugin.h> - -@protocol GGLInstanceIDDelegate; -@protocol GCMReceiverDelegate; -@interface PushPlugin : CDVPlugin<GGLInstanceIDDelegate, GCMReceiverDelegate> -{ - NSDictionary *notificationMessage; - BOOL isInline; - NSString *notificationCallbackId; - NSString *callback; - BOOL clearBadge; - - NSMutableDictionary *handlerObj; - void (^completionHandler)(UIBackgroundFetchResult); - - BOOL ready; -} - -@property (nonatomic, copy) NSString *callbackId; -@property (nonatomic, copy) NSString *notificationCallbackId; -@property (nonatomic, copy) NSString *callback; - -@property (nonatomic, strong) NSDictionary *notificationMessage; -@property BOOL isInline; -@property BOOL coldstart; -@property BOOL clearBadge; -@property (nonatomic, strong) NSMutableDictionary *handlerObj; - -- (void)init:(CDVInvokedUrlCommand*)command; -- (void)unregister:(CDVInvokedUrlCommand*)command; -- (void)subscribe:(CDVInvokedUrlCommand*)command; -- (void)unsubscribe:(CDVInvokedUrlCommand*)command; - -- (void)didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken; -- (void)didFailToRegisterForRemoteNotificationsWithError:(NSError *)error; - -- (void)setNotificationMessage:(NSDictionary *)notification; -- (void)notificationReceived; - -- (void)willSendDataMessageWithID:(NSString *)messageID error:(NSError *)error; -- (void)didSendDataMessageWithID:(NSString *)messageID; -- (void)didDeleteMessagesOnServer; - -// GCM Features -@property(nonatomic, assign) BOOL usesGCM; -@property(nonatomic, strong) NSNumber* gcmSandbox; -@property(nonatomic, strong) NSString *gcmSenderId; -@property(nonatomic, strong) NSDictionary *gcmRegistrationOptions; -@property(nonatomic, strong) void (^gcmRegistrationHandler) (NSString *registrationToken, NSError *error); -@property(nonatomic, strong) NSString *gcmRegistrationToken; -@property(nonatomic, strong) NSArray *gcmTopics; - -@end diff --git a/StoneIsland/plugins/phonegap-plugin-push/src/ios/PushPlugin.m b/StoneIsland/plugins/phonegap-plugin-push/src/ios/PushPlugin.m deleted file mode 100644 index a176b9af..00000000 --- a/StoneIsland/plugins/phonegap-plugin-push/src/ios/PushPlugin.m +++ /dev/null @@ -1,677 +0,0 @@ -/* - Copyright 2009-2011 Urban Airship Inc. All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - 1. Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - 2. Redistributions in binaryform must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided withthe distribution. - - THIS SOFTWARE IS PROVIDED BY THE URBAN AIRSHIP INC``AS IS'' AND ANY EXPRESS OR - IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO - EVENT SHALL URBAN AIRSHIP INC OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -// See GGLInstanceID.h -#define GMP_NO_MODULES true - -#import "PushPlugin.h" -#import "GoogleCloudMessaging.h" -#import "GGLInstanceIDHeaders.h" - -@implementation PushPlugin : CDVPlugin - -@synthesize notificationMessage; -@synthesize isInline; -@synthesize coldstart; - -@synthesize callbackId; -@synthesize notificationCallbackId; -@synthesize callback; -@synthesize clearBadge; -@synthesize handlerObj; - -@synthesize usesGCM; -@synthesize gcmSandbox; -@synthesize gcmSenderId; -@synthesize gcmRegistrationOptions; -@synthesize gcmRegistrationHandler; -@synthesize gcmRegistrationToken; -@synthesize gcmTopics; - --(void)initGCMRegistrationHandler; -{ - __weak __block PushPlugin *weakSelf = self; - gcmRegistrationHandler = ^(NSString *registrationToken, NSError *error){ - if (registrationToken != nil) { - NSLog(@"GCM Registration Token: %@", registrationToken); - [weakSelf setGcmRegistrationToken: registrationToken]; - - id topics = [weakSelf gcmTopics]; - if (topics != nil) { - for (NSString *topic in topics) { - NSLog(@"subscribe from topic: %@", topic); - id pubSub = [GCMPubSub sharedInstance]; - [pubSub subscribeWithToken: [weakSelf gcmRegistrationToken] - topic:[NSString stringWithFormat:@"/topics/%@", topic] - options:nil - handler:^void(NSError *error) { - if (error) { - if (error.code == 3001) { - NSLog(@"Already subscribed to %@", topic); - } else { - NSLog(@"Failed to subscribe to topic %@: %@", topic, error); - } - } - else { - NSLog(@"Successfully subscribe to topic %@", topic); - } - }]; - } - } - - [weakSelf registerWithToken:registrationToken]; - } else { - NSLog(@"Registration to GCM failed with error: %@", error.localizedDescription); - [weakSelf failWithMessage:self.callbackId withMsg:@"" withError:error]; - } - }; -} - -// GCM refresh token -// Unclear how this is testable under normal circumstances -- (void)onTokenRefresh { -#if !TARGET_IPHONE_SIMULATOR - // A rotation of the registration tokens is happening, so the app needs to request a new token. - NSLog(@"The GCM registration token needs to be changed."); - [[GGLInstanceID sharedInstance] tokenWithAuthorizedEntity:[self gcmSenderId] - scope:kGGLInstanceIDScopeGCM - options:[self gcmRegistrationOptions] - handler:[self gcmRegistrationHandler]]; -#endif -} - -- (void)willSendDataMessageWithID:(NSString *)messageID error:(NSError *)error { - NSLog(@"willSendDataMessageWithID"); - if (error) { - // Failed to send the message. - } else { - // Will send message, you can save the messageID to track the message - } -} - -- (void)didSendDataMessageWithID:(NSString *)messageID { - NSLog(@"willSendDataMessageWithID"); - // Did successfully send message identified by messageID -} - -- (void)didDeleteMessagesOnServer { - NSLog(@"didDeleteMessagesOnServer"); - // Some messages sent to this device were deleted on the GCM server before reception, likely - // because the TTL expired. The client should notify the app server of this, so that the app - // server can resend those messages. -} - -- (void)unregister:(CDVInvokedUrlCommand*)command; -{ - NSArray* topics = [command argumentAtIndex:0]; - - if (topics != nil) { - id pubSub = [GCMPubSub sharedInstance]; - for (NSString *topic in topics) { - NSLog(@"unsubscribe from topic: %@", topic); - [pubSub unsubscribeWithToken: [self gcmRegistrationToken] - topic:[NSString stringWithFormat:@"/topics/%@", topic] - options:nil - handler:^void(NSError *error) { - if (error) { - NSLog(@"Failed to unsubscribe from topic %@: %@", topic, error); - } - else { - NSLog(@"Successfully unsubscribe from topic %@", topic); - } - }]; - } - } else { - [[UIApplication sharedApplication] unregisterForRemoteNotifications]; - [self successWithMessage:command.callbackId withMsg:@"unregistered"]; - } -} - -- (void)subscribe:(CDVInvokedUrlCommand*)command; -{ - NSString* topic = [command argumentAtIndex:0]; - - if (topic != nil) { - NSLog(@"subscribe from topic: %@", topic); - id pubSub = [GCMPubSub sharedInstance]; - [pubSub subscribeWithToken: [self gcmRegistrationToken] - topic:[NSString stringWithFormat:@"/topics/%@", topic] - options:nil - handler:^void(NSError *error) { - if (error) { - if (error.code == 3001) { - NSLog(@"Already subscribed to %@", topic); - [self successWithMessage:command.callbackId withMsg:[NSString stringWithFormat:@"Already subscribed to %@", topic]]; - } else { - NSLog(@"Failed to subscribe to topic %@: %@", topic, error); - [self failWithMessage:command.callbackId withMsg:[NSString stringWithFormat:@"Failed to subscribe to topic %@", topic] withError:error]; - } - } - else { - NSLog(@"Successfully subscribe to topic %@", topic); - [self successWithMessage:command.callbackId withMsg:[NSString stringWithFormat:@"Successfully subscribe to topic %@", topic]]; - } - }]; - } else { - NSLog(@"There is no topic to subscribe"); - [self successWithMessage:command.callbackId withMsg:@"There is no topic to subscribe"]; - } -} - -- (void)unsubscribe:(CDVInvokedUrlCommand*)command; -{ - NSString* topic = [command argumentAtIndex:0]; - - if (topic != nil) { - NSLog(@"unsubscribe from topic: %@", topic); - id pubSub = [GCMPubSub sharedInstance]; - [pubSub unsubscribeWithToken: [self gcmRegistrationToken] - topic:[NSString stringWithFormat:@"/topics/%@", topic] - options:nil - handler:^void(NSError *error) { - if (error) { - NSLog(@"Failed to unsubscribe to topic %@: %@", topic, error); - [self failWithMessage:command.callbackId withMsg:[NSString stringWithFormat:@"Failed to unsubscribe to topic %@", topic] withError:error]; - } else { - NSLog(@"Successfully unsubscribe to topic %@", topic); - [self successWithMessage:command.callbackId withMsg:[NSString stringWithFormat:@"Successfully unsubscribe to topic %@", topic]]; - } - }]; - } else { - NSLog(@"There is no topic to unsubscribe"); - [self successWithMessage:command.callbackId withMsg:@"There is no topic to unsubscribe"]; - } -} - -- (void)init:(CDVInvokedUrlCommand*)command; -{ - [self.commandDelegate runInBackground:^ { - - NSLog(@"Push Plugin register called"); - self.callbackId = command.callbackId; - - NSMutableDictionary* options = [command.arguments objectAtIndex:0]; - NSMutableDictionary* iosOptions = [options objectForKey:@"ios"]; - - NSArray* topics = [iosOptions objectForKey:@"topics"]; - [self setGcmTopics:topics]; - -#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 80000 - UIUserNotificationType UserNotificationTypes = UIUserNotificationTypeNone; -#endif - UIRemoteNotificationType notificationTypes = UIRemoteNotificationTypeNone; - - id badgeArg = [iosOptions objectForKey:@"badge"]; - id soundArg = [iosOptions objectForKey:@"sound"]; - id alertArg = [iosOptions objectForKey:@"alert"]; - id clearBadgeArg = [iosOptions objectForKey:@"clearBadge"]; - - if (([badgeArg isKindOfClass:[NSString class]] && [badgeArg isEqualToString:@"true"]) || [badgeArg boolValue]) - { - notificationTypes |= UIRemoteNotificationTypeBadge; -#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 80000 - UserNotificationTypes |= UIUserNotificationTypeBadge; -#endif - } - - if (([soundArg isKindOfClass:[NSString class]] && [soundArg isEqualToString:@"true"]) || [soundArg boolValue]) - { - notificationTypes |= UIRemoteNotificationTypeSound; -#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 80000 - UserNotificationTypes |= UIUserNotificationTypeSound; -#endif - } - - if (([alertArg isKindOfClass:[NSString class]] && [alertArg isEqualToString:@"true"]) || [alertArg boolValue]) - { - notificationTypes |= UIRemoteNotificationTypeAlert; -#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 80000 - UserNotificationTypes |= UIUserNotificationTypeAlert; -#endif - } - - notificationTypes |= UIRemoteNotificationTypeNewsstandContentAvailability; -#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 80000 - UserNotificationTypes |= UIUserNotificationActivationModeBackground; -#endif - - if (clearBadgeArg == nil || ([clearBadgeArg isKindOfClass:[NSString class]] && [clearBadgeArg isEqualToString:@"false"]) || ![clearBadgeArg boolValue]) { - NSLog(@"PushPlugin.register: setting badge to false"); - clearBadge = NO; - } else { - NSLog(@"PushPlugin.register: setting badge to true"); - clearBadge = YES; - [[UIApplication sharedApplication] setApplicationIconBadgeNumber:0]; - } - NSLog(@"PushPlugin.register: clear badge is set to %d", clearBadge); - - if (notificationTypes == UIRemoteNotificationTypeNone) - NSLog(@"PushPlugin.register: Push notification type is set to none"); - - isInline = NO; - -#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 80000 - NSLog(@"PushPlugin.register: better button setup"); - // setup action buttons - NSMutableSet *categories = [[NSMutableSet alloc] init]; - id categoryOptions = [iosOptions objectForKey:@"categories"]; - if (categoryOptions != nil && [categoryOptions isKindOfClass:[NSDictionary class]]) { - for (id key in categoryOptions) { - NSLog(@"categories: key %@", key); - id category = [categoryOptions objectForKey:key]; - - id yesButton = [category objectForKey:@"yes"]; - UIMutableUserNotificationAction *yesAction; - if (yesButton != nil && [yesButton isKindOfClass:[NSDictionary class]]) { - yesAction = [self createAction: yesButton]; - } - id noButton = [category objectForKey:@"no"]; - UIMutableUserNotificationAction *noAction; - if (noButton != nil && [noButton isKindOfClass:[NSDictionary class]]) { - noAction = [self createAction: noButton]; - } - id maybeButton = [category objectForKey:@"maybe"]; - UIMutableUserNotificationAction *maybeAction; - if (maybeButton != nil && [maybeButton isKindOfClass:[NSDictionary class]]) { - maybeAction = [self createAction: maybeButton]; - } - - // First create the category - UIMutableUserNotificationCategory *notificationCategory = [[UIMutableUserNotificationCategory alloc] init]; - - // Identifier to include in your push payload and local notification - notificationCategory.identifier = key; - - NSMutableArray *categoryArray = [[NSMutableArray alloc] init]; - NSMutableArray *minimalCategoryArray = [[NSMutableArray alloc] init]; - if (yesButton != nil) { - [categoryArray addObject:yesAction]; - [minimalCategoryArray addObject:yesAction]; - } - if (noButton != nil) { - [categoryArray addObject:noAction]; - [minimalCategoryArray addObject:noAction]; - } - if (maybeButton != nil) { - [categoryArray addObject:maybeAction]; - } - - // Add the actions to the category and set the action context - [notificationCategory setActions:categoryArray forContext:UIUserNotificationActionContextDefault]; - - // Set the actions to present in a minimal context - [notificationCategory setActions:minimalCategoryArray forContext:UIUserNotificationActionContextMinimal]; - - NSLog(@"Adding category %@", key); - [categories addObject:notificationCategory]; - } - - } -#else - NSLog(@"PushPlugin.register: action buttons only supported on iOS8 and above"); -#endif - - -#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 80000 - if ([[UIApplication sharedApplication]respondsToSelector:@selector(registerUserNotificationSettings:)]) { - UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:UserNotificationTypes categories:categories]; - [[UIApplication sharedApplication] registerUserNotificationSettings:settings]; - [[UIApplication sharedApplication] registerForRemoteNotifications]; - } else { - [[UIApplication sharedApplication] registerForRemoteNotificationTypes: - (UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert)]; - } -#else - [[UIApplication sharedApplication] registerForRemoteNotificationTypes: - (UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert)]; -#endif - - // GCM options - [self setGcmSenderId: [iosOptions objectForKey:@"senderID"]]; - NSLog(@"GCM Sender ID %@", gcmSenderId); - if([[self gcmSenderId] length] > 0) { - NSLog(@"Using GCM Notification"); - [self setUsesGCM: YES]; - [self initGCMRegistrationHandler]; - } else { - NSLog(@"Using APNS Notification"); - [self setUsesGCM:NO]; - } - id gcmSandBoxArg = [iosOptions objectForKey:@"gcmSandbox"]; - - [self setGcmSandbox:@NO]; - if ([self usesGCM] && - (([gcmSandBoxArg isKindOfClass:[NSString class]] && [gcmSandBoxArg isEqualToString:@"true"]) || - [gcmSandBoxArg boolValue])) - { - NSLog(@"Using GCM Sandbox"); - [self setGcmSandbox:@YES]; - } - - if (notificationMessage) { // if there is a pending startup notification - dispatch_async(dispatch_get_main_queue(), ^{ - // delay to allow JS event handlers to be setup - [self performSelector:@selector(notificationReceived) withObject:nil afterDelay: 0.5]; - }); - } - }]; -} - -- (UIMutableUserNotificationAction *)createAction:(NSDictionary *)dictionary { - - UIMutableUserNotificationAction *myAction = [[UIMutableUserNotificationAction alloc] init]; - - myAction = [[UIMutableUserNotificationAction alloc] init]; - myAction.identifier = [dictionary objectForKey:@"callback"]; - myAction.title = [dictionary objectForKey:@"title"]; - id mode =[dictionary objectForKey:@"foreground"]; - if (mode == nil || ([mode isKindOfClass:[NSString class]] && [mode isEqualToString:@"false"]) || ![mode boolValue]) { - myAction.activationMode = UIUserNotificationActivationModeBackground; - } else { - myAction.activationMode = UIUserNotificationActivationModeForeground; - } - id destructive = [dictionary objectForKey:@"destructive"]; - if (destructive == nil || ([destructive isKindOfClass:[NSString class]] && [destructive isEqualToString:@"false"]) || ![destructive boolValue]) { - myAction.destructive = NO; - } else { - myAction.destructive = YES; - } - myAction.authenticationRequired = NO; - - return myAction; -} - -- (void)didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken { - if (self.callbackId == nil) { - NSLog(@"Unexpected call to didRegisterForRemoteNotificationsWithDeviceToken, ignoring: %@", deviceToken); - return; - } - NSLog(@"Push Plugin register success: %@", deviceToken); - - NSMutableDictionary *results = [NSMutableDictionary dictionary]; - NSString *token = [[[[deviceToken description] stringByReplacingOccurrencesOfString:@"<"withString:@""] - stringByReplacingOccurrencesOfString:@">" withString:@""] - stringByReplacingOccurrencesOfString: @" " withString: @""]; - [results setValue:token forKey:@"deviceToken"]; - -#if !TARGET_IPHONE_SIMULATOR - // Get Bundle Info for Remote Registration (handy if you have more than one app) - [results setValue:[[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleDisplayName"] forKey:@"appName"]; - [results setValue:[[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"] forKey:@"appVersion"]; - - // Check what Notifications the user has turned on. We registered for all three, but they may have manually disabled some or all of them. -#define SYSTEM_VERSION_LESS_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedAscending) - - NSUInteger rntypes; - if (!SYSTEM_VERSION_LESS_THAN(@"8.0")) { - rntypes = [[[UIApplication sharedApplication] currentUserNotificationSettings] types]; - } else { - rntypes = [[UIApplication sharedApplication] enabledRemoteNotificationTypes]; - } - - // Set the defaults to disabled unless we find otherwise... - NSString *pushBadge = @"disabled"; - NSString *pushAlert = @"disabled"; - NSString *pushSound = @"disabled"; - - // Check what Registered Types are turned on. This is a bit tricky since if two are enabled, and one is off, it will return a number 2... not telling you which - // one is actually disabled. So we are literally checking to see if rnTypes matches what is turned on, instead of by number. The "tricky" part is that the - // single notification types will only match if they are the ONLY one enabled. Likewise, when we are checking for a pair of notifications, it will only be - // true if those two notifications are on. This is why the code is written this way - if(rntypes & UIRemoteNotificationTypeBadge){ - pushBadge = @"enabled"; - } - if(rntypes & UIRemoteNotificationTypeAlert) { - pushAlert = @"enabled"; - } - if(rntypes & UIRemoteNotificationTypeSound) { - pushSound = @"enabled"; - } - - [results setValue:pushBadge forKey:@"pushBadge"]; - [results setValue:pushAlert forKey:@"pushAlert"]; - [results setValue:pushSound forKey:@"pushSound"]; - - // Get the users Device Model, Display Name, Token & Version Number - UIDevice *dev = [UIDevice currentDevice]; - [results setValue:dev.name forKey:@"deviceName"]; - [results setValue:dev.model forKey:@"deviceModel"]; - [results setValue:dev.systemVersion forKey:@"deviceSystemVersion"]; - - if([self usesGCM]) { - GGLInstanceIDConfig *instanceIDConfig = [GGLInstanceIDConfig defaultConfig]; - instanceIDConfig.delegate = self; - [[GGLInstanceID sharedInstance] startWithConfig:instanceIDConfig]; - - [self setGcmRegistrationOptions: @{kGGLInstanceIDRegisterAPNSOption:deviceToken, - kGGLInstanceIDAPNSServerTypeSandboxOption:[self gcmSandbox]}]; - - [[GGLInstanceID sharedInstance] tokenWithAuthorizedEntity:[self gcmSenderId] - scope:kGGLInstanceIDScopeGCM - options:[self gcmRegistrationOptions] - handler:[self gcmRegistrationHandler]]; - - GCMConfig *gcmConfig = [GCMConfig defaultConfig]; - gcmConfig.receiverDelegate = self; - [[GCMService sharedInstance] startWithConfig:gcmConfig]; - - } else { - [self registerWithToken: token]; - } -#endif -} - -- (void)didFailToRegisterForRemoteNotificationsWithError:(NSError *)error -{ - if (self.callbackId == nil) { - NSLog(@"Unexpected call to didFailToRegisterForRemoteNotificationsWithError, ignoring: %@", error); - return; - } - NSLog(@"Push Plugin register failed"); - [self failWithMessage:self.callbackId withMsg:@"" withError:error]; -} - -- (void)notificationReceived { - NSLog(@"Notification received"); - - if (notificationMessage && self.callbackId != nil) - { - NSMutableDictionary* message = [NSMutableDictionary dictionaryWithCapacity:4]; - NSMutableDictionary* additionalData = [NSMutableDictionary dictionaryWithCapacity:4]; - - - for (id key in notificationMessage) { - if ([key isEqualToString:@"aps"]) { - id aps = [notificationMessage objectForKey:@"aps"]; - - for(id key in aps) { - NSLog(@"Push Plugin key: %@", key); - id value = [aps objectForKey:key]; - - if ([key isEqualToString:@"alert"]) { - if ([value isKindOfClass:[NSDictionary class]]) { - for (id messageKey in value) { - id messageValue = [value objectForKey:messageKey]; - if ([messageKey isEqualToString:@"body"]) { - [message setObject:messageValue forKey:@"message"]; - } else if ([messageKey isEqualToString:@"title"]) { - [message setObject:messageValue forKey:@"title"]; - } else { - [additionalData setObject:messageValue forKey:messageKey]; - } - } - } - else { - [message setObject:value forKey:@"message"]; - } - } else if ([key isEqualToString:@"title"]) { - [message setObject:value forKey:@"title"]; - } else if ([key isEqualToString:@"badge"]) { - [message setObject:value forKey:@"count"]; - } else if ([key isEqualToString:@"sound"]) { - [message setObject:value forKey:@"sound"]; - } else if ([key isEqualToString:@"image"]) { - [message setObject:value forKey:@"image"]; - } else { - [additionalData setObject:value forKey:key]; - } - } - } else { - [additionalData setObject:[notificationMessage objectForKey:key] forKey:key]; - } - } - - if (isInline) { - [additionalData setObject:[NSNumber numberWithBool:YES] forKey:@"foreground"]; - } else { - [additionalData setObject:[NSNumber numberWithBool:NO] forKey:@"foreground"]; - } - - if (coldstart) { - [additionalData setObject:[NSNumber numberWithBool:YES] forKey:@"coldstart"]; - } else { - [additionalData setObject:[NSNumber numberWithBool:NO] forKey:@"coldstart"]; - } - - [message setObject:additionalData forKey:@"additionalData"]; - - // send notification message - CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:message]; - [pluginResult setKeepCallbackAsBool:YES]; - [self.commandDelegate sendPluginResult:pluginResult callbackId:self.callbackId]; - - self.coldstart = NO; - self.notificationMessage = nil; - } -} - -- (void)setApplicationIconBadgeNumber:(CDVInvokedUrlCommand *)command -{ - NSMutableDictionary* options = [command.arguments objectAtIndex:0]; - int badge = [[options objectForKey:@"badge"] intValue] ?: 0; - - [[UIApplication sharedApplication] setApplicationIconBadgeNumber:badge]; - - NSString* message = [NSString stringWithFormat:@"app badge count set to %d", badge]; - CDVPluginResult *commandResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:message]; - [self.commandDelegate sendPluginResult:commandResult callbackId:command.callbackId]; -} - -- (void)getApplicationIconBadgeNumber:(CDVInvokedUrlCommand *)command -{ - NSInteger badge = [UIApplication sharedApplication].applicationIconBadgeNumber; - - CDVPluginResult *commandResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsInt:(int)badge]; - [self.commandDelegate sendPluginResult:commandResult callbackId:command.callbackId]; -} - -- (void)clearAllNotifications:(CDVInvokedUrlCommand *)command -{ - [[UIApplication sharedApplication] setApplicationIconBadgeNumber:0]; - - NSString* message = [NSString stringWithFormat:@"cleared all notifications"]; - CDVPluginResult *commandResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:message]; - [self.commandDelegate sendPluginResult:commandResult callbackId:command.callbackId]; -} - -- (void)hasPermission:(CDVInvokedUrlCommand *)command -{ - BOOL enabled = NO; - id<UIApplicationDelegate> appDelegate = [UIApplication sharedApplication].delegate; - if ([appDelegate respondsToSelector:@selector(userHasRemoteNotificationsEnabled)]) { - enabled = [appDelegate performSelector:@selector(userHasRemoteNotificationsEnabled)]; - } - - NSMutableDictionary* message = [NSMutableDictionary dictionaryWithCapacity:1]; - [message setObject:[NSNumber numberWithBool:enabled] forKey:@"isEnabled"]; - CDVPluginResult *commandResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:message]; - [self.commandDelegate sendPluginResult:commandResult callbackId:command.callbackId]; -} - --(void)successWithMessage:(NSString *)callbackId withMsg:(NSString *)message -{ - if (callbackId != nil) - { - CDVPluginResult *commandResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:message]; - [self.commandDelegate sendPluginResult:commandResult callbackId:callbackId]; - } -} - --(void)registerWithToken:(NSString*)token; { - // Send result to trigger 'registration' event but keep callback - NSMutableDictionary* message = [NSMutableDictionary dictionaryWithCapacity:1]; - [message setObject:token forKey:@"registrationId"]; - CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:message]; - [pluginResult setKeepCallbackAsBool:YES]; - [self.commandDelegate sendPluginResult:pluginResult callbackId:self.callbackId]; -} - - --(void)failWithMessage:(NSString *)callbackId withMsg:(NSString *)message withError:(NSError *)error -{ - NSString *errorMessage = (error) ? [NSString stringWithFormat:@"%@ - %@", message, [error localizedDescription]] : message; - CDVPluginResult *commandResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:errorMessage]; - - [self.commandDelegate sendPluginResult:commandResult callbackId:callbackId]; -} - --(void) finish:(CDVInvokedUrlCommand*)command -{ - NSLog(@"Push Plugin finish called"); - - [self.commandDelegate runInBackground:^ { - NSString* notId = [command.arguments objectAtIndex:0]; - - dispatch_async(dispatch_get_main_queue(), ^{ - [NSTimer scheduledTimerWithTimeInterval:0.1 - target:self - selector:@selector(stopBackgroundTask:) - userInfo:notId - repeats:NO]; - }); - - CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK]; - [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId]; - }]; -} - --(void)stopBackgroundTask:(NSTimer*)timer -{ - UIApplication *app = [UIApplication sharedApplication]; - - NSLog(@"Push Plugin stopBackgroundTask called"); - - if (handlerObj) { - NSLog(@"Push Plugin handlerObj"); - completionHandler = [handlerObj[[timer userInfo]] copy]; - if (completionHandler) { - NSLog(@"Push Plugin: stopBackgroundTask (remaining t: %f)", app.backgroundTimeRemaining); - completionHandler(UIBackgroundFetchResultNewData); - completionHandler = nil; - } - } -} - -@end diff --git a/StoneIsland/plugins/phonegap-plugin-push/src/windows/PushPluginProxy.js b/StoneIsland/plugins/phonegap-plugin-push/src/windows/PushPluginProxy.js deleted file mode 100644 index ac04f39d..00000000 --- a/StoneIsland/plugins/phonegap-plugin-push/src/windows/PushPluginProxy.js +++ /dev/null @@ -1,93 +0,0 @@ -var myApp = {}; -var pushNotifications = Windows.Networking.PushNotifications; - -var createNotificationJSON = function (e) { - var result = { message: '' }; //Added to identify callback as notification type in the API in case where notification has no message - var notificationPayload; - - switch (e.notificationType) { - case pushNotifications.PushNotificationType.toast: - case pushNotifications.PushNotificationType.tile: - if (e.notificationType === pushNotifications.PushNotificationType.toast) { - notificationPayload = e.toastNotification.content; - } - else { - notificationPayload = e.tileNotification.content; - } - var texts = notificationPayload.getElementsByTagName("text"); - if (texts.length > 1) { - result.title = texts[0].innerText; - result.message = texts[1].innerText; - } - else if(texts.length === 1) { - result.message = texts[0].innerText; - } - var images = notificationPayload.getElementsByTagName("image"); - if (images.length > 0) { - result.image = images[0].getAttribute("src"); - } - var soundFile = notificationPayload.getElementsByTagName("audio"); - if (soundFile.length > 0) { - result.sound = soundFile[0].getAttribute("src"); - } - break; - - case pushNotifications.PushNotificationType.badge: - notificationPayload = e.badgeNotification.content; - result.count = notificationPayload.getElementsByTagName("badge")[0].getAttribute("value"); - break; - - case pushNotifications.PushNotificationType.raw: - result.message = e.rawNotification.content; - break; - } - - result.additionalData = { coldstart: false }; // this gets called only when the app is running - result.additionalData.pushNotificationReceivedEventArgs = e; - return result; -} - -module.exports = { - init: function (onSuccess, onFail, args) { - - var onNotificationReceived = function (e) { - var result = createNotificationJSON(e); - onSuccess(result, { keepCallback: true }); - } - - try { - pushNotifications.PushNotificationChannelManager.createPushNotificationChannelForApplicationAsync().done( - function (channel) { - var result = {}; - result.registrationId = channel.uri; - myApp.channel = channel; - channel.addEventListener("pushnotificationreceived", onNotificationReceived); - myApp.notificationEvent = onNotificationReceived; - onSuccess(result, { keepCallback: true }); - - var context = cordova.require('cordova/platform').activationContext; - var launchArgs = context ? context.args : null; - if (launchArgs) { //If present, app launched through push notification - var result = { message: '' }; //Added to identify callback as notification type in the API - result.launchArgs = launchArgs; - result.additionalData = { coldstart: true }; - onSuccess(result, { keepCallback: true }); - } - }, function (error) { - onFail(error); - }); - } catch (ex) { - onFail(ex); - } - }, - unregister: function (onSuccess, onFail, args) { - try { - myApp.channel.removeEventListener("pushnotificationreceived", myApp.notificationEvent); - myApp.channel.close(); - onSuccess(); - } catch(ex) { - onFail(ex); - } - } -}; -require("cordova/exec/proxy").add("PushNotification", module.exports); diff --git a/StoneIsland/plugins/phonegap-plugin-push/www/browser/push.js b/StoneIsland/plugins/phonegap-plugin-push/www/browser/push.js deleted file mode 100644 index 9b74d8a4..00000000 --- a/StoneIsland/plugins/phonegap-plugin-push/www/browser/push.js +++ /dev/null @@ -1,357 +0,0 @@ -/* global cordova:false */ -/* globals window, document, navigator */ - -/*! - * Module dependencies. - */ - -var exec = cordova.require('cordova/exec'); - -/** - * PushNotification constructor. - * - * @param {Object} options to initiate Push Notifications. - * @return {PushNotification} instance that can be monitored and cancelled. - */ -var serviceWorker, subscription; -var PushNotification = function(options) { - this._handlers = { - 'registration': [], - 'notification': [], - 'error': [] - }; - - // require options parameter - if (typeof options === 'undefined') { - throw new Error('The options argument is required.'); - } - - // store the options to this object instance - this.options = options; - - // triggered on registration and notification - var that = this; - - // Add manifest.json to main HTML file - var linkElement = document.createElement('link'); - linkElement.rel = 'manifest'; - linkElement.href = 'manifest.json'; - document.getElementsByTagName('head')[0].appendChild(linkElement); - - if ('serviceWorker' in navigator && 'MessageChannel' in window) { - var result; - var channel = new MessageChannel(); - channel.port1.onmessage = function(event) { - that.emit('notification', event.data); - }; - - navigator.serviceWorker.register('ServiceWorker.js').then(function() { - return navigator.serviceWorker.ready; - }) - .then(function(reg) { - serviceWorker = reg; - reg.pushManager.subscribe({userVisibleOnly: true}).then(function(sub) { - subscription = sub; - result = { 'registrationId': sub.endpoint.substring(sub.endpoint.lastIndexOf('/') + 1) }; - that.emit('registration', result); - - // send encryption keys to push server - var xmlHttp = new XMLHttpRequest(); - var xmlURL = (options.browser.pushServiceURL || 'http://push.api.phonegap.com/v1/push') + '/keys'; - xmlHttp.open('POST', xmlURL, true); - - var formData = new FormData(); - formData.append('subscription', JSON.stringify(sub)); - - xmlHttp.send(formData); - - navigator.serviceWorker.controller.postMessage(result, [channel.port2]); - }).catch(function(error) { - if (navigator.serviceWorker.controller === null) { - // When you first register a SW, need a page reload to handle network operations - window.location.reload(); - return; - } - - throw new Error('Error subscribing for Push notifications.'); - }); - }).catch(function(error) { - console.log(error); - throw new Error('Error registering Service Worker'); - }); - } else { - throw new Error('Service Workers are not supported on your browser.'); - } -}; - -/** - * Unregister from push notifications - */ - -PushNotification.prototype.unregister = function(successCallback, errorCallback, options) { - if (!errorCallback) { errorCallback = function() {}; } - - if (typeof errorCallback !== 'function') { - console.log('PushNotification.unregister failure: failure parameter not a function'); - return; - } - - if (typeof successCallback !== 'function') { - console.log('PushNotification.unregister failure: success callback parameter must be a function'); - return; - } - - var that = this; - if (!options) { - that._handlers = { - 'registration': [], - 'notification': [], - 'error': [] - }; - } - - if (serviceWorker) { - serviceWorker.unregister().then(function(isSuccess) { - if (isSuccess) { - var deviceID = subscription.endpoint.substring(subscription.endpoint.lastIndexOf('/') + 1); - var xmlHttp = new XMLHttpRequest(); - var xmlURL = (that.options.browser.pushServiceURL || 'http://push.api.phonegap.com/v1/push') - + '/keys/' + deviceID; - xmlHttp.open('DELETE', xmlURL, true); - xmlHttp.send(); - - successCallback(); - } else { - errorCallback(); - } - }); - } -}; - -/** - * subscribe to a topic - * @param {String} topic topic to subscribe - * @param {Function} successCallback success callback - * @param {Function} errorCallback error callback - * @return {void} - */ -PushNotification.prototype.subscribe = function(topic, successCallback, errorCallback) { - if (!errorCallback) { errorCallback = function() {}; } - - if (typeof errorCallback !== 'function') { - console.log('PushNotification.subscribe failure: failure parameter not a function'); - return; - } - - if (typeof successCallback !== 'function') { - console.log('PushNotification.subscribe failure: success callback parameter must be a function'); - return; - } - - successCallback(); -}; - -/** - * unsubscribe to a topic - * @param {String} topic topic to unsubscribe - * @param {Function} successCallback success callback - * @param {Function} errorCallback error callback - * @return {void} - */ -PushNotification.prototype.unsubscribe = function(topic, successCallback, errorCallback) { - if (!errorCallback) { errorCallback = function() {}; } - - if (typeof errorCallback !== 'function') { - console.log('PushNotification.unsubscribe failure: failure parameter not a function'); - return; - } - - if (typeof successCallback !== 'function') { - console.log('PushNotification.unsubscribe failure: success callback parameter must be a function'); - return; - } - - successCallback(); -}; - -/** - * Call this to set the application icon badge - */ - -PushNotification.prototype.setApplicationIconBadgeNumber = function(successCallback, errorCallback, badge) { - if (!errorCallback) { errorCallback = function() {}; } - - if (typeof errorCallback !== 'function') { - console.log('PushNotification.setApplicationIconBadgeNumber failure: failure parameter not a function'); - return; - } - - if (typeof successCallback !== 'function') { - console.log('PushNotification.setApplicationIconBadgeNumber failure: success callback parameter must be a function'); - return; - } - - successCallback(); -}; - -/** - * Get the application icon badge - */ - -PushNotification.prototype.getApplicationIconBadgeNumber = function(successCallback, errorCallback) { - if (!errorCallback) { errorCallback = function() {}; } - - if (typeof errorCallback !== 'function') { - console.log('PushNotification.getApplicationIconBadgeNumber failure: failure parameter not a function'); - return; - } - - if (typeof successCallback !== 'function') { - console.log('PushNotification.getApplicationIconBadgeNumber failure: success callback parameter must be a function'); - return; - } - - successCallback(); -}; - -/** - * Get the application icon badge - */ - -PushNotification.prototype.clearAllNotifications = function(successCallback, errorCallback) { - if (!errorCallback) { errorCallback = function() {}; } - - if (typeof errorCallback !== 'function') { - console.log('PushNotification.clearAllNotifications failure: failure parameter not a function'); - return; - } - - if (typeof successCallback !== 'function') { - console.log('PushNotification.clearAllNotifications failure: success callback parameter must be a function'); - return; - } - - successCallback(); -}; - -/** - * Listen for an event. - * - * The following events are supported: - * - * - registration - * - notification - * - error - * - * @param {String} eventName to subscribe to. - * @param {Function} callback triggered on the event. - */ - -PushNotification.prototype.on = function(eventName, callback) { - if (this._handlers.hasOwnProperty(eventName)) { - this._handlers[eventName].push(callback); - } -}; - -/** - * Remove event listener. - * - * @param {String} eventName to match subscription. - * @param {Function} handle function associated with event. - */ - -PushNotification.prototype.off = function (eventName, handle) { - if (this._handlers.hasOwnProperty(eventName)) { - var handleIndex = this._handlers[eventName].indexOf(handle); - if (handleIndex >= 0) { - this._handlers[eventName].splice(handleIndex, 1); - } - } -}; - -/** - * Emit an event. - * - * This is intended for internal use only. - * - * @param {String} eventName is the event to trigger. - * @param {*} all arguments are passed to the event listeners. - * - * @return {Boolean} is true when the event is triggered otherwise false. - */ - -PushNotification.prototype.emit = function() { - var args = Array.prototype.slice.call(arguments); - var eventName = args.shift(); - - if (!this._handlers.hasOwnProperty(eventName)) { - return false; - } - - for (var i = 0, length = this._handlers[eventName].length; i < length; i++) { - var callback = this._handlers[eventName][i]; - if (typeof callback === 'function') { - callback.apply(undefined,args); - } else { - console.log('event handler: ' + eventName + ' must be a function'); - } - } - - return true; -}; - -PushNotification.prototype.finish = function(successCallback, errorCallback, id) { - if (!successCallback) { successCallback = function() {}; } - if (!errorCallback) { errorCallback = function() {}; } - if (!id) { id = 'handler'; } - - if (typeof successCallback !== 'function') { - console.log('finish failure: success callback parameter must be a function'); - return; - } - - if (typeof errorCallback !== 'function') { - console.log('finish failure: failure parameter not a function'); - return; - } - - successCallback(); -}; - -/*! - * Push Notification Plugin. - */ - -module.exports = { - /** - * Register for Push Notifications. - * - * This method will instantiate a new copy of the PushNotification object - * and start the registration process. - * - * @param {Object} options - * @return {PushNotification} instance - */ - - init: function(options) { - return new PushNotification(options); - }, - - hasPermission: function(successCallback, errorCallback) { - successCallback(true); - }, - - unregister: function(successCallback, errorCallback, options) { - PushNotification.unregister(successCallback, errorCallback, options); - }, - - /** - * PushNotification Object. - * - * Expose the PushNotification object for direct use - * and testing. Typically, you should use the - * .init helper method. - */ - - PushNotification: PushNotification -}; diff --git a/StoneIsland/plugins/phonegap-plugin-push/www/push.js b/StoneIsland/plugins/phonegap-plugin-push/www/push.js deleted file mode 100644 index 58c686d3..00000000 --- a/StoneIsland/plugins/phonegap-plugin-push/www/push.js +++ /dev/null @@ -1,326 +0,0 @@ -/* global cordova:false */ -/* globals window */ - -/*! - * Module dependencies. - */ - -var exec = cordova.require('cordova/exec'); - -/** - * PushNotification constructor. - * - * @param {Object} options to initiate Push Notifications. - * @return {PushNotification} instance that can be monitored and cancelled. - */ - -var PushNotification = function(options) { - this._handlers = { - 'registration': [], - 'notification': [], - 'error': [] - }; - - // require options parameter - if (typeof options === 'undefined') { - throw new Error('The options argument is required.'); - } - - // store the options to this object instance - this.options = options; - - // triggered on registration and notification - var that = this; - var success = function(result) { - if (result && typeof result.registrationId !== 'undefined') { - that.emit('registration', result); - } else if (result && result.additionalData && typeof result.additionalData.actionCallback !== 'undefined') { - var executeFuctionOrEmitEventByName = function(callbackName, context, arg) { - var namespaces = callbackName.split('.'); - var func = namespaces.pop(); - for (var i = 0; i < namespaces.length; i++) { - context = context[namespaces[i]]; - } - - if (typeof context[func] === 'function') { - context[func].call(context, arg); - } else { - that.emit(callbackName, arg); - } - }; - - executeFuctionOrEmitEventByName(result.additionalData.actionCallback, window, result); - } else if (result) { - that.emit('notification', result); - } - }; - - // triggered on error - var fail = function(msg) { - var e = (typeof msg === 'string') ? new Error(msg) : msg; - that.emit('error', e); - }; - - // wait at least one process tick to allow event subscriptions - setTimeout(function() { - exec(success, fail, 'PushNotification', 'init', [options]); - }, 10); -}; - -/** - * Unregister from push notifications - */ - -PushNotification.prototype.unregister = function(successCallback, errorCallback, options) { - if (!errorCallback) { errorCallback = function() {}; } - - if (typeof errorCallback !== 'function') { - console.log('PushNotification.unregister failure: failure parameter not a function'); - return; - } - - if (typeof successCallback !== 'function') { - console.log('PushNotification.unregister failure: success callback parameter must be a function'); - return; - } - - var that = this; - var cleanHandlersAndPassThrough = function() { - if (!options) { - that._handlers = { - 'registration': [], - 'notification': [], - 'error': [] - }; - } - successCallback(); - }; - - exec(cleanHandlersAndPassThrough, errorCallback, 'PushNotification', 'unregister', [options]); -}; - -/** - * subscribe to a topic - * @param {String} topic topic to subscribe - * @param {Function} successCallback success callback - * @param {Function} errorCallback error callback - * @return {void} - */ -PushNotification.prototype.subscribe = function(topic, successCallback, errorCallback) { - if (!errorCallback) { errorCallback = function() {}; } - - if (typeof errorCallback !== 'function') { - console.log('PushNotification.subscribe failure: failure parameter not a function'); - return; - } - - if (typeof successCallback !== 'function') { - console.log('PushNotification.subscribe failure: success callback parameter must be a function'); - return; - } - - exec(successCallback, errorCallback, 'PushNotification', 'subscribe', [topic]); -}; - -/** - * unsubscribe to a topic - * @param {String} topic topic to unsubscribe - * @param {Function} successCallback success callback - * @param {Function} errorCallback error callback - * @return {void} - */ -PushNotification.prototype.unsubscribe = function(topic, successCallback, errorCallback) { - if (!errorCallback) { errorCallback = function() {}; } - - if (typeof errorCallback !== 'function') { - console.log('PushNotification.unsubscribe failure: failure parameter not a function'); - return; - } - - if (typeof successCallback !== 'function') { - console.log('PushNotification.unsubscribe failure: success callback parameter must be a function'); - return; - } - - exec(successCallback, errorCallback, 'PushNotification', 'unsubscribe', [topic]); -}; - -/** - * Call this to set the application icon badge - */ - -PushNotification.prototype.setApplicationIconBadgeNumber = function(successCallback, errorCallback, badge) { - if (!errorCallback) { errorCallback = function() {}; } - - if (typeof errorCallback !== 'function') { - console.log('PushNotification.setApplicationIconBadgeNumber failure: failure parameter not a function'); - return; - } - - if (typeof successCallback !== 'function') { - console.log('PushNotification.setApplicationIconBadgeNumber failure: success callback parameter must be a function'); - return; - } - - exec(successCallback, errorCallback, 'PushNotification', 'setApplicationIconBadgeNumber', [{badge: badge}]); -}; - -/** - * Get the application icon badge - */ - -PushNotification.prototype.getApplicationIconBadgeNumber = function(successCallback, errorCallback) { - if (!errorCallback) { errorCallback = function() {}; } - - if (typeof errorCallback !== 'function') { - console.log('PushNotification.getApplicationIconBadgeNumber failure: failure parameter not a function'); - return; - } - - if (typeof successCallback !== 'function') { - console.log('PushNotification.getApplicationIconBadgeNumber failure: success callback parameter must be a function'); - return; - } - - exec(successCallback, errorCallback, 'PushNotification', 'getApplicationIconBadgeNumber', []); -}; - -/** - * Get the application icon badge - */ - -PushNotification.prototype.clearAllNotifications = function(successCallback, errorCallback) { - if (!successCallback) { successCallback = function() {}; } - if (!errorCallback) { errorCallback = function() {}; } - - if (typeof errorCallback !== 'function') { - console.log('PushNotification.clearAllNotifications failure: failure parameter not a function'); - return; - } - - if (typeof successCallback !== 'function') { - console.log('PushNotification.clearAllNotifications failure: success callback parameter must be a function'); - return; - } - - exec(successCallback, errorCallback, 'PushNotification', 'clearAllNotifications', []); -}; - -/** - * Listen for an event. - * - * Any event is supported, but the following are built-in: - * - * - registration - * - notification - * - error - * - * @param {String} eventName to subscribe to. - * @param {Function} callback triggered on the event. - */ - -PushNotification.prototype.on = function(eventName, callback) { - if (!this._handlers.hasOwnProperty(eventName)) { - this._handlers[eventName] = []; - } - this._handlers[eventName].push(callback); -}; - -/** - * Remove event listener. - * - * @param {String} eventName to match subscription. - * @param {Function} handle function associated with event. - */ - -PushNotification.prototype.off = function (eventName, handle) { - if (this._handlers.hasOwnProperty(eventName)) { - var handleIndex = this._handlers[eventName].indexOf(handle); - if (handleIndex >= 0) { - this._handlers[eventName].splice(handleIndex, 1); - } - } -}; - -/** - * Emit an event. - * - * This is intended for internal use only. - * - * @param {String} eventName is the event to trigger. - * @param {*} all arguments are passed to the event listeners. - * - * @return {Boolean} is true when the event is triggered otherwise false. - */ - -PushNotification.prototype.emit = function() { - var args = Array.prototype.slice.call(arguments); - var eventName = args.shift(); - - if (!this._handlers.hasOwnProperty(eventName)) { - return false; - } - - for (var i = 0, length = this._handlers[eventName].length; i < length; i++) { - var callback = this._handlers[eventName][i]; - if (typeof callback === 'function') { - callback.apply(undefined,args); - } else { - console.log('event handler: ' + eventName + ' must be a function'); - } - } - - return true; -}; - -PushNotification.prototype.finish = function(successCallback, errorCallback, id) { - if (!successCallback) { successCallback = function() {}; } - if (!errorCallback) { errorCallback = function() {}; } - if (!id) { id = 'handler'; } - - if (typeof successCallback !== 'function') { - console.log('finish failure: success callback parameter must be a function'); - return; - } - - if (typeof errorCallback !== 'function') { - console.log('finish failure: failure parameter not a function'); - return; - } - - exec(successCallback, errorCallback, 'PushNotification', 'finish', [id]); -}; - -/*! - * Push Notification Plugin. - */ - -module.exports = { - /** - * Register for Push Notifications. - * - * This method will instantiate a new copy of the PushNotification object - * and start the registration process. - * - * @param {Object} options - * @return {PushNotification} instance - */ - - init: function(options) { - return new PushNotification(options); - }, - - hasPermission: function(successCallback, errorCallback) { - exec(successCallback, errorCallback, 'PushNotification', 'hasPermission', []); - }, - - /** - * PushNotification Object. - * - * Expose the PushNotification object for direct use - * and testing. Typically, you should use the - * .init helper method. - */ - - PushNotification: PushNotification -}; |
