diff --git a/.babelrc b/.babelrc
new file mode 100644
index 000000000..7c195a007
--- /dev/null
+++ b/.babelrc
@@ -0,0 +1,18 @@
+{
+ "presets": [
+ "es2015"
+ ],
+ "plugins": [
+ ["add-header-comment", {
+ "files": {
+ "src/js/push.js": {
+ "header": [
+ "This file has been generated by Babel.\n",
+ "DO NOT EDIT IT DIRECTLY\n",
+ "Edit the JS source file src/js/push.js"
+ ]
+ }
+ }
+ }]
+ ]
+}
diff --git a/.editorconfig b/.editorconfig
index e640cd712..b1b1afa9b 100644
--- a/.editorconfig
+++ b/.editorconfig
@@ -6,7 +6,7 @@ root = true
[*]
charset = utf-8
end_of_line = lf
-indent_size = 4
+indent_size = 2
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true
diff --git a/.eslintrc b/.eslintrc
new file mode 100644
index 000000000..19511ef9c
--- /dev/null
+++ b/.eslintrc
@@ -0,0 +1,17 @@
+{
+ "extends": "airbnb",
+ "parser": "babel-eslint",
+ "ecmaFeatures": {
+ "experimentalObjectRestSpread": true
+ },
+ "rules": {
+ "spaced-comment": 0,
+ "no-console": 0,
+ "no-unused-expressions": [2, { "allowShortCircuit": true }]
+ },
+ "env": {
+ "node": true,
+ "mocha": true,
+ "browser": true
+ }
+}
diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md
index d02ad9a0b..013bc63b7 100644
--- a/.github/CONTRIBUTING.md
+++ b/.github/CONTRIBUTING.md
@@ -41,33 +41,33 @@ git commit -m "Cool stuff"
```
Consider starting the commit message with an applicable emoji:
- * :art: `:art:` when improving the format/structure of the code
- * :zap: `:zap:` when improving performance
- * :non-potable_water: `:non-potable_water:` when plugging memory leaks
- * :memo: `:memo:` when writing docs
- * :ambulance: `:ambulance:` a critical hotfix.
- * :sparkles: `:sparkles:` when introducing new features
- * :bookmark: `:bookmark:` when releasing / version tags
- * :rocket: `:rocket:` when deploying stuff
- * :penguin: `:penguin:` when fixing something on Android
- * :apple: `:apple:` when fixing something on iOS
- * :checkered_flag: `:checkered_flag:` when fixing something on Windows
- * :bug: `:bug:` when fixing a bug
- * :fire: `:fire:` when removing code or files
- * :green_heart: `:green_heart:` when fixing the CI build
- * :white_check_mark: `:white_check_mark:` when adding tests
- * :lock: `:lock:` when dealing with security
- * :arrow_up: `:arrow_up:` when upgrading dependencies
- * :arrow_down: `:arrow_down:` when downgrading dependencies
- * :shirt: `:shirt:` when removing linter warnings
- * :hammer: `:hammer:` when doing heavy refactoring
- * :heavy_minus_sign: `:heavy_minus_sign:` when removing a dependency.
- * :heavy_plus_sign: `:heavy_plus_sign:` when adding a dependency.
- * :wrench: `:wrench:` when changing configuration files.
- * :globe_with_meridians: `:globe_with_meridians:` when dealing with internationalization and localization.
- * :pencil2: `:pencil2:` when fixing typos.
- * :hankey: `:hankey:` when writing bad code that needs to be improved.
- * :package: `:package:` when updating compiled files or packages.
+* :art: `:art:` when improving the format/structure of the code
+* :zap: `:zap:` when improving performance
+* :non-potable_water: `:non-potable_water:` when plugging memory leaks
+* :memo: `:memo:` when writing docs
+* :ambulance: `:ambulance:` a critical hotfix.
+* :sparkles: `:sparkles:` when introducing new features
+* :bookmark: `:bookmark:` when releasing / version tags
+* :rocket: `:rocket:` when deploying stuff
+* :penguin: `:penguin:` when fixing something on Android
+* :apple: `:apple:` when fixing something on iOS
+* :checkered_flag: `:checkered_flag:` when fixing something on Windows
+* :bug: `:bug:` when fixing a bug
+* :fire: `:fire:` when removing code or files
+* :green_heart: `:green_heart:` when fixing the CI build
+* :white_check_mark: `:white_check_mark:` when adding tests
+* :lock: `:lock:` when dealing with security
+* :arrow_up: `:arrow_up:` when upgrading dependencies
+* :arrow_down: `:arrow_down:` when downgrading dependencies
+* :shirt: `:shirt:` when removing linter warnings
+* :hammer: `:hammer:` when doing heavy refactoring
+* :heavy_minus_sign: `:heavy_minus_sign:` when removing a dependency.
+* :heavy_plus_sign: `:heavy_plus_sign:` when adding a dependency.
+* :wrench: `:wrench:` when changing configuration files.
+* :globe_with_meridians: `:globe_with_meridians:` when dealing with internationalization and localization.
+* :pencil2: `:pencil2:` when fixing typos.
+* :hankey: `:hankey:` when writing bad code that needs to be improved.
+* :package: `:package:` when updating compiled files or packages.
Make sure your branch is up to date with the original repo:
@@ -100,23 +100,8 @@ The project uses [.editorconfig](http://editorconfig.org/) to define the coding
style of each file. We recommend that you install the Editor Config extension
for your preferred IDE. Consistency is key.
-## JSHint
+## ESLint
-The project uses [.jshint](http://jshint.com/docs) to define the JavaScript
-coding conventions. Most editors now have a JSHint add-on to provide on-save
+The project uses [.eslint](http://eslint.org/) to define the JavaScript
+coding conventions. Most editors now have a ESLint add-on to provide on-save
or on-edit linting.
-
-### Install JSHint for vim
-
-1. Install [jshint](https://www.npmjs.com/package/jshint).
-1. Install [jshint.vim](https://github.com/wookiehangover/jshint.vim).
-
-### Install JSHint for Sublime
-
-1. Install [Package Control](https://packagecontrol.io/installation)
-1. Restart Sublime
-1. Type `CMD+SHIFT+P`
-1. Type _Install Package_
-1. Type _JSHint Gutter_
-1. Sublime -> Preferences -> Package Settings -> JSHint Gutter
-1. Set `lint_on_load` and `lint_on_save` to `true`
diff --git a/.gitignore b/.gitignore
index 40348f107..075a7a971 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,3 +3,4 @@
.DS_Store
/node_modules/
npm-debug.log
+.tern-project
diff --git a/.jshintrc b/.jshintrc
deleted file mode 100644
index fe628be48..000000000
--- a/.jshintrc
+++ /dev/null
@@ -1,30 +0,0 @@
-{
- "asi": false,
- "boss": false,
- "camelcase": true,
- "curly": true,
- "eqeqeq": true,
- "eqnull": false,
- "es5": false,
- "evil": false,
- "expr": false,
- "forin": true,
- "funcscope": false,
- "jasmine": true,
- "immed": true,
- "indent": 4,
- "latedef": true,
- "loopfunc": false,
- "maxerr": 7,
- "newcap": true,
- "node": true,
- "nonew": true,
- "plusplus": false,
- "quotmark": "single",
- "shadow": false,
- "strict": false,
- "supernew": false,
- "trailing": true,
- "undef": true,
- "white": true
-}
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 6be587a33..d43750e62 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -13,6 +13,226 @@
- :memo: Fix PAYLOAD.md regarding "drawable" directory name (#1711) [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/a27a62d6e346b1e61ffe2ffaae482461cf970c03)
- Updating CHANGELOG [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/cfad83fa420df5ba4ac12f2f3f7fa68fdb22cc03)
+## [v2.0.0-rc3](https://github.com/phonegap/phonegap-plugin-push/tree/v2.0.0-rc3) (2017-05-09)
+[Full Changelog](https://github.com/phonegap/phonegap-plugin-push/compare/v2.0.0-rc2...v2.0.0-rc3)
+
+- 2.0.0-rc3 [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/b393a9d932aee66da277b404c2475cb77195d8d8)
+- :bookmark: Bumping plugin version to 2.0.0-rc3 [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/8003110d0757107ad211cd0e0b9c175e60dcd7ed)
+- :package: update www/push.js [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/c0a3a4c6d578b2ee14a82f167934ecc8a7672557)
+- :wrench: Update cordovaDependencies [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/969d546c3dc96efb59a226ee5df38de6e66e4de4)
+- Bump requirements [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/85e6419cbad124eaa3eac1c1c515aa684ccf4393)
+- Add resource-file way of copying google services files [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/46ba2745f0ebc08cc3b12f9c51177247130b592c)
+- Merge branch 'v2.0.x' of https://github.com/phonegap/phonegap-plugin-push into v2.0.x [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/a5c9e456ce333b3387b2e4412248cdf45d26334c)
+- Fixing package.json from failed merge/rebase. [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/974d2e218bcc8ab8ebf779ef18df74622702eb0e)
+- Remove hook and use resource-file tag to copy google services file [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/86763c7f2cc15eae39972e4137813edb5cd8b838)
+- Bumping plugin version to 2.0.0-rc2 [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/9850b1b180c3b66f64edc1680d358a7b1df58b95)
+- :bookmark: Bumping plugin version to 2.0.0-rc1 [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/15a68ed070d611f0569c90adaa062099120a7817)
+- :wrench: add tern to gitignore [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/784b7355a62490a5ce6229292213e22e671873c8)
+- :hammer::wrench::arrow_up: Use Babel to transpile ES2015 code [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/9b9df30cf65a275c0d4727a2854b12792ec905a2)
+- :bug: Issue #1188: Strings.xml google_app_id conflict with google-services.json [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/620af90cdda85f64aa65cc0fc0de051cb13980ba)
+- Issue #689: Remove sender id from PushNotification init iOS options [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/ee9ecc957d8961e2a0ae884f55ee5abc71652885)
+- Issue #689: Remove sender id from PushNotification init Android options [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/c7545607bb23ea801f7a167d3408b112e4a6e812)
+- Fix rebase errors [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/2ac7442de047ecedf4a6d2c66591889e14bdafc4)
+- Use CocoaPods [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/5c2fc51055343467e51f6facbd690e71273cbac2)
+- fixed registration and removed unused code [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/d1b4f51fb2cd6e9ee8447fee0ce4a5e9eba0a52d)
+- Added hook and resource file to copy GoogleService-Info.plist [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/0169587f198d0b44a06f408d803bbdac0fb1d079)
+- Changed code to work with FCM [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/38bd3581663ccd85b2daed7b9833571a4adbc99e)
+- Removed GCM files and added FCM files [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/9d5dbb196763e399d5177c0d4802ecc043cfc270)
+- Added partial Android FCM support (#975) [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/24f0a77bac10e0d8e4ff837a165a3d69c3447601)
+- Updating CHANGELOG [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/2535a189caddba2a41f9e002930541c55360047d)
+- 2.0.0-rc2 [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/8aa6f717db7dd534c97ad559307d391788e13e47)
+- Bumping plugin version to 2.0.0-rc2 [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/740cfe2bda63548a0e9cbf62b1833a4945eb432f)
+- :apple::bug: Issue #1497: App crashes after refreshing when using FCM (v2) [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/704b3635764700d5fc06f2e9c8c6a657ea4b7f29)
+- :pencil2: fixing error in CHANGELOG [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/68b045e6e40cdf1d5b9ed84136bebdf5f7874b8a)
+- :memo: Using a newer version on the examples [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/d8c4d002e4b6c6b399e5c5e5456012a121ee7b20)
+- :penguin::memo::bug: Issue #1470: Cannot install phonegap-plugin-push on master [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/632a4f1d87ff306bbc8920133e96b84125e44468)
+- :bug::apple::wrench: Fixing a merge issue where aps-environment was accidentally removed [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/4fb78566b5ebbbf2f04268b91f9c8cbc7193601e)
+- :bug::penguin::memo::arrow_up: #1460: Build Issue Android [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/e93f04a87763a762d581a18439b2de808fc81a2c)
+- :bug::apple: Issue #1461: App crashes when initialising with topics (v2.0.0-rc1) [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/8f827a9678dac02887872bd7374fde1c40caeb90)
+- Fixing my merge error for PR #1378 Optional event emit instead of function call for action buttons [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/64044115de796c52132e60719d5e93fc16594002)
+- Updating CHANGELOG [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/d1f8f8e55af40a16129cdc362e179f0c7ef60bd0)
+- 2.0.0-rc1 [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/05c52e22945c0405b76a6d10d837ae6b015e661b)
+- :bookmark: Bumping plugin version to 2.0.0-rc1 [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/600f6050a2c3899559148579c5bc32c1e56449fa)
+- :wrench: add tern to gitignore [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/2660a8620874d520e2f3f3217cf20ea369affada)
+- :hammer::wrench::arrow_up: Use Babel to transpile ES2015 code [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/3f043c21a608fdea4436409b68fbcf2c822d6c0a)
+- :wrench: Add browser platform back for FCM branch [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/97a1615a79ab0317a5dae27b7124dbaec7bc71c7)
+- Pin FCM to 9.8.0 [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/e04b175c72d0680b3b618fdbcce80f9f9d470055)
+- Add empty google services plist [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/d21632fd2acf90847c67b0c70f0b740ed3d367a7)
+- :bug: Issue #1188: Strings.xml google_app_id conflict with google-services.json [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/b41580f7476a34014ceb03976f25989f98cbde6a)
+- :memo: Update to using fcm-node [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/f84574aeffc958b6ec152ca36c2ea595418e901c)
+- Issue #689: Remove sender id from PushNotification init iOS options [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/326943dadc29fe662ce4925b8141960e31d78dd3)
+- Issue #689: Remove sender id from PushNotification init Android options [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/b5c0156bb13a22e11cf6f174a7307e404ed6d154)
+- Refactor GCMIntentService to FCMService [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/006ca17a7482490fbbfc67faa88a4c60d81a49f4)
+- Fix topic subscription and unsubscription on FCM [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/102934b167c4e69c9a6a5c7b41d0ca3fba0cfd25)
+- Fix rebase errors [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/bccc1ba887603b8577c01ee5b885bffa0d406028)
+- Use CocoaPods [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/7fe0379c6be007817c21355044bcecdd05bcc301)
+- fixed registration and removed unused code [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/6c1a5572c420c88772bd3fc89d81fac21027a5be)
+- Added hook and resource file to copy GoogleService-Info.plist [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/98c100b12613a2885ed1afd417b1e678883d37ee)
+- Changed code to work with FCM [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/7861fd27cd052c7e80736b8da9cba8cfae442e73)
+- Added .framework files as custom frameworks [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/b3dc189600842c6a8e318b032bdf215ea1c9b81f)
+- Removed GCM files and added FCM files [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/ff2dbe0cc5a2dce0a92b6c16f35b1a67ce6a6f18)
+- Fixed empty token on android first run (#1008) [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/50285f9193f5e6b33e63c2540b8f3c7a257a5221)
+- Added partial Android FCM support (#975) [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/f67e30d41f5ea94a60a53b00ed51b995960f89c9)
+- Updating CHANGELOG [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/cfad83fa420df5ba4ac12f2f3f7fa68fdb22cc03)
+- 1.10.3 [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/1e072b351056d453fd1c1d40d5fcac310f3e107c)
+- :bookmark: Bumping plugin version to 1.10.3 [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/29df66eae54e773925e25bd92299957e4d654723)
+- :bug: Handle null in getCircleBitmap (#1705) [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/3acdfa338d7a8b56ec4dc73c50aa9917ecb3be7c)
+- :shirt: Issue #1702: The logging tag can be at most 23 characters, was 40 (PushPlugin_BackgroundActionButtonHandler) [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/2045873acda2e81d54b2da87cd2d10f056bd90f9)
+- Shortened log tag PushPlugin_BackgroundActionButtonHandler to bring u… (#1703) [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/dd707122b7aa78649fa6f5f73ba9b05436799926)
+- Merge branch 'v2.0.x' of https://github.com/phonegap/phonegap-plugin-push into v2.0.x [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/96af63840f28a57d29e21a48cc52533fa0830bea)
+- Updating CHANGELOG [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/7371f3b31ea7a672ec6d43da7ef9475916b6c5c5)
+- 2.0.0-rc2 [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/5099c8fe435bda7d8bc7b2648d078a3b63cf19ea)
+- Bumping plugin version to 2.0.0-rc2 [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/72d29bd4372e6043d38835d07839346ea204390a)
+- :apple::bug: Issue #1497: App crashes after refreshing when using FCM (v2) [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/c44be0628bb42ba7ee07456524e9b1fffae64aea)
+- :memo: Using a newer version on the examples [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/95cdee193d2977a17e778bf91ca1bcfc240dc266)
+- :penguin::memo::bug: Issue #1470: Cannot install phonegap-plugin-push on master [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/a1fa7cce1168145c77fef2632ad64f8926e71d27)
+- :bug::apple::wrench: Fixing a merge issue where aps-environment was accidentally removed [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/ef4c7e187f2c5f386d9c844ee7211c8ff1cc214c)
+- :bug::penguin::memo::arrow_up: #1460: Build Issue Android [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/5d52fdaf28f0535ef6dab315abd67141b0fcd0f7)
+- :bug::apple: Issue #1461: App crashes when initialising with topics (v2.0.0-rc1) [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/5d9dfdf179b39312a6382a48dd99d675e642a533)
+- Fixing my merge error for PR #1378 Optional event emit instead of function call for action buttons [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/057cbd16f10581cd601079a9a10b9338df3c23eb)
+- Updating CHANGELOG [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/83238fce85413cdd192b5ff33139ba9a0bcd080f)
+- 2.0.0-rc1 [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/9ff3929bed6bff911027bef21168e527ff61fd2c)
+- :bookmark: Bumping plugin version to 2.0.0-rc1 [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/94d8cc7ec8ba3a4d466758ffb2c27104c2cc1ca3)
+- :wrench: add tern to gitignore [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/a837c875d8a30fc4175693dff43139569974ec22)
+- :hammer::wrench::arrow_up: Use Babel to transpile ES2015 code [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/49da4ea30af1a2fb479110074ddf5f67e2ba370c)
+- :wrench: Add browser platform back for FCM branch [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/ebc5d9353bab3917f91c775cf13aec47c5ca1e04)
+- Pin FCM to 9.8.0 [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/505c8da8253cb8562ed16659b5ec2a8e73ec1c23)
+- Add empty google services plist [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/46eafb1e5688ade278086a1644d06de4e36849b5)
+- :bug: Issue #1188: Strings.xml google_app_id conflict with google-services.json [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/f3b01f155f6300dc05c625116e0c374af61d6388)
+- :memo: Update to using fcm-node [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/453561c8f2dfc4ed09b6a182f6998c90408a3d44)
+- Issue #689: Remove sender id from PushNotification init iOS options [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/ba0020349337160f83271b683195693ef0b4f440)
+- Issue #689: Remove sender id from PushNotification init Android options [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/aee7b93a4d0b0bb0b9c987704c1cde82612e4445)
+- Refactor GCMIntentService to FCMService [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/5e0e7d107b2c9f4aeeda3a7757213e41ac573798)
+- Fix topic subscription and unsubscription on FCM [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/172528ea548174fd7be62d0ab2f9816566447a61)
+- Fix rebase errors [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/2727d274ef650fb0b4d25786d42f0ee5f72e9730)
+- Use CocoaPods [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/697e592d8225f4e0853a0ea72a598d10a18c832d)
+- fixed registration and removed unused code [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/c2987cbee54f04e7d44eec421b2417be5e7d716e)
+- Added hook and resource file to copy GoogleService-Info.plist [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/f358dba691fb39757003326209a232cefce53adf)
+- Changed code to work with FCM [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/7b7de65c2718eccc1ff0eeb2800973cd440c85a7)
+- Added .framework files as custom frameworks [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/8bf4343369e6b12f6ec28a104512cb3ab392e834)
+- Removed GCM files and added FCM files [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/3de63bdf9e5a365e3b3e295f2a305ad66b512917)
+- Fixed empty token on android first run (#1008) [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/b9ad4ebdeee6700d9edf95bf051dabda5923e01a)
+- Added partial Android FCM support (#975) [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/c119bf08869d51d5fe23f9a0fb78fd8325b35248)
+- :memo: Docs for interoperability with Firebase (#1693) [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/cebb6403143047192462f30c22b9510a8c6dbe21)
+- fix headline (#1685) [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/e2e7993544eed544eb7286868b60e2e3efb6275d)
+- Fix changelog date [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/3140b2b00388785f8056632376b50a1d1ef67b96)
+- :arrow_up: update pluginpub to 0.0.8 [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/cfab7d91556a38ee81550fe47e13f2662ae810db)
+- Updating CHANGELOG [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/027ea2c17e4b96b848ab29046efea243e6e2da27)
+- 1.10.2 [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/b5a7d4ec6e64abaed65de00be3e9bac9ab25791e)
+- :bookmark: Bumping plugin version to 1.10.2 [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/5b700ad9927c401081a5de49f2a6a27ba0dfaa9a)
+- :arrow_up: update pluginpub to 0.0.7 [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/38564ce55e53e018c91f4063d680eedd2631b825)
+- Fix the dates on the CHANGELOG (the last 2 version) (#1676) [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/c0f26192c906bfc1a60390333c96d5dc07433978)
+- Vapid Support (#1675) [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/384b60bade628035b21d23f07e284eb6e1557a10)
+- Updating CHANGELOG [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/97d618fb53084cfae78f397def48df791131358f)
+- 1.10.1 [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/6211e8c3df8881a90d19b111a0e63f890d435df6)
+- :bookmark: Bumping plugin version to 1.10.1 [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/6d710a06681ad84c13273fe5d20feb3033ac67b6)
+- :bug: Issue #1655: App opens on clearing notification (Android) [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/ff417925f6d6678f0fcd8315d5f4b4b08fbb9085)
+- :memo: Issue #1118: Problem with notifications stacking [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/d669c44a863d86d0bb73b5ae086bc2fe6f8113a9)
+- :memo: Issue #1220: [Question] the hook setting seem not work [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/4ef137eea370da7c225ab2a5cf63b1e97a68f4a4)
+- Set get badge count android (#1644) [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/630907cf3d8802bcd5d91b6bd768c989f6ef897a)
+- Add plugin typings from DefinitelyTyped (#1654) [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/6ea70d9984e176a75602e72e1d26f5404c519e29)
+- :arrow_up: Issue #1560: setApplicationIconBadgeNumber not working on Android but firing success function [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/700701fd2151667905d860228cf954301186721a)
+- :memo: Issue #1618: No notification when app is closed on Android, not at all on iOS [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/7f64bf0ffbddf3ef20de2fe540ec2718be5d0c23)
+- :arrow_down: Issue #1560: setApplicationIconBadgeNumber not working on Android but firing success function [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/e450fd7b623f27f27858a7537ec7950aa0f618b5)
+- :arrow_up: Issue #1560: setApplicationIconBadgeNumber not working on Android but firing success function [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/4af3472263a5125cab6f08bbb59b83bf957144ec)
+- Updating CHANGELOG [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/ed25a3e3ad9fb6f2af63fd07957944f974eafaa1)
+- 1.10.0 [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/6b9b862da8566c7717dfc79dd6b32d8a7e6774d8)
+- :bookmark: Bumping plugin version to 1.10.0 [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/626e9615fbff6ea225569ab58353ac7f58aef495)
+- :heavy_plus_sign: update pluginpub version [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/c3c8058ffee888447017eb5d8c0f4f30cbcd090f)
+- Issue #1464: Create round bitmap icon for large icon image passed in from local resource or url (#1635) [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/0dd0d468868f0b13c8d840c78dd89fca5920cd32)
+- Receive notification only from SENDER_ID (#1484) [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/a0d51e54aac39b8c58e4c67080f174c0228947c9)
+- Add no-cache flag to payload (#1620) [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/42f8cefbd187c36534e6ab59b6611fb7f15b91f0)
+- Add dismiss key to on notification data (#1621) [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/4259bb3cacfe2561ed44e9f16bd74f8d5ae45ae2)
+- return true for old android versions, since AppOpsManager is available starting at 19 (#1634) [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/945aa2ad6d266e82683e0bee86f53d258f2b31b6)
+- :art: remove reference to unused String [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/75f2191632a7a51eda7510a172ae6cc9d477acb9)
+- Ability to use custom keys to find message title and text on Android (#1604) [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/fd366296773906c91d5f8dfa3e8ba813c7c71b85)
+- :memo: Fixed URL of apples custom sound documentation (#1600) [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/8c93f8622eb1c453cb0c681158a07deca32bf200)
+- Updating CHANGELOG [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/409020c90edf04e0a37232cff8aadb070d4ccaa9)
+- 1.9.4 [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/2241c7431cd60a68d2f35e7b4a5bfd797d5161b6)
+- Bumping plugin version to 1.9.4 [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/ec47932bf8fdf9cd96db076fe56306ab230048d9)
+- Issue #1591: App crashes with the latest updates of Android SDK with plugin v-1.9.2 [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/514c21366ab37001ca323bec58261e023edaefd7)
+- Updating CHANGELOG [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/3a218e4c68ebc1088461c2cfec966e57eaa24089)
+- 1.9.3 [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/42723d6609862aa950abce67b2a637736bdd9e99)
+- :bookmark: Bumping plugin version to 1.9.3 [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/8f7b7dc003a2bc5bab7a316b0e2b0cf475c5a449)
+- :wrench: Add valid SPDX license expression [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/4274d0759acd7110ed2592ed1d2ce3bf692711d3)
+- :memo: Issue #1587: v2.0.0-rc2: .on('notification') event not fired when background notification in Android [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/7e90853a09a2c49f29e12eed03977b08b1295387)
+- :arrow_up: Issue #1560: setApplicationIconBadgeNumber not working on Android but firing success function [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/3188a3907f50dcf625b7663ecf74ea9a9209d437)
+- :memo: Issue #1557: push.on('notification') not triggered - Ionic [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/b91e9420fb68c4efc943cc5f8ecbd81274ffcbec)
+- :memo: Issue #1407: Uncaught (in promise): Error: Push plugin not found! [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/adf3eabb8871980d2dead7ecb8185ad0da1d6b46)
+- Corrected merges usage to prevent possible conflicts with other plugins (#1538) [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/00c67cb2c85e97dfe4f7020f28ad4d954458599f)
+- Updating CHANGELOG [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/3a1806aaec5d3c76f7fcd30ddfd85d576fb6d197)
+- 2.0.0-rc2 [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/471b2aa829cb0ecc93a9a788891602ad17319a47)
+- Bumping plugin version to 2.0.0-rc2 [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/7ad471ff45724828fb21630fdfbc244ba037d9d8)
+- :apple::bug: Issue #1497: App crashes after refreshing when using FCM (v2) [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/b80dfb12b5053184936a4c6c881f1af55459348f)
+- :pencil2: fixing error in CHANGELOG [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/9796292910f2d600b22d4846c128196cfb54ba7c)
+- :memo: Using a newer version on the examples [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/297b8d28f2d7bf04420744c445e59a527c52d502)
+- :penguin::memo::bug: Issue #1470: Cannot install phonegap-plugin-push on master [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/41c8e66483fc0c5f21da7477d2522a2212a8017a)
+- :bug::apple::wrench: Fixing a merge issue where aps-environment was accidentally removed [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/08e496fffc7fa082410f7b16e73e6afe12da194c)
+- :bug::penguin::memo::arrow_up: #1460: Build Issue Android [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/156718a5800dfe4b87593e0732f4258c7c148bea)
+- :bug::apple: Issue #1461: App crashes when initialising with topics (v2.0.0-rc1) [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/0add758d08657e22501612ed258033e31c394e6a)
+- Fixing my merge error for PR #1378 Optional event emit instead of function call for action buttons [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/1f2fd671ae734201b1260bc3d7878ae9ef28673c)
+- Updating CHANGELOG [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/70c6e04a3ba072b91b3752173ca2287d4e448b8f)
+- 2.0.0-rc1 [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/7e07d81dbb47babe161f3204cdd06222a1e2ab3c)
+- :bookmark: Bumping plugin version to 2.0.0-rc1 [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/f3dffdcf63c3d19b4717eed89eb911b8aecdd25a)
+- :wrench: add tern to gitignore [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/f5182503b241f519c03c872ae12f3489383f2b83)
+- :hammer::wrench::arrow_up: Use Babel to transpile ES2015 code [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/27a101f1d35217e0a1b7f0be9ad0607d31ea6c57)
+- :wrench: Add browser platform back for FCM branch [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/c25a47bd3b5c2437ce3108656449658568f2c053)
+- Pin FCM to 9.8.0 [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/000bc36a8ce2a00e96212b66d69f1597dac68554)
+- Add empty google services plist [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/aa1cc247fcf8b94c4d60d26b18c9229c112e8185)
+- :bug: Issue #1188: Strings.xml google_app_id conflict with google-services.json [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/7f4bcafafe56be18f6dc64f3e634a6de594bc034)
+- :memo: Update to using fcm-node [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/a3f0eee774c7f9791f55f85816b0aeadc5c4fb4c)
+- Issue #689: Remove sender id from PushNotification init iOS options [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/6c796a49c3a44b47f58237d7e7760f5ebc34c371)
+- Issue #689: Remove sender id from PushNotification init Android options [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/10c5153672dc478dd072274c220200526c313604)
+- Refactor GCMIntentService to FCMService [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/aa6e3ce5449accd5397b4eda8a950fd5cebc4f0e)
+- Fix topic subscription and unsubscription on FCM [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/b65fe745b5eabbb7437a46b46e747be4aaf5116a)
+- Fix rebase errors [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/3b5f3c71657d8af3e4407ac9ea6c36e00988b1cf)
+- Use CocoaPods [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/89040874c530c7f86c2acbcce5c3b88b351e80fb)
+- fixed registration and removed unused code [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/a1e90013f8ca8497acc2513f4ce3df1358293d51)
+- Added hook and resource file to copy GoogleService-Info.plist [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/0bc1ca736546242772516334f47fd4ea4f8f5e5f)
+- Changed code to work with FCM [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/f7acf338d5bff2bc25b5c1e2fa681b7e20254cc9)
+- Added .framework files as custom frameworks [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/a65be290d4176c1c0b51b700d673550ae22cf777)
+- Removed GCM files and added FCM files [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/ed630d481b9035eb9df48738c0e77029937fafe9)
+- Fixed empty token on android first run (#1008) [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/c9c53761fa3d6fc99acaa96601e9abc673a62c23)
+- Added partial Android FCM support (#975) [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/6c46880b57aa1dee2bbcfeb5a86b497035f46ebe)
+- :penguin: android mixpanel pushnotification suport added (#1523) [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/951cb6921a717d847c279ad6896c28772c70103f)
+- :memo: Making string replacement clearer [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/abdb656315bd4457c7ae43aaa52e2357df85d139)
+- :bug::penguin::memo: Issue #1433: Cordova Push V5 register () crashes App when initialized with topicList [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/1d5723c81ad7a1e9d76fdce22161e8e8aa8da262)
+- :bug::penguin: Issue #1421: Notification delay caused by icon bitmap timeout [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/fb4b533f2b31daebc7ed57c16228458def3d2af9)
+- :memo: Issue #1442: CocoaPods support vs requirement [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/5912b1ea911fbe3b45a3a47ed005b7048a487ba6)
+- 2.0.0-rc2 [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/67041a994d70fd3a04149003607b88947e8cc994)
+- Bumping plugin version to 2.0.0-rc2 [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/7dea689ba17ebb901ee12da62801f051a99cc368)
+- :apple::bug: Issue #1497: App crashes after refreshing when using FCM (v2) [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/ea92e039b1d7640b70ca94e5f8748e7d2abbf13a)
+- :pencil2: fixing error in CHANGELOG [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/498bb038799bd687d8c492154bd3b34d72edd322)
+- :memo: Using a newer version on the examples [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/74aba315b4cbb1e06c902e76891bce5582cbe690)
+- :penguin::memo::bug: Issue #1470: Cannot install phonegap-plugin-push on master [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/e2f8a62c431af26c4d2fa487daa704067a088643)
+- :bug::apple::wrench: Fixing a merge issue where aps-environment was accidentally removed [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/cb9839740c4cbff5711224eed4b91b55aba77612)
+- :bug::penguin::memo::arrow_up: #1460: Build Issue Android [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/1bef8b37ef7bc017571924edc9e05fe09cd25e29)
+- :bug::apple: Issue #1461: App crashes when initialising with topics (v2.0.0-rc1) [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/ca5c281897c664b0bd98097ec2fc8c19c33b2c63)
+- Fixing my merge error for PR #1378 Optional event emit instead of function call for action buttons [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/170d7dd43fe047c6caf84ec0f59da6c2c0cdeb6f)
+- Updating CHANGELOG [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/fa4e36606c965504dba609940a2acf24f74ed978)
+- 2.0.0-rc1 [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/af6c31933e3daedf6e5a7f046e971efcf65cc1ea)
+- :bookmark: Bumping plugin version to 2.0.0-rc1 [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/99742021c8c6c2cd860c40b01db6a3dc18095dbb)
+- :wrench: add tern to gitignore [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/ff14a71b5e365f5c93159e759f989a6bbe89b40a)
+- :hammer::wrench::arrow_up: Use Babel to transpile ES2015 code [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/92dca439e1b0a0750a7e466bace2c4cb3acd19d8)
+- :wrench: Add browser platform back for FCM branch [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/4cbc1cb69203c5a0fab250bd49b99a398ce86558)
+- Pin FCM to 9.8.0 [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/7075bc8206641aa6459cf6acc4fe447fb1d57f77)
+- Add empty google services plist [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/d043c5f9d7872dc4340151c0645a24716391f58f)
+- :bug: Issue #1188: Strings.xml google_app_id conflict with google-services.json [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/f7a7c5c172190acab17fdfd54ad726a7a2fad701)
+- :memo: Update to using fcm-node [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/15e68b03956a1dd292fda87e0da4f1ad9700d9c0)
+- Issue #689: Remove sender id from PushNotification init iOS options [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/54aa482fb8af6ac15a60fb06090077e1d68dee6c)
+- Issue #689: Remove sender id from PushNotification init Android options [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/1276d538b80106dd2f3d67996a531e64e7aa4937)
+- Refactor GCMIntentService to FCMService [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/504f2dcb5b158e0b2e151b255aad28a659bc2c4d)
+- Fix topic subscription and unsubscription on FCM [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/97f0aeaa1099b89076b28282b2d2daac7ec62b33)
+- Fix rebase errors [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/e11d89f46572d1e4430f1f6a63945d74b56e574c)
+- Use CocoaPods [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/fa66ac99685f1f2b580597a45b16315ab7748028)
+- fixed registration and removed unused code [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/c539b041cbe2a2b6e9a360a91ee2a9bfdfd16b03)
+- Added hook and resource file to copy GoogleService-Info.plist [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/dce5e9fb70e4df45a10fd8348a7def64864fdd24)
+- Changed code to work with FCM [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/6f0182aff86b04c22630d1586d6ac6ca617c7e61)
+- Added .framework files as custom frameworks [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/562a22f45bdafa4e2887996e9c0fa295b8bac886)
+- Removed GCM files and added FCM files [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/f1d14b2615d7c8330afbdbf0faa1d2438473a45d)
+- Fixed empty token on android first run (#1008) [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/7e4c47b5c5647866f24e6c2f47e4c98a1f8e2442)
+- Added partial Android FCM support (#975) [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/a02580e19d470919ec61ec489cdf4ee6ca2f0d8c)
+
## [v1.10.3](https://github.com/phonegap/phonegap-plugin-push/tree/v1.10.3) (2017-20-04)
[Full Changelog](https://github.com/phonegap/phonegap-plugin-push/compare/v1.10.2...v1.10.3)
@@ -97,6 +317,96 @@
- :penguin::bug: Issue #1474: Android: force-start starts the app in Foreground instead of Background [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/2bb5f53a8478353ed1f5f97756adff336fb9a710)
- Updating CHANGELOG [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/e02ff6703a53cb18e53060e2d7f6f64ebc8588b6)
+## [v2.0.0-rc2](https://github.com/phonegap/phonegap-plugin-push/tree/v2.0.0-rc2) (2016-07-09)
+[Full Changelog](https://github.com/phonegap/phonegap-plugin-push/compare/v2.0.0-rc1...v2.0.0-rc2)
+
+- 2.0.0-rc2 [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/67041a994d70fd3a04149003607b88947e8cc994)
+- Bumping plugin version to 2.0.0-rc2 [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/7dea689ba17ebb901ee12da62801f051a99cc368)
+- :apple::bug: Issue #1497: App crashes after refreshing when using FCM (v2) [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/ea92e039b1d7640b70ca94e5f8748e7d2abbf13a)
+- :pencil2: fixing error in CHANGELOG [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/498bb038799bd687d8c492154bd3b34d72edd322)
+- :memo: Using a newer version on the examples [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/74aba315b4cbb1e06c902e76891bce5582cbe690)
+- :penguin::memo::bug: Issue #1470: Cannot install phonegap-plugin-push on master [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/e2f8a62c431af26c4d2fa487daa704067a088643)
+- :bug::apple::wrench: Fixing a merge issue where aps-environment was accidentally removed [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/cb9839740c4cbff5711224eed4b91b55aba77612)
+- :bug::penguin::memo::arrow_up: #1460: Build Issue Android [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/1bef8b37ef7bc017571924edc9e05fe09cd25e29)
+- :bug::apple: Issue #1461: App crashes when initialising with topics (v2.0.0-rc1) [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/ca5c281897c664b0bd98097ec2fc8c19c33b2c63)
+- Fixing my merge error for PR #1378 Optional event emit instead of function call for action buttons [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/170d7dd43fe047c6caf84ec0f59da6c2c0cdeb6f)
+
+## [v2.0.0-rc1](https://github.com/phonegap/phonegap-plugin-push/tree/v2.0.0-rc1) (2016-07-09)
+[Full Changelog](https://github.com/phonegap/phonegap-plugin-push/compare/v1.9.1...v2.0.0-rc1)
+
+- 2.0.0-rc1 [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/46a44f92ca8f94c991a564a5a8ff1e424c4b7f7f)
+- :bookmark: Bumping plugin version to 2.0.0-rc1 [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/b952330124ab76d6a8ec88ebdb7eac0a614f8c38)
+- :wrench: add tern to gitignore [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/6ec1beb2ab13d6333122b76122ae4eb2e60dfb55)
+- :hammer::wrench::arrow_up: Use Babel to transpile ES2015 code [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/fab033596c66ee1c9594d404fec8473a4dd41e77)
+- :wrench: Add browser platform back for FCM branch [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/07f28d8dbc477faeb2a8dd8997fde0d088dd191a)
+- Pin FCM to 9.8.0 [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/ba16ce363a198edd0d190e9603a5e1363289a893)
+- Add empty google services plist [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/a47af30d32c6921b484c1c129cd60582e1b3047b)
+- :bug: Issue #1188: Strings.xml google_app_id conflict with google-services.json [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/c9f4a5d6d6f18082ae9e5a533a700cf3662c2739)
+- :memo: Update to using fcm-node [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/368f6cbb8095fd742bb39308e02fac7f89379f18)
+- Issue #689: Remove sender id from PushNotification init iOS options [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/a3e0eefe09359612d6757d4598eba69e3d68a96b)
+- Issue #689: Remove sender id from PushNotification init Android options [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/d6d527628f8811ab6781591b3c186ce2732c9f37)
+- Refactor GCMIntentService to FCMService [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/26b0369f148976e4227f73f5883658a726f825dd)
+- Fix topic subscription and unsubscription on FCM [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/b4d850028b088c38bbd11c1899e28ea69b1c391e)
+- Fix rebase errors [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/417be691c8131f006a7f1bd49bc171faa36ee872)
+- Use CocoaPods [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/e34ddc03b01e676382a6d70e1e750a4e64ca6d62)
+- fixed registration and removed unused code [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/732a2bd8efbfbea696db6951439e2472d6dc8e6f)
+- Added hook and resource file to copy GoogleService-Info.plist [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/8d44ccfdfe91831140e4e972d6879b6330a1c613)
+- Changed code to work with FCM [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/a18d50324ab96945db382539ce2ed7a287bed840)
+- Added .framework files as custom frameworks [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/72875ac0aef0f9d00de6413e0dea4d7533c5eaef)
+- Removed GCM files and added FCM files [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/2bd37d1b31ca0b2c76c89a04a803b22186d1f8ad)
+- Fixed empty token on android first run (#1008) [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/fda1f905c4364a3ac100486dc639fdd5c3bae9ca)
+- Added partial Android FCM support (#975) [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/b6acbfeacf851bab256962616ba2bd93150982ba)
+- :memo: Issue #1235: SecurityError: Only secure origins are allowed (see: https://goo.gl/Y0ZkNV) [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/5241a6f3868b4b15f79c6d5c0b5b5ea45e6301f9)
+- :memo: Issue #1415: What is the id in push.finish? [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/2660b51da66e791ff342d027ea6afa4313281e28)
+- :memo: Issue #1420: Update PLATFORM_SUPPORT.md [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/60ad23affaf2dc4c9c2bf48b6cbb702b0217aeb7)
+- :memo: Adding more emoji for commit messages [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/eb6b7b7d52770769719392b9b5226ee9a7caef75)
+- Updating CHANGELOG [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/f38fd3d4d9f5f4f8de602b6aa07089b706884ca5)
+
+## [v2.0.0-rc2](https://github.com/phonegap/phonegap-plugin-push/tree/v2.0.0-rc2) (2016-07-09)
+[Full Changelog](https://github.com/phonegap/phonegap-plugin-push/compare/v2.0.0-rc1...v2.0.0-rc2)
+
+- 2.0.0-rc2 [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/67041a994d70fd3a04149003607b88947e8cc994)
+- Bumping plugin version to 2.0.0-rc2 [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/7dea689ba17ebb901ee12da62801f051a99cc368)
+- :apple::bug: Issue #1497: App crashes after refreshing when using FCM (v2) [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/ea92e039b1d7640b70ca94e5f8748e7d2abbf13a)
+- :pencil2: fixing error in CHANGELOG [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/498bb038799bd687d8c492154bd3b34d72edd322)
+- :memo: Using a newer version on the examples [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/74aba315b4cbb1e06c902e76891bce5582cbe690)
+- :penguin::memo::bug: Issue #1470: Cannot install phonegap-plugin-push on master [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/e2f8a62c431af26c4d2fa487daa704067a088643)
+- :bug::apple::wrench: Fixing a merge issue where aps-environment was accidentally removed [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/cb9839740c4cbff5711224eed4b91b55aba77612)
+- :bug::penguin::memo::arrow_up: #1460: Build Issue Android [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/1bef8b37ef7bc017571924edc9e05fe09cd25e29)
+- :bug::apple: Issue #1461: App crashes when initialising with topics (v2.0.0-rc1) [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/ca5c281897c664b0bd98097ec2fc8c19c33b2c63)
+- Fixing my merge error for PR #1378 Optional event emit instead of function call for action buttons [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/170d7dd43fe047c6caf84ec0f59da6c2c0cdeb6f)
+
+## [v2.0.0-rc1](https://github.com/phonegap/phonegap-plugin-push/tree/v2.0.0-rc1) (2016-07-09)
+[Full Changelog](https://github.com/phonegap/phonegap-plugin-push/compare/v1.9.1...v2.0.0-rc1)
+
+- 2.0.0-rc1 [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/46a44f92ca8f94c991a564a5a8ff1e424c4b7f7f)
+- :bookmark: Bumping plugin version to 2.0.0-rc1 [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/b952330124ab76d6a8ec88ebdb7eac0a614f8c38)
+- :wrench: add tern to gitignore [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/6ec1beb2ab13d6333122b76122ae4eb2e60dfb55)
+- :hammer::wrench::arrow_up: Use Babel to transpile ES2015 code [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/fab033596c66ee1c9594d404fec8473a4dd41e77)
+- :wrench: Add browser platform back for FCM branch [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/07f28d8dbc477faeb2a8dd8997fde0d088dd191a)
+- Pin FCM to 9.8.0 [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/ba16ce363a198edd0d190e9603a5e1363289a893)
+- Add empty google services plist [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/a47af30d32c6921b484c1c129cd60582e1b3047b)
+- :bug: Issue #1188: Strings.xml google_app_id conflict with google-services.json [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/c9f4a5d6d6f18082ae9e5a533a700cf3662c2739)
+- :memo: Update to using fcm-node [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/368f6cbb8095fd742bb39308e02fac7f89379f18)
+- Issue #689: Remove sender id from PushNotification init iOS options [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/a3e0eefe09359612d6757d4598eba69e3d68a96b)
+- Issue #689: Remove sender id from PushNotification init Android options [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/d6d527628f8811ab6781591b3c186ce2732c9f37)
+- Refactor GCMIntentService to FCMService [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/26b0369f148976e4227f73f5883658a726f825dd)
+- Fix topic subscription and unsubscription on FCM [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/b4d850028b088c38bbd11c1899e28ea69b1c391e)
+- Fix rebase errors [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/417be691c8131f006a7f1bd49bc171faa36ee872)
+- Use CocoaPods [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/e34ddc03b01e676382a6d70e1e750a4e64ca6d62)
+- fixed registration and removed unused code [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/732a2bd8efbfbea696db6951439e2472d6dc8e6f)
+- Added hook and resource file to copy GoogleService-Info.plist [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/8d44ccfdfe91831140e4e972d6879b6330a1c613)
+- Changed code to work with FCM [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/a18d50324ab96945db382539ce2ed7a287bed840)
+- Added .framework files as custom frameworks [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/72875ac0aef0f9d00de6413e0dea4d7533c5eaef)
+- Removed GCM files and added FCM files [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/2bd37d1b31ca0b2c76c89a04a803b22186d1f8ad)
+- Fixed empty token on android first run (#1008) [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/fda1f905c4364a3ac100486dc639fdd5c3bae9ca)
+- Added partial Android FCM support (#975) [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/b6acbfeacf851bab256962616ba2bd93150982ba)
+- :memo: Issue #1235: SecurityError: Only secure origins are allowed (see: https://goo.gl/Y0ZkNV) [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/5241a6f3868b4b15f79c6d5c0b5b5ea45e6301f9)
+- :memo: Issue #1415: What is the id in push.finish? [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/2660b51da66e791ff342d027ea6afa4313281e28)
+- :memo: Issue #1420: Update PLATFORM_SUPPORT.md [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/60ad23affaf2dc4c9c2bf48b6cbb702b0217aeb7)
+- :memo: Adding more emoji for commit messages [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/eb6b7b7d52770769719392b9b5226ee9a7caef75)
+- Updating CHANGELOG [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/f38fd3d4d9f5f4f8de602b6aa07089b706884ca5)
+
## [v1.9.2](https://github.com/phonegap/phonegap-plugin-push/tree/v1.9.2) (2016-07-09)
[Full Changelog](https://github.com/phonegap/phonegap-plugin-push/compare/v1.9.1...v1.9.2)
@@ -104,11 +414,6 @@
- :bookmark: Bumping plugin version to 1.9.2 [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/24650bad4db49525505e9a2624ff1b5500e6b3ef)
- Optional event emit instead of function call for action buttons (#1378) [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/e92e951e759fe64d17d01e152575b6262973380a)
- Ensures foreground is true when inline is set to true and Android version is earlier than N (#1459) [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/dd61ec34c0ca5c3fadf6797a8e192b9343324f68)
-- :memo: Issue #1235: SecurityError: Only secure origins are allowed (see: https://goo.gl/Y0ZkNV) [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/5241a6f3868b4b15f79c6d5c0b5b5ea45e6301f9)
-- :memo: Issue #1415: What is the id in push.finish? [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/2660b51da66e791ff342d027ea6afa4313281e28)
-- :memo: Issue #1420: Update PLATFORM_SUPPORT.md [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/60ad23affaf2dc4c9c2bf48b6cbb702b0217aeb7)
-- :memo: Adding more emoji for commit messages [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/eb6b7b7d52770769719392b9b5226ee9a7caef75)
-- Updating CHANGELOG [view commit](http://github.com/phonegap/phonegap-plugin-push/commit/f38fd3d4d9f5f4f8de602b6aa07089b706884ca5)
## [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)
diff --git a/docs/API.md b/docs/API.md
index 92072c0f8..65c1588cd 100644
--- a/docs/API.md
+++ b/docs/API.md
@@ -39,7 +39,6 @@ All available option attributes are described bellow. Currently, there are no Wi
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.
@@ -47,7 +46,8 @@ Attribute | Type | Default | Description
`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. Note: you should omit the `/topics/` prefix from each element of the array as the plugin will handle that for you.
+`android.topics` | `array` | `[]` | Optional. If the array contains one or more strings each string will be used to subscribe to a FcmPubSub topic.
+`/topics/` prefix from each element of the array as the plugin will handle that for you.
`android.messageKey` | `string` | `message` | Optional. The key to search for text of notification.
`android.titleKey` | `string` | `'title'` | Optional. The key to search for title of notification.
@@ -76,9 +76,9 @@ 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`. Note: you should omit the `/topics/` prefix from each element of the array as the plugin will handle that for you.
+`ios.fcmSandbox` | `boolean` | `false` | Whether to use prod or sandbox GCM setting. Defaults to false.
+options
+`ios.topics` | `array` | `[]` | Optional. If the array contains one or more strings each string will be used to subscribe to a FcmPubSub topic.
##### How GCM on iOS works.
@@ -88,12 +88,12 @@ What happens is on the device side is that it registers with APNS, then that reg
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.
+Make sure that the certificate you build with matches your `fcmSandbox` 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.
+- If you build your app as development and set `fcmSandbox: false` it will fail.
+- If you build your app as production and set `fcmSandbox: true` it will fail.
+- If you build your app as development and set `fcmSandbox: true` but haven't uploaded the development certs to Google it will fail.
+- If you build your app as production and set `fcmSandbox: 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.
@@ -102,7 +102,6 @@ Make sure that the certificate you build with matches your `gcmSandbox` value.
```javascript
var push = PushNotification.init({
android: {
- senderID: "12345679"
},
browser: {
pushServiceURL: 'http://push.api.phonegap.com/v1/push'
diff --git a/docs/EXAMPLES.md b/docs/EXAMPLES.md
index 8481e7bcc..32bc2e5fd 100644
--- a/docs/EXAMPLES.md
+++ b/docs/EXAMPLES.md
@@ -11,7 +11,6 @@ phonegap create my-app --template phonegap-template-push
```javascript
var push = PushNotification.init({
android: {
- senderID: "12345679"
},
browser: {
pushServiceURL: 'http://push.api.phonegap.com/v1/push'
diff --git a/docs/INSTALLATION.md b/docs/INSTALLATION.md
index 28c438876..d4c8e56b3 100644
--- a/docs/INSTALLATION.md
+++ b/docs/INSTALLATION.md
@@ -24,46 +24,56 @@
Plugin version | Cordova CLI | Cordova Android | Cordova iOS | CocoaPods
---- | ---- | ---- | ---- | ----
+2.0.0 | 6.4.0 | 6.2.1 | 4.4.0 | 1.1.1
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"
+phonegap plugin add phonegap-plugin-push
```
or
```
-cordova plugin add phonegap-plugin-push --variable SENDER_ID="XXXXXXX"
+cordova plugin add phonegap-plugin-push
```
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"
+phonegap plugin add https://github.com/phonegap/phonegap-plugin-push
```
or
```
-cordova plugin add https://github.com/phonegap/phonegap-plugin-push --variable SENDER_ID="XXXXXXX"
+cordova plugin add https://github.com/phonegap/phonegap-plugin-push
```
-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.
+As of version 2.0.0 the SENDER_ID parameter has been removed at install time. Instead you put your google-services.json (Android) and/or GoogleService-Info.pList in the root folder of your project and then add the following lines into your plugin.xml.
-
+In the platform tag for Android add the resource-file tag:
-If you are not creating an Android application you can put in anything for this value.
+```
+
+
+
+```
+
+In the platform tag for iOS add the resource-file tag:
+
+```
+
+
+
+```
> 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"
}
]
@@ -72,23 +82,17 @@ If you are not creating an Android application you can put in anything for this
> 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.
```
-
-
-
+
```
## 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:
+As of version 2.0.0 the plugin has been switched to using pinned version of Gradle libraries. 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
+- Android Support Library version 25.1.0
+- FirebaseMessaging Library version 9.8.0

diff --git a/docs/PAYLOAD.md b/docs/PAYLOAD.md
index a50ee702d..7daf60839 100644
--- a/docs/PAYLOAD.md
+++ b/docs/PAYLOAD.md
@@ -158,22 +158,32 @@ Or use localization with formatted constants.
}
```
-Here is an example using node-gcm that sends the above JSON:
+Here is an example using fcm-node that sends the above JSON:
```javascript
-var gcm = require('node-gcm');
+var FCM = require('fcm-node');
// 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);
+var fcm = new FCM(apiKey);
+
+var message = {
+ to: deviceID,
+ data: {
+ title: {"locKey": "push_app_title"},
+ message: 'Simple non-localizable text for message!'
+ // Constant with formatted params
+ // message: {"locKey": "push_message_fox", "locData": ["fox", "dog"]});
+ }
+};
+
+fcm.send(message, function(err, response){
+ if (err) {
+ console.log(err);
+ console.log("Something has gone wrong!");
+ } else {
+ console.log("Successfully sent with response: ", response);
+ }
});
```
@@ -192,9 +202,8 @@ By default the icon displayed in your push notification will be your apps icon.
```javascript
var push = PushNotification.init({
"android": {
- "senderID": "12345679"
},
- browser: {
+ "browser": {
pushServiceURL: 'http://push.api.phonegap.com/v1/push'
},
"ios": {
@@ -217,11 +226,10 @@ In order to get a better user experience you can specify an alternate icon and b
```javascript
var push = PushNotification.init({
"android": {
- "senderID": "123456789",
"icon": "phonegap",
"iconColor": "blue"
},
- browser: {
+ "browser": {
pushServiceURL: 'http://push.api.phonegap.com/v1/push'
},
"ios": {
@@ -257,21 +265,31 @@ The first is the `res/drawable` folder in your app. This JSON sent from GCM:
}
```
-Here is an example using node-gcm that sends the above JSON:
+Here is an example using fcm-node that sends the above JSON:
```javascript
-var gcm = require('node-gcm');
+var FCM = require('fcm-node');
// 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 drawable folder.');
-message.addData('image', 'twitter');
-service.send(message, { registrationTokens: [ deviceID ] }, function (err, response) {
- if(err) console.error(err);
- else console.log(response);
+var fcm = new FCM(apiKey);
+
+var message = {
+ to: deviceID,
+ data: {
+ title: 'Large Icon',
+ message: 'Loaded from drawables folder.',
+ image: 'twitter'
+ }
+};
+
+fcm.send(message, function(err, response){
+ if (err) {
+ console.log(err);
+ console.log("Something has gone wrong!");
+ } else {
+ console.log("Successfully sent with response: ", response);
+ }
});
```
@@ -292,21 +310,31 @@ The second is the *assets* folder in your app. This JSON sent from GCM:
}
```
-Here is an example using node-gcm that sends the above JSON:
+Here is an example using fcm-node that sends the above JSON:
```javascript
-var gcm = require('node-gcm');
+var FCM = require('fcm-node');
// 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);
+var fcm = new FCM(apiKey);
+
+var message = {
+ to: deviceID,
+ data: {
+ title: 'Large Icon',
+ message: 'Loaded from assets folder.',
+ image: 'www/image/logo.png'
+ }
+};
+
+fcm.send(message, function(err, response){
+ if (err) {
+ console.log(err);
+ console.log("Something has gone wrong!");
+ } else {
+ console.log("Successfully sent with response: ", response);
+ }
});
```
@@ -328,21 +356,31 @@ The third is the remote *URL*. This JSON sent from GCM:
}
```
-Here is an example using node-gcm that sends the above JSON:
+Here is an example using fcm-node that sends the above JSON:
```javascript
-var gcm = require('node-gcm');
+var FCM = require('fcm-node');
// 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);
+var fcm = new FCM(apiKey);
+
+var message = {
+ to: deviceID,
+ data: {
+ title: 'Large Icon',
+ message: 'Loaded from URL',
+ image: 'https://dl.dropboxusercontent.com/u/887989/antshot.png'
+ }
+};
+
+fcm.send(message, function(err, response){
+ if (err) {
+ console.log(err);
+ console.log("Something has gone wrong!");
+ } else {
+ console.log("Successfully sent with response: ", response);
+ }
});
```
@@ -440,21 +478,31 @@ In order for your your notification to play a custom sound you will need to add
}
```
-Here is an example using node-gcm that sends the above JSON:
+Here is an example using fcm-node that sends the above JSON:
```javascript
-var gcm = require('node-gcm');
+var FCM = require('fcm-node');
// 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);
+var fcm = new FCM(apiKey);
+
+var message = {
+ to: deviceID,
+ data: {
+ title: 'Sound Test',
+ message: 'Loaded res/raw',
+ soundname: 'test'
+ }
+};
+
+fcm.send(message, function(err, response){
+ if (err) {
+ console.log(err);
+ console.log("Something has gone wrong!");
+ } else {
+ console.log("Successfully sent with response: ", response);
+ }
});
```
@@ -476,20 +524,30 @@ If you want to see multiple notifications in the shade you will need to provide
}
```
-Here is an example using node-gcm that sends the above JSON:
+Here is an example using fcm-node that sends the above JSON:
```javascript
-var gcm = require('node-gcm');
+var FCM = require('fcm-node');
// 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);
+var fcm = new FCM(apiKey);
+
+var message = {
+ to: deviceID,
+ data: {
+ title: 'Test Push',
+ message: 'Push number 1'
+ }
+};
+
+fcm.send(message, function(err, response){
+ if (err) {
+ console.log(err);
+ console.log("Something has gone wrong!");
+ } else {
+ console.log("Successfully sent with response: ", response);
+ }
});
```
@@ -505,20 +563,30 @@ Followed by:
}
```
-Here is an example using node-gcm that sends the above JSON:
+Here is an example using fcm-node that sends the above JSON:
```javascript
-var gcm = require('node-gcm');
+var FCM = require('fcm-node');
// 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);
+var fcm = new FCM(apiKey);
+
+var message = {
+ to: deviceID,
+ data: {
+ title: 'Test Push',
+ message: 'Push number 2'
+ }
+};
+
+fcm.send(message, function(err, response){
+ if (err) {
+ console.log(err);
+ console.log("Something has gone wrong!");
+ } else {
+ console.log("Successfully sent with response: ", response);
+ }
});
```
@@ -535,21 +603,31 @@ You will only see "Push number 2" in the shade. However, if you send:
}
```
-Here is an example using node-gcm that sends the above JSON:
+Here is an example using fcm-node that sends the above JSON:
```javascript
-var gcm = require('node-gcm');
+var FCM = require('fcm-node');
// 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);
+var fcm = new FCM(apiKey);
+
+var message = {
+ to: deviceID,
+ data: {
+ title: 'Test Push',
+ message: 'Push number 1',
+ notId: 1
+ }
+};
+
+fcm.send(message, function(err, response){
+ if (err) {
+ console.log(err);
+ console.log("Something has gone wrong!");
+ } else {
+ console.log("Successfully sent with response: ", response);
+ }
});
```
@@ -566,21 +644,31 @@ and:
}
```
-Here is an example using node-gcm that sends the above JSON:
+Here is an example using fcm-node that sends the above JSON:
```javascript
-var gcm = require('node-gcm');
+var FCM = require('fcm-node');
// 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);
+var fcm = new FCM(apiKey);
+
+var message = {
+ to: deviceID,
+ data: {
+ title: 'Test Push',
+ message: 'Push number 2',
+ notId: 2
+ }
+};
+
+fcm.send(message, function(err, response){
+ if (err) {
+ console.log(err);
+ console.log("Something has gone wrong!");
+ } else {
+ console.log("Successfully sent with response: ", response);
+ }
});
```
@@ -602,22 +690,32 @@ A better alternative to stacking your notifications is to use the inbox style to
}
```
-Here is an example using node-gcm that sends the above JSON:
+Here is an example using fcm-node that sends the above JSON:
```javascript
-var gcm = require('node-gcm');
+var FCM = require('fcm-node');
// 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);
+var fcm = new FCM(apiKey);
+
+var message = {
+ to: deviceID,
+ data: {
+ title: 'My Title',
+ message: 'My first message',
+ style: 'inbox',
+ summaryText: 'There are %n% notifications'
+ }
+};
+
+fcm.send(message, function(err, response){
+ if (err) {
+ console.log(err);
+ console.log("Something has gone wrong!");
+ } else {
+ console.log("Successfully sent with response: ", response);
+ }
});
```
@@ -639,22 +737,32 @@ But, if you follow it up with subsequent notifications like:
}
```
-Here is an example using node-gcm that sends the above JSON:
+Here is an example using fcm-node that sends the above JSON:
```javascript
-var gcm = require('node-gcm');
+var FCM = require('fcm-node');
// 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);
+var fcm = new FCM(apiKey);
+
+var message = {
+ to: deviceID,
+ data: {
+ title: 'My Title',
+ message: 'My second message',
+ style: 'inbox',
+ summaryText: 'There are %n% notifications'
+ }
+};
+
+fcm.send(message, function(err, response){
+ if (err) {
+ console.log(err);
+ console.log("Something has gone wrong!");
+ } else {
+ console.log("Successfully sent with response: ", response);
+ }
});
```
@@ -682,24 +790,34 @@ Your notification can include a maximum of three action buttons. If you wish to
}
```
-Here is an example using node-gcm that sends the above JSON:
+Here is an example using fcm-node that sends the above JSON:
```javascript
-var gcm = require('node-gcm');
+var FCM = require('fcm-node');
// 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);
+var fcm = new FCM(apiKey);
+
+var message = {
+ to: deviceID,
+ 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},
+ ]
+ }
+};
+
+fcm.send(message, function(err, response){
+ if (err) {
+ console.log(err);
+ console.log("Something has gone wrong!");
+ } else {
+ console.log("Successfully sent with response: ", response);
+ }
});
```
@@ -729,24 +847,34 @@ Your notification can include action buttons. If you wish to include an icon alo
}
```
-Here is an example using node-gcm that sends the above JSON:
+Here is an example using fcm-node that sends the above JSON:
```javascript
-var gcm = require('node-gcm');
+var FCM = require('fcm-node');
// 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);
+var fcm = new FCM(apiKey);
+
+var message = {
+ to: deviceID,
+ 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},
+ ]
+ }
+};
+
+fcm.send(message, function(err, response){
+ if (err) {
+ console.log(err);
+ console.log("Something has gone wrong!");
+ } else {
+ console.log("Successfully sent with response: ", response);
+ }
});
```
@@ -813,21 +941,31 @@ You can use a Led notifcation and choose the color of it. Just add a `ledColor`
}
```
-Here is an example using node-gcm that sends the above JSON:
+Here is an example using fcm-node that sends the above JSON:
```javascript
-var gcm = require('node-gcm');
+var FCM = require('fcm-node');
// 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);
+var fcm = new FCM(apiKey);
+
+var message = {
+ to: deviceID,
+ data: {
+ title: 'Green LED',
+ message: 'This is my message with a Green LED',
+ ledColor: [0, 0, 255, 0]
+ }
+};
+
+fcm.send(message, function(err, response){
+ if (err) {
+ console.log(err);
+ console.log("Something has gone wrong!");
+ } else {
+ console.log("Successfully sent with response: ", response);
+ }
});
```
@@ -846,21 +984,31 @@ You can set a Vibration Pattern for your notifications. Just add a `vibrationPat
}
```
-Here is an example using node-gcm that sends the above JSON:
+Here is an example using fcm-node that sends the above JSON:
```javascript
-var gcm = require('node-gcm');
+var FCM = require('fcm-node');
// 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);
+var fcm = new FCM(apiKey);
+
+var message = {
+ to: deviceID,
+ 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]
+ }
+};
+
+fcm.send(message, function(err, response){
+ if (err) {
+ console.log(err);
+ console.log("Something has gone wrong!");
+ } else {
+ console.log("Successfully sent with response: ", response);
+ }
});
```
@@ -879,21 +1027,31 @@ You can set a priority parameter for your notifications. This priority value det
}
```
-Here is an example using node-gcm that sends the above JSON:
+Here is an example using fcm-node that sends the above JSON:
```javascript
-var gcm = require('node-gcm');
+var FCM = require('fcm-node');
// 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);
+var fcm = new FCM(apiKey);
+
+var message = {
+ to: deviceID,
+ data: {
+ title: 'This is a maximum priority Notification',
+ message: 'This notification should appear in front of all others',
+ priority: 2
+ }
+};
+
+fcm.send(message, function(err, response){
+ if (err) {
+ console.log(err);
+ console.log("Something has gone wrong!");
+ } else {
+ console.log("Successfully sent with response: ", response);
+ }
});
```
@@ -916,23 +1074,32 @@ Perhaps you want to include a large picture in the notification that you are sen
}
```
-Here is an example using node-gcm that sends the above JSON:
+Here is an example using fcm-node that sends the above JSON:
```javascript
-var gcm = require('node-gcm');
+var FCM = require('fcm-node');
// 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);
+var fcm = new FCM(apiKey);
+
+var message = {
+ to: deviceID,
+ data: {
+ title: 'Big Picture',
+ message: 'This is my big picture message',
+ picture: 'http://36.media.tumblr.com/c066cc2238103856c9ac506faa6f3bc2/tumblr_nmstmqtuo81tssmyno1_1280.jpg',
+ summaryText: 'The internet is built on cat pictures'
+ }
+};
+
+fcm.send(message, function(err, response){
+ if (err) {
+ console.log(err);
+ console.log("Something has gone wrong!");
+ } else {
+ console.log("Successfully sent with response: ", response);
+ }
});
```
@@ -960,22 +1127,32 @@ First the JSON you send from GCM will need to include `"content-available": "1"`
}
```
-Here is an example using node-gcm that sends the above JSON:
+Here is an example using fcm-node that sends the above JSON:
```javascript
-var gcm = require('node-gcm');
+var FCM = require('fcm-node');
// 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);
+var fcm = new FCM(apiKey);
+
+var message = {
+ to: deviceID,
+ data: {
+ title: 'Test Push',
+ message: 'Push number 1',
+ info: 'super secret info',
+ content-available: '1'
+ }
+};
+
+fcm.send(message, function(err, response){
+ if (err) {
+ console.log(err);
+ console.log("Something has gone wrong!");
+ } else {
+ console.log("Successfully sent with response: ", response);
+ }
});
```
@@ -992,20 +1169,30 @@ or if you want the payload to be delivered directly to your app without anything
}
```
-Here is an example using node-gcm that sends the above JSON:
+Here is an example using fcm-node that sends the above JSON:
```javascript
-var gcm = require('node-gcm');
+var FCM = require('fcm-node');
// 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);
+var fcm = new FCM(apiKey);
+
+var message = {
+ to: deviceID,
+ data: {
+ info: 'super secret info',
+ content-available: '1'
+ }
+};
+
+fcm.send(message, function(err, response){
+ if (err) {
+ console.log(err);
+ console.log("Something has gone wrong!");
+ } else {
+ console.log("Successfully sent with response: ", response);
+ }
});
```
@@ -1095,21 +1282,31 @@ If you add `force-start: 1` to the data payload the application will be restarte
}
```
-Here is an example using node-gcm that sends the above JSON:
+Here is an example using fcm-node that sends the above JSON:
```javascript
-var gcm = require('node-gcm');
+var FCM = require('fcm-node');
// 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);
+var fcm = new FCM(apiKey);
+
+var message = {
+ to: deviceID,
+ data: {
+ title: 'Force Start',
+ message: 'This notification should restart the app',
+ force-start: '1'
+ }
+};
+
+fcm.send(message, function(err, response){
+ if (err) {
+ console.log(err);
+ console.log("Something has gone wrong!");
+ } else {
+ console.log("Successfully sent with response: ", response);
+ }
});
```
@@ -1144,21 +1341,31 @@ You can set a visibility parameter for your notifications. Just add a `visibilit
}
```
-Here is an example using node-gcm that sends the above JSON:
+Here is an example using fcm-node that sends the above JSON:
```javascript
-var gcm = require('node-gcm');
+var FCM = require('fcm-node');
// 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);
+var fcm = new FCM(apiKey);
+
+var message = {
+ to: deviceID,
+ data: {
+ title: 'This is a public Notification',
+ message: 'You should be able to read this notification on your lock screen',
+ visibility: 1
+ }
+};
+
+fcm.send(message, function(err, response){
+ if (err) {
+ console.log(err);
+ console.log("Something has gone wrong!");
+ } else {
+ console.log("Successfully sent with response: ", response);
+ }
});
```
@@ -1179,21 +1386,31 @@ In order to set the badge number you will need to include the `badge` property i
}
```
-Here is an example using node-gcm that sends the above JSON:
+Here is an example using fcm-node that sends the above JSON:
```javascript
-var gcm = require('node-gcm');
+var FCM = require('fcm-node');
// 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);
+var fcm = new FCM(apiKey);
+
+var message = {
+ to: deviceID,
+ data: {
+ title: 'Badge Test',
+ message: 'Badges, we don\'t need no stinking badges',
+ badge: 7
+ }
+};
+
+fcm.send(message, function(err, response){
+ if (err) {
+ console.log(err);
+ console.log("Something has gone wrong!");
+ } else {
+ console.log("Successfully sent with response: ", response);
+ }
});
```
diff --git a/docs/TYPESCRIPT.md b/docs/TYPESCRIPT.md
index 37117d168..843a6d913 100644
--- a/docs/TYPESCRIPT.md
+++ b/docs/TYPESCRIPT.md
@@ -11,7 +11,6 @@ All available attributes and properties will have autocomplete support and type
```typescript
let push = PushNotification.init({
android: {
- senderID: "12345679"
},
ios: {
alert: "true",
@@ -69,4 +68,4 @@ push.on('notification', (data: my.custom.NotificationEventResponse) => {
## 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
+We welcome any contribution, and they should be done through issues created [there](https://github.com/DefinitelyTyped/DefinitelyTyped/issues/new).
diff --git a/package.json b/package.json
index eca2c08bb..570b28e05 100644
--- a/package.json
+++ b/package.json
@@ -2,7 +2,7 @@
"name": "phonegap-plugin-push",
"description": "Register and receive push notifications.",
"types": "./types/index.d.ts",
- "version": "1.10.4",
+ "version": "2.0.0-rc3",
"homepage": "http://github.com/phonegap/phonegap-plugin-push#readme",
"repository": {
"type": "git",
@@ -37,23 +37,43 @@
"cordova-android": ">=4.0.0",
"cordova-ios": ">=4.1.0"
},
- "1.9.0": {
+ "<2.0.0": {
"cordova-ios": ">=4.3.0",
"cordova-android": ">=6.0.0",
"cordova": ">=6.4.0"
},
"2.0.0": {
- "cordova": ">100"
+ "cordova-ios": ">=4.4.0",
+ "cordova-android": ">=6.2.1",
+ "cordova": ">=6.4.0"
}
}
},
"author": "Adobe PhoneGap Team",
"license": "MIT",
"scripts": {
- "test": "jasmine-node --color spec"
+ "build": "babel src/js --out-dir www",
+ "build:watch": "nodemon -w ./src/js -e js -x npm run build",
+ "jasmine": "jasmine-node --color spec",
+ "test": "npm run build && npm run jasmine"
},
"devDependencies": {
+ "babel-cli": "^6.10.1",
+ "babel-core": "^6.10.4",
+ "babel-eslint": "^6.1.0",
+ "babel-preset-es2015": "^6.9.0",
+ "eslint": "^2.13.1",
+ "eslint-config-airbnb": "^9.0.1",
+ "eslint-plugin-import": "^1.9.2",
+ "eslint-plugin-jsx-a11y": "^1.5.3",
+ "eslint-plugin-react": "^5.2.2",
"jasmine-node": "1.14.5",
+ "nodemon": "^1.9.2",
"pluginpub": "^0.0.8"
+ },
+ "dependencies": {
+ "babel-plugin-add-header-comment": "^1.0.3",
+ "install": "^0.8.2",
+ "npm": "^4.0.2"
}
}
diff --git a/plugin.xml b/plugin.xml
index 313666dc4..9d6002de1 100755
--- a/plugin.xml
+++ b/plugin.xml
@@ -1,73 +1,58 @@
-
+
PushPlugin
- This plugin allows your application to receive push notifications on Android, iOS and Windows devices.
- Android uses Google Cloud Messaging.
+ This plugin allows your application to receive push notifications on Android, iOS and Windows devices.
+ Android uses Firebase Cloud Messaging.
iOS uses Apple APNS Notifications.
Windows uses Microsoft WNS Notifications.
-
+
MIT
-
-
+
+
-
+
-
- $SENDER_ID
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
+
-
+
-
+
-
+
-
+
-
-
-
+
-
+
+
+
-
@@ -89,12 +74,6 @@
remote-notification
-
- $SENDER_ID
-
-
-
-
development
@@ -105,19 +84,14 @@
-
-
-
-
-
+
-
-
+
-
\ No newline at end of file
+
diff --git a/push.gradle b/push.gradle
index 11e735ae7..1a410b982 100644
--- a/push.gradle
+++ b/push.gradle
@@ -8,6 +8,10 @@ def doExtractStringFromManifest(name) {
return matcher.group(1)
}
+cdvPluginPostBuildExtras << {
+ apply plugin: 'com.google.gms.google-services'
+}
+
android {
sourceSets {
main {
diff --git a/scripts/copyAndroidFile.js b/scripts/copyAndroidFile.js
new file mode 100644
index 000000000..b493c3a19
--- /dev/null
+++ b/scripts/copyAndroidFile.js
@@ -0,0 +1,22 @@
+module.exports = function(ctx) {
+ var fs = ctx.requireCordovaModule('fs'),
+ path = ctx.requireCordovaModule('path'),
+ os = require("os"),
+ readline = require("readline"),
+ deferral = ctx.requireCordovaModule('q').defer();
+
+ var lineReader = readline.createInterface({
+ terminal: false,
+ input : fs.createReadStream('platforms/android/build.gradle')
+ });
+ lineReader.on("line", function(line) {
+ fs.appendFileSync('./build.gradle', line.toString() + os.EOL);
+ if (/.*\ dependencies \{.*/.test(line)) {
+ fs.appendFileSync('./build.gradle', '\t\tclasspath "com.google.gms:google-services:3.0.0"' + os.EOL);
+ }
+ }).on("close", function () {
+ fs.rename('./build.gradle', 'platforms/android/build.gradle', deferral.resolve);
+ });
+
+ return deferral.promise;
+};
diff --git a/spec/index.spec.js b/spec/index.spec.js
index 8e1c26657..e41accd2b 100644
--- a/spec/index.spec.js
+++ b/spec/index.spec.js
@@ -193,7 +193,7 @@ describe('phonegap-plugin-push', function () {
push.off('notification', eventHandler);
- expect(push._handlers.notification.indexOf(eventHandler)).toEqual(-1);
+ expect(push.handlers.notification.indexOf(eventHandler)).toEqual(-1);
done();
});
});
@@ -208,7 +208,7 @@ describe('phonegap-plugin-push', function () {
push.off('registration', eventHandler);
- expect(push._handlers.registration.indexOf(eventHandler)).toEqual(-1);
+ expect(push.handlers.registration.indexOf(eventHandler)).toEqual(-1);
done();
});
});
@@ -222,7 +222,7 @@ describe('phonegap-plugin-push', function () {
push.on('error', eventHandler);
push.off('error', eventHandler);
- expect(push._handlers.error.indexOf(eventHandler)).toEqual(-1);
+ expect(push.handlers.error.indexOf(eventHandler)).toEqual(-1);
done();
});
});
@@ -233,19 +233,19 @@ describe('phonegap-plugin-push', function () {
eventHandler = function () {
};
- expect(push._handlers.registration.length).toEqual(0);
+ 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);
+ 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);
+ expect(push.handlers.registration.length).toEqual(0);
+ expect(push.handlers.registration.indexOf(eventHandler)).toEqual(-1);
done();
});
});
@@ -255,19 +255,19 @@ describe('phonegap-plugin-push', function () {
eventHandler = function () {
};
- expect(push._handlers.notification.length).toEqual(0);
+ 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);
+ 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);
+ expect(push.handlers.notification.length).toEqual(0);
+ expect(push.handlers.notification.indexOf(eventHandler)).toEqual(-1);
done();
});
});
@@ -277,19 +277,19 @@ describe('phonegap-plugin-push', function () {
eventHandler = function () {
};
- expect(push._handlers.error.length).toEqual(0);
+ 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);
+ 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);
+ expect(push.handlers.error.length).toEqual(0);
+ expect(push.handlers.error.indexOf(eventHandler)).toEqual(-1);
done();
});
});
@@ -301,21 +301,21 @@ describe('phonegap-plugin-push', function () {
eventHandler = function () {
};
- expect(push._handlers.registration.length).toEqual(0);
+ 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);
+ 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);
+ expect(push.handlers.registration.length).toEqual(1);
+ expect(push.handlers.registration.indexOf(eventHandler)).toBeGreaterThan(-1);
done();
- }, null, ['foo', 'bar']);
+ }, function() {}, ['foo', 'bar']);
});
it('should not clear "notification" event handlers', function (done) {
@@ -323,21 +323,21 @@ describe('phonegap-plugin-push', function () {
eventHandler = function () {
};
- expect(push._handlers.notification.length).toEqual(0);
+ 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);
+ 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);
+ expect(push.handlers.notification.length).toEqual(1);
+ expect(push.handlers.notification.indexOf(eventHandler)).toBeGreaterThan(-1);
done();
- }, null, ['foo', 'bar']);
+ }, function() {}, ['foo', 'bar']);
});
it('should not clear "error" event handlers', function (done) {
@@ -345,21 +345,21 @@ describe('phonegap-plugin-push', function () {
eventHandler = function () {
};
- expect(push._handlers.error.length).toEqual(0);
+ 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);
+ 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);
+ expect(push.handlers.error.length).toEqual(1);
+ expect(push.handlers.error.indexOf(eventHandler)).toBeGreaterThan(-1);
done();
- }, null, ['foo', 'bar']);
+ }, function() {}, ['foo', 'bar']);
});
});
diff --git a/src/android/com/adobe/phonegap/push/BackgroundActionButtonHandler.java b/src/android/com/adobe/phonegap/push/BackgroundActionButtonHandler.java
index 4802e606b..4456f5255 100644
--- a/src/android/com/adobe/phonegap/push/BackgroundActionButtonHandler.java
+++ b/src/android/com/adobe/phonegap/push/BackgroundActionButtonHandler.java
@@ -19,7 +19,7 @@ public void onReceive(Context context, Intent intent) {
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);
+ notificationManager.cancel(FCMService.getAppName(context), notId);
if (extras != null) {
Bundle originalExtras = extras.getBundle(PUSH_BUNDLE);
diff --git a/src/android/com/adobe/phonegap/push/GCMIntentService.java b/src/android/com/adobe/phonegap/push/FCMService.java
similarity index 97%
rename from src/android/com/adobe/phonegap/push/GCMIntentService.java
rename to src/android/com/adobe/phonegap/push/FCMService.java
index f8bbf37ed..394733308 100644
--- a/src/android/com/adobe/phonegap/push/GCMIntentService.java
+++ b/src/android/com/adobe/phonegap/push/FCMService.java
@@ -28,7 +28,8 @@
import android.text.Spanned;
import android.util.Log;
-import com.google.android.gms.gcm.GcmListenerService;
+import com.google.firebase.messaging.FirebaseMessagingService;
+import com.google.firebase.messaging.RemoteMessage;
import org.json.JSONArray;
import org.json.JSONException;
@@ -41,12 +42,13 @@
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
+import java.util.Map;
import java.util.Random;
@SuppressLint("NewApi")
-public class GCMIntentService extends GcmListenerService implements PushConstants {
+public class FCMService extends FirebaseMessagingService implements PushConstants {
- private static final String LOG_TAG = "Push_GCMIntentService";
+ private static final String LOG_TAG = "Push_FCMService";
private static HashMap> messageMap = new HashMap>();
public void setNotification(int notId, String message){
@@ -64,9 +66,21 @@ public void setNotification(int notId, String message){
}
@Override
- public void onMessageReceived(String from, Bundle extras) {
+ public void onMessageReceived(RemoteMessage message){
+
+ String from = message.getFrom();
Log.d(LOG_TAG, "onMessage - from: " + from);
+ Bundle extras = new Bundle();
+
+ if (message.getNotification()!=null) {
+ extras.putString(TITLE,message.getNotification().getTitle());
+ extras.putString(MESSAGE,message.getNotification().getBody());
+ }
+ for (Map.Entry entry : message.getData().entrySet()) {
+ extras.putString(entry.getKey(), entry.getValue());
+ }
+
if (extras != null && isAvailableSender(from)) {
Context applicationContext = getApplicationContext();
diff --git a/src/android/com/adobe/phonegap/push/PushConstants.java b/src/android/com/adobe/phonegap/push/PushConstants.java
index 33c6fcdd8..a5fbb5d33 100644
--- a/src/android/com/adobe/phonegap/push/PushConstants.java
+++ b/src/android/com/adobe/phonegap/push/PushConstants.java
@@ -55,7 +55,7 @@ public interface PushConstants {
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 FCM = "FCM";
public static final String CONTENT_AVAILABLE = "content-available";
public static final String TOPICS = "topics";
public static final String SET_APPLICATION_ICON_BADGE_NUMBER = "setApplicationIconBadgeNumber";
@@ -79,4 +79,6 @@ public interface PushConstants {
public static final String IMAGE_TYPE_SQUARE = "square";
public static final String IMAGE_TYPE_CIRCLE = "circle";
public static final String SUBJECT = "subject";
+ public static final String GOOGLE_APP_ID = "google_app_id";
+ public static final String GCM_DEFAULT_SENDER_ID = "gcm_defaultSenderId";
}
diff --git a/src/android/com/adobe/phonegap/push/PushHandlerActivity.java b/src/android/com/adobe/phonegap/push/PushHandlerActivity.java
index 3099aa6d4..0d399a619 100644
--- a/src/android/com/adobe/phonegap/push/PushHandlerActivity.java
+++ b/src/android/com/adobe/phonegap/push/PushHandlerActivity.java
@@ -21,7 +21,7 @@ public class PushHandlerActivity extends Activity implements PushConstants {
*/
@Override
public void onCreate(Bundle savedInstanceState) {
- GCMIntentService gcm = new GCMIntentService();
+ FCMService gcm = new FCMService();
Intent intent = getIntent();
@@ -39,7 +39,7 @@ public void onCreate(Bundle savedInstanceState) {
if(!startOnBackground){
NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
- notificationManager.cancel(GCMIntentService.getAppName(this), notId);
+ notificationManager.cancel(FCMService.getAppName(this), notId);
}
boolean isPushPluginActive = PushPlugin.isActive();
diff --git a/src/android/com/adobe/phonegap/push/PushInstanceIDListenerService.java b/src/android/com/adobe/phonegap/push/PushInstanceIDListenerService.java
index 690d66794..176b7419a 100644
--- a/src/android/com/adobe/phonegap/push/PushInstanceIDListenerService.java
+++ b/src/android/com/adobe/phonegap/push/PushInstanceIDListenerService.java
@@ -5,23 +5,22 @@
import android.content.SharedPreferences;
import android.util.Log;
-import com.google.android.gms.iid.InstanceID;
-import com.google.android.gms.iid.InstanceIDListenerService;
+import com.google.firebase.iid.FirebaseInstanceId;
+import com.google.firebase.iid.FirebaseInstanceIdService;
import org.json.JSONException;
import java.io.IOException;
-public class PushInstanceIDListenerService extends InstanceIDListenerService implements PushConstants {
- public static final String LOG_TAG = "Push_InstanceIDListener";
+public class PushInstanceIDListenerService extends FirebaseInstanceIdService implements PushConstants {
+ public static final String LOG_TAG = "Push_InsIdService";
@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);
- }
+ // Get updated InstanceID token.
+ String refreshedToken = FirebaseInstanceId.getInstance().getToken();
+ Log.d(LOG_TAG, "Refreshed token: " + refreshedToken);
+ // TODO: Implement this method to send any registration to your app's servers.
+ //sendRegistrationToServer(refreshedToken);
}
}
diff --git a/src/android/com/adobe/phonegap/push/PushPlugin.java b/src/android/com/adobe/phonegap/push/PushPlugin.java
index b6e1e050b..f4c703701 100644
--- a/src/android/com/adobe/phonegap/push/PushPlugin.java
+++ b/src/android/com/adobe/phonegap/push/PushPlugin.java
@@ -1,13 +1,14 @@
package com.adobe.phonegap.push;
+import android.app.Activity;
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 com.google.firebase.iid.FirebaseInstanceId;
+import com.google.firebase.messaging.FirebaseMessaging;
import org.apache.cordova.CallbackContext;
import org.apache.cordova.CordovaInterface;
@@ -59,6 +60,7 @@ public void run() {
Log.v(LOG_TAG, "execute: data=" + data.toString());
SharedPreferences sharedPref = getApplicationContext().getSharedPreferences(COM_ADOBE_PHONEGAP_PUSH, Context.MODE_PRIVATE);
+ String token = null;
String senderID = null;
try {
@@ -66,14 +68,18 @@ public void run() {
Log.v(LOG_TAG, "execute: jo=" + jo.toString());
- senderID = jo.getString(SENDER_ID);
+ senderID = getStringResourceByName(GCM_DEFAULT_SENDER_ID);
Log.v(LOG_TAG, "execute: senderID=" + senderID);
- registration_id = InstanceID.getInstance(getApplicationContext()).getToken(senderID, GCM);
+ token = FirebaseInstanceId.getInstance().getToken();
- if (!"".equals(registration_id)) {
- JSONObject json = new JSONObject().put(REGISTRATION_ID, registration_id);
+ if (token == null) {
+ token = FirebaseInstanceId.getInstance().getToken(senderID,FCM);
+ }
+
+ if (!"".equals(token)) {
+ JSONObject json = new JSONObject().put(REGISTRATION_ID, token);
Log.v(LOG_TAG, "onRegistered: " + json.toString());
@@ -82,14 +88,14 @@ public void run() {
PushPlugin.sendEvent( json );
} else {
- callbackContext.error("Empty registration ID received from GCM");
+ callbackContext.error("Empty registration ID received from FCM");
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());
+ Log.e(LOG_TAG, "execute: Got IO Exception " + e.getMessage());
callbackContext.error(e.getMessage());
}
@@ -144,7 +150,7 @@ public void run() {
if (topics != null && !"".equals(registration_id)) {
unsubscribeFromTopics(topics, registration_id);
} else {
- InstanceID.getInstance(getApplicationContext()).deleteInstanceID();
+ FirebaseInstanceId.getInstance().deleteInstanceId();
Log.v(LOG_TAG, "UNREGISTER");
// Remove shared prefs
@@ -220,8 +226,6 @@ public void run() {
callbackContext.success();
} catch (JSONException e) {
callbackContext.error(e.getMessage());
- } catch (IOException e) {
- callbackContext.error(e.getMessage());
}
}
});
@@ -235,8 +239,6 @@ public void run() {
callbackContext.success();
} catch (JSONException e) {
callbackContext.error(e.getMessage());
- } catch (IOException e) {
- callbackContext.error(e.getMessage());
}
}
});
@@ -339,28 +341,7 @@ private void clearAllNotifications() {
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) {
- if (topic.startsWith("/topics/")) {
- return topic;
- } else if (topic.startsWith("/topic/")) {
- return topic.replace("/topic/", "/topics/");
- } else {
- return "/topics/" + topic;
- }
- }
-
- private void subscribeToTopics(JSONArray topics, String registrationToken) throws IOException {
+ private void subscribeToTopics(JSONArray topics, String registrationToken) {
if (topics != null) {
String topic = null;
for (int i=0; i
+@interface PushPlugin : CDVPlugin
{
NSDictionary *notificationMessage;
BOOL isInline;
@@ -68,13 +68,12 @@
- (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;
+// FCM Features
+@property(nonatomic, assign) BOOL usesFCM;
+@property(nonatomic, strong) NSNumber *fcmSandbox;
+@property(nonatomic, strong) NSString *fcmSenderId;
+@property(nonatomic, strong) NSDictionary *fcmRegistrationOptions;
+@property(nonatomic, strong) NSString *fcmRegistrationToken;
+@property(nonatomic, strong) NSArray *fcmTopics;
@end
diff --git a/src/ios/PushPlugin.m b/src/ios/PushPlugin.m
index a176b9af5..2ed79fc6c 100644
--- a/src/ios/PushPlugin.m
+++ b/src/ios/PushPlugin.m
@@ -27,8 +27,9 @@
#define GMP_NO_MODULES true
#import "PushPlugin.h"
-#import "GoogleCloudMessaging.h"
-#import "GGLInstanceIDHeaders.h"
+@import FirebaseInstanceID;
+@import FirebaseMessaging;
+@import FirebaseAnalytics;
@implementation PushPlugin : CDVPlugin
@@ -42,78 +43,60 @@ @implementation PushPlugin : CDVPlugin
@synthesize clearBadge;
@synthesize handlerObj;
-@synthesize usesGCM;
-@synthesize gcmSandbox;
-@synthesize gcmSenderId;
-@synthesize gcmRegistrationOptions;
-@synthesize gcmRegistrationHandler;
-@synthesize gcmRegistrationToken;
-@synthesize gcmTopics;
+@synthesize usesFCM;
+@synthesize fcmSandbox;
+@synthesize fcmSenderId;
+@synthesize fcmRegistrationOptions;
+@synthesize fcmRegistrationToken;
+@synthesize fcmTopics;
--(void)initGCMRegistrationHandler;
+-(void)initRegistration;
{
- __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);
- }
- }];
- }
+ NSString * registrationToken = [[FIRInstanceID instanceID] token];
+
+ if (registrationToken != nil) {
+ NSLog(@"FCM Registration Token: %@", registrationToken);
+ [self setFcmRegistrationToken: registrationToken];
+
+ id topics = [self fcmTopics];
+ if (topics != nil) {
+ for (NSString *topic in topics) {
+ NSLog(@"subscribe from topic: %@", topic);
+ id pubSub = [FIRMessaging messaging];
+ [pubSub subscribeToTopic:[NSString stringWithFormat:@"/topics/%@", topic]];
}
-
- [weakSelf registerWithToken:registrationToken];
- } else {
- NSLog(@"Registration to GCM failed with error: %@", error.localizedDescription);
- [weakSelf failWithMessage:self.callbackId withMsg:@"" withError:error];
}
- };
+
+ [self registerWithToken:registrationToken];
+ } else {
+ NSLog(@"FCM token is null");
+ }
+
}
-// GCM refresh token
+// FCM 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]];
+ NSLog(@"The FCM registration token needs to be changed.");
+ [[FIRInstanceID instanceID] token];
+ [self initRegistration];
#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
- }
+// contains error info
+- (void)sendDataMessageFailure:(NSNotification *)notification {
+ NSString *messageID = (NSString *)notification.object;
+ NSDictionary *userInfo = notification.userInfo;
+ NSLog(@"sendDataMessageFailure");
+ // Did fail send message
}
-
-- (void)didSendDataMessageWithID:(NSString *)messageID {
- NSLog(@"willSendDataMessageWithID");
- // Did successfully send message identified by messageID
+- (void)sendDataMessageSuccess:(NSNotification *)notification {
+ NSString *messageID = (NSString *)notification.object;
+ NSDictionary *userInfo = notification.userInfo;
+ NSLog(@"sendDataMessageSuccess");
+ // Did successfully send message
}
- (void)didDeleteMessagesOnServer {
@@ -128,20 +111,10 @@ - (void)unregister:(CDVInvokedUrlCommand*)command;
NSArray* topics = [command argumentAtIndex:0];
if (topics != nil) {
- id pubSub = [GCMPubSub sharedInstance];
+ id pubSub = [FIRMessaging messaging];
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);
- }
- }];
+ [pubSub unsubscribeFromTopic:topic];
}
} else {
[[UIApplication sharedApplication] unregisterForRemoteNotifications];
@@ -155,25 +128,10 @@ - (void)subscribe:(CDVInvokedUrlCommand*)command;
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]];
- }
- }];
+ id pubSub = [FIRMessaging messaging];
+ [pubSub subscribeToTopic:[NSString stringWithFormat:@"/topics/%@", topic]];
+ 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"];
@@ -186,19 +144,10 @@ - (void)unsubscribe:(CDVInvokedUrlCommand*)command;
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]];
- }
- }];
+ id pubSub = [FIRMessaging messaging];
+ [pubSub unsubscribeFromTopic:[NSString stringWithFormat:@"/topics/%@", topic]];
+ NSLog(@"Successfully unsubscribe to topic %@", topic);
+ [self successWithMessage:command.callbackId withMsg:[NSString stringWithFormat:@"Successfully unsubscribe from topic %@", topic]];
} else {
NSLog(@"There is no topic to unsubscribe");
[self successWithMessage:command.callbackId withMsg:@"There is no topic to unsubscribe"];
@@ -207,6 +156,22 @@ - (void)unsubscribe:(CDVInvokedUrlCommand*)command;
- (void)init:(CDVInvokedUrlCommand*)command;
{
+ [[NSNotificationCenter defaultCenter]
+ addObserver:self selector:@selector(onTokenRefresh)
+ name:kFIRInstanceIDTokenRefreshNotification object:nil];
+
+ [[NSNotificationCenter defaultCenter]
+ addObserver:self selector:@selector(sendDataMessageFailure:)
+ name:FIRMessagingSendErrorNotification object:nil];
+
+ [[NSNotificationCenter defaultCenter]
+ addObserver:self selector:@selector(sendDataMessageSuccess:)
+ name:FIRMessagingSendSuccessNotification object:nil];
+
+ [[NSNotificationCenter defaultCenter]
+ addObserver:self selector:@selector(didDeleteMessagesOnServer)
+ name:FIRMessagingMessagesDeletedNotification object:nil];
+
[self.commandDelegate runInBackground:^ {
NSLog(@"Push Plugin register called");
@@ -215,8 +180,8 @@ - (void)init:(CDVInvokedUrlCommand*)command;
NSMutableDictionary* options = [command.arguments objectAtIndex:0];
NSMutableDictionary* iosOptions = [options objectForKey:@"ios"];
- NSArray* topics = [iosOptions objectForKey:@"topics"];
- [self setGcmTopics:topics];
+ NSArray* topics = [iosOptions objectForKey:@"topics"];
+ [self setFcmTopics:topics];
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 80000
UIUserNotificationType UserNotificationTypes = UIUserNotificationTypeNone;
@@ -348,26 +313,39 @@ - (void)init:(CDVInvokedUrlCommand*)command;
(UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert)];
#endif
+
+ // Read GoogleService-Info.plist
+ NSString *path = [[NSBundle mainBundle] pathForResource:@"GoogleService-Info" ofType:@"plist"];
+
+ // Load the file content and read the data into arrays
+ NSDictionary *dict = [[NSDictionary alloc] initWithContentsOfFile:path];
+ fcmSenderId = [dict objectForKey:@"GCM_SENDER_ID"];
+
+ NSLog(@"FCM Sender ID %@", fcmSenderId);
+
// 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];
+ [self setFcmSenderId: fcmSenderId];
+ if([[self fcmSenderId] length] > 0) {
+ NSLog(@"Using FCM Notification");
+ [self setUsesFCM: YES];
+ dispatch_async(dispatch_get_main_queue(), ^{
+ if([FIRApp defaultApp] == nil)
+ [FIRApp configure];
+ [self initRegistration];
+ });
} else {
NSLog(@"Using APNS Notification");
- [self setUsesGCM:NO];
+ [self setUsesFCM:NO];
}
- id gcmSandBoxArg = [iosOptions objectForKey:@"gcmSandbox"];
+ id fcmSandboxArg = [iosOptions objectForKey:@"fcmSandbox"];
- [self setGcmSandbox:@NO];
- if ([self usesGCM] &&
- (([gcmSandBoxArg isKindOfClass:[NSString class]] && [gcmSandBoxArg isEqualToString:@"true"]) ||
- [gcmSandBoxArg boolValue]))
+ [self setFcmSandbox:@NO];
+ if ([self usesFCM] &&
+ (([fcmSandboxArg isKindOfClass:[NSString class]] && [fcmSandboxArg isEqualToString:@"true"]) ||
+ [fcmSandboxArg boolValue]))
{
- NSLog(@"Using GCM Sandbox");
- [self setGcmSandbox:@YES];
+ NSLog(@"Using FCM Sandbox");
+ [self setFcmSandbox:@YES];
}
if (notificationMessage) { // if there is a pending startup notification
@@ -460,24 +438,7 @@ - (void)didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
[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 {
+ if(![self usesFCM]) {
[self registerWithToken: token];
}
#endif
diff --git a/src/js/push.js b/src/js/push.js
new file mode 100644
index 000000000..150af3441
--- /dev/null
+++ b/src/js/push.js
@@ -0,0 +1,316 @@
+/* global cordova:false */
+/* globals window */
+
+/*!
+ * Module dependencies.
+ */
+
+const exec = cordova.require('cordova/exec');
+
+class PushNotification {
+ /**
+ * PushNotification constructor.
+ *
+ * @param {Object} options to initiate Push Notifications.
+ * @return {PushNotification} instance that can be monitored and cancelled.
+ */
+ constructor(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
+ const success = (result) => {
+ if (result && typeof result.registrationId !== 'undefined') {
+ this.emit('registration', result);
+ } else if (result && result.additionalData &&
+ typeof result.additionalData.actionCallback !== 'undefined') {
+ const executeFuctionOrEmitEventByName = (functionName, context, ...args) => {
+ const namespaces = functionName.split('.');
+ const func = namespaces.pop();
+ for (let i = 0; i < namespaces.length; i++) {
+ context = context[namespaces[i]];
+ }
+
+ if (typeof context[func] === 'function') {
+ context[func].call(context, args);
+ } else {
+ this.emit(functionName, args);
+ }
+ };
+
+ executeFuctionOrEmitEventByName(result.additionalData.actionCallback, window, result);
+ } else if (result) {
+ this.emit('notification', result);
+ }
+ };
+
+ // triggered on error
+ const fail = (msg) => {
+ const e = (typeof msg === 'string') ? new Error(msg) : msg;
+ this.emit('error', e);
+ };
+
+ // wait at least one process tick to allow event subscriptions
+ setTimeout(() => {
+ exec(success, fail, 'PushNotification', 'init', [options]);
+ }, 10);
+ }
+
+ /**
+ * Unregister from push notifications
+ */
+ unregister(successCallback, errorCallback = () => {}, options) {
+ 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;
+ }
+
+ const cleanHandlersAndPassThrough = () => {
+ if (!options) {
+ this.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}
+ */
+ subscribe(topic, successCallback, errorCallback = () => {}) {
+ 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}
+ */
+ unsubscribe(topic, successCallback, errorCallback = () => {}) {
+ 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
+ */
+ setApplicationIconBadgeNumber(successCallback, errorCallback = () => {}, badge) {
+ 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 }]);
+ }
+
+ /**
+ * Get the application icon badge
+ */
+
+ getApplicationIconBadgeNumber(successCallback, errorCallback = () => {}) {
+ 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', []);
+ }
+
+ /**
+ * Clear all notifications
+ */
+
+ clearAllNotifications(successCallback = () => {}, errorCallback = () => {}) {
+ 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.
+ *
+ * The following events are supported:
+ *
+ * - registration
+ * - notification
+ * - error
+ *
+ * @param {String} eventName to subscribe to.
+ * @param {Function} callback triggered on the event.
+ */
+
+ on(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.
+ */
+
+ off(eventName, handle) {
+ if (this.handlers.hasOwnProperty(eventName)) {
+ const 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.
+ */
+
+ emit(...args) {
+ const eventName = args.shift();
+
+ if (!this.handlers.hasOwnProperty(eventName)) {
+ return false;
+ }
+
+ for (let i = 0, length = this.handlers[eventName].length; i < length; i++) {
+ const 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;
+ }
+
+ finish(successCallback = () => {}, errorCallback = () => {}, 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: (options) => {
+ return new PushNotification(options);
+ },
+
+ hasPermission: (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,
+};
diff --git a/www/push.js b/www/push.js
index 58c686d32..e327da76d 100644
--- a/www/push.js
+++ b/www/push.js
@@ -1,3 +1,15 @@
+/**
+* This file has been generated by Babel.
+*
+* DO NOT EDIT IT DIRECTLY
+*
+* Edit the JS source file src/js/push.js
+**/'use strict';
+
+var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
+
+function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
+
/* global cordova:false */
/* globals window */
@@ -7,320 +19,357 @@
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': []
+var PushNotification = function () {
+ /**
+ * PushNotification constructor.
+ *
+ * @param {Object} options to initiate Push Notifications.
+ * @return {PushNotification} instance that can be monitored and cancelled.
+ */
+ function PushNotification(options) {
+ var _this = this;
+
+ _classCallCheck(this, PushNotification);
+
+ this.handlers = {
+ registration: [],
+ notification: [],
+ error: []
};
// require options parameter
if (typeof options === 'undefined') {
- throw new Error('The options argument is required.');
+ 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);
- }
+ var success = function success(result) {
+ if (result && typeof result.registrationId !== 'undefined') {
+ _this.emit('registration', result);
+ } else if (result && result.additionalData && typeof result.additionalData.actionCallback !== 'undefined') {
+ var executeFuctionOrEmitEventByName = function executeFuctionOrEmitEventByName(functionName, context) {
+ for (var _len = arguments.length, args = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
+ args[_key - 2] = arguments[_key];
+ }
+
+ var namespaces = functionName.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, args);
+ } else {
+ _this.emit(functionName, args);
+ }
+ };
+
+ executeFuctionOrEmitEventByName(result.additionalData.actionCallback, window, result);
+ } else if (result) {
+ _this.emit('notification', result);
+ }
};
// triggered on error
- var fail = function(msg) {
- var e = (typeof msg === 'string') ? new Error(msg) : msg;
- that.emit('error', e);
+ var fail = function fail(msg) {
+ var e = typeof msg === 'string' ? new Error(msg) : msg;
+ _this.emit('error', e);
};
// wait at least one process tick to allow event subscriptions
- setTimeout(function() {
- exec(success, fail, 'PushNotification', 'init', [options]);
+ setTimeout(function () {
+ exec(success, fail, 'PushNotification', 'init', [options]);
}, 10);
-};
+ }
-/**
- * Unregister from push notifications
- */
+ /**
+ * Unregister from push notifications
+ */
+
+
+ _createClass(PushNotification, [{
+ key: 'unregister',
+ value: function unregister(successCallback) {
+ var _this2 = this;
-PushNotification.prototype.unregister = function(successCallback, errorCallback, options) {
- if (!errorCallback) { errorCallback = function() {}; }
+ var errorCallback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function () {};
+ var options = arguments[2];
- if (typeof 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');
+ if (typeof successCallback !== 'function') {
+ console.log('PushNotification.unregister failure: success callback parameter ' + ' must be a function');
return;
- }
+ }
- var that = this;
- var cleanHandlersAndPassThrough = function() {
+ var cleanHandlersAndPassThrough = function cleanHandlersAndPassThrough() {
if (!options) {
- that._handlers = {
- 'registration': [],
- 'notification': [],
- 'error': []
- };
+ _this2.handlers = {
+ registration: [],
+ notification: [],
+ error: []
+ };
}
successCallback();
- };
+ };
- exec(cleanHandlersAndPassThrough, errorCallback, 'PushNotification', 'unregister', [options]);
-};
+ 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() {}; }
+ /**
+ * subscribe to a topic
+ * @param {String} topic topic to subscribe
+ * @param {Function} successCallback success callback
+ * @param {Function} errorCallback error callback
+ * @return {void}
+ */
+
+ }, {
+ key: 'subscribe',
+ value: function subscribe(topic, successCallback) {
+ var errorCallback = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : function () {};
- if (typeof errorCallback !== 'function') {
- console.log('PushNotification.subscribe failure: failure parameter not a 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');
+ if (typeof successCallback !== 'function') {
+ console.log('PushNotification.subscribe failure: ' + 'success callback parameter must be a function');
return;
+ }
+
+ exec(successCallback, errorCallback, 'PushNotification', 'subscribe', [topic]);
}
- 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}
+ */
-/**
- * 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() {}; }
+ }, {
+ key: 'unsubscribe',
+ value: function unsubscribe(topic, successCallback) {
+ var errorCallback = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : function () {};
- if (typeof 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');
+ if (typeof successCallback !== 'function') {
+ console.log('PushNotification.unsubscribe failure: ' + 'success callback parameter must be a function');
return;
- }
+ }
- exec(successCallback, errorCallback, 'PushNotification', 'unsubscribe', [topic]);
-};
+ exec(successCallback, errorCallback, 'PushNotification', 'unsubscribe', [topic]);
+ }
-/**
- * Call this to set the application icon badge
- */
+ /**
+ * Call this to set the application icon badge
+ */
-PushNotification.prototype.setApplicationIconBadgeNumber = function(successCallback, errorCallback, badge) {
- if (!errorCallback) { errorCallback = function() {}; }
+ }, {
+ key: 'setApplicationIconBadgeNumber',
+ value: function setApplicationIconBadgeNumber(successCallback) {
+ var errorCallback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function () {};
+ var badge = arguments[2];
- if (typeof errorCallback !== 'function') {
- console.log('PushNotification.setApplicationIconBadgeNumber failure: failure parameter not a 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');
+ if (typeof successCallback !== 'function') {
+ console.log('PushNotification.setApplicationIconBadgeNumber failure: success ' + 'callback parameter must be a function');
return;
- }
+ }
- exec(successCallback, errorCallback, 'PushNotification', 'setApplicationIconBadgeNumber', [{badge: badge}]);
-};
+ exec(successCallback, errorCallback, 'PushNotification', 'setApplicationIconBadgeNumber', [{ badge: badge }]);
+ }
-/**
- * Get the application icon badge
- */
+ /**
+ * Get the application icon badge
+ */
-PushNotification.prototype.getApplicationIconBadgeNumber = function(successCallback, errorCallback) {
- if (!errorCallback) { errorCallback = function() {}; }
+ }, {
+ key: 'getApplicationIconBadgeNumber',
+ value: function getApplicationIconBadgeNumber(successCallback) {
+ var errorCallback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function () {};
- if (typeof errorCallback !== 'function') {
- console.log('PushNotification.getApplicationIconBadgeNumber failure: failure parameter not a 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');
+ if (typeof successCallback !== 'function') {
+ console.log('PushNotification.getApplicationIconBadgeNumber failure: success ' + 'callback parameter must be a function');
return;
- }
+ }
- exec(successCallback, errorCallback, 'PushNotification', 'getApplicationIconBadgeNumber', []);
-};
+ exec(successCallback, errorCallback, 'PushNotification', 'getApplicationIconBadgeNumber', []);
+ }
-/**
- * Get the application icon badge
- */
+ /**
+ * Clear all notifications
+ */
-PushNotification.prototype.clearAllNotifications = function(successCallback, errorCallback) {
- if (!successCallback) { successCallback = function() {}; }
- if (!errorCallback) { errorCallback = function() {}; }
+ }, {
+ key: 'clearAllNotifications',
+ value: function clearAllNotifications() {
+ var successCallback = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : function () {};
+ var errorCallback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function () {};
- if (typeof errorCallback !== 'function') {
- console.log('PushNotification.clearAllNotifications failure: failure parameter not a 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');
+ 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.
- */
+ exec(successCallback, errorCallback, 'PushNotification', 'clearAllNotifications', []);
+ }
+ /**
+ * 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] = [];
+ }, {
+ key: 'on',
+ value: function on(eventName, callback) {
+ if (!this.handlers.hasOwnProperty(eventName)) {
+ this.handlers[eventName] = [];
+ }
+ this.handlers[eventName].push(callback);
}
- this._handlers[eventName].push(callback);
-};
-/**
- * Remove event listener.
- *
- * @param {String} eventName to match subscription.
- * @param {Function} handle function associated with event.
- */
+ /**
+ * 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);
+ }, {
+ key: 'off',
+ value: function off(eventName, handle) {
+ if (this.handlers.hasOwnProperty(eventName)) {
+ var handleIndex = this.handlers[eventName].indexOf(handle);
if (handleIndex >= 0) {
- this._handlers[eventName].splice(handleIndex, 1);
+ 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.
- */
+ /**
+ * 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();
+ }, {
+ key: 'emit',
+ value: function emit() {
+ for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
+ args[_key2] = arguments[_key2];
+ }
- if (!this._handlers.hasOwnProperty(eventName)) {
+ 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];
+ 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);
+ callback.apply(undefined, args);
} else {
- console.log('event handler: ' + eventName + ' must be a function');
+ 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') {
+ return true;
+ }
+ }, {
+ key: 'finish',
+ value: function finish() {
+ var successCallback = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : function () {};
+ var errorCallback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function () {};
+ var id = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'handler';
+
+ if (typeof successCallback !== 'function') {
console.log('finish failure: success callback parameter must be a function');
return;
- }
+ }
- if (typeof errorCallback !== 'function') {
+ if (typeof errorCallback !== 'function') {
console.log('finish failure: failure parameter not a function');
return;
+ }
+
+ exec(successCallback, errorCallback, 'PushNotification', 'finish', [id]);
}
+ }]);
- exec(successCallback, errorCallback, 'PushNotification', 'finish', [id]);
-};
+ return PushNotification;
+}();
/*!
* 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
+ /**
+ * 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 init(options) {
+ return new PushNotification(options);
+ },
+
+ hasPermission: function hasPermission(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
};