cordova-plugin-fcm-ng
Advanced tools
Comparing version 3.0.4 to 4.0.0
{ | ||
"version": "3.0.4", | ||
"version": "4.0.0", | ||
"name": "cordova-plugin-fcm-ng", | ||
@@ -4,0 +4,0 @@ "cordova_name": "Cordova FCM Push Plugin NG", |
# Google Firebase Cloud Messaging Cordova Push Plugin | ||
> Extremely easy plug&play push notification plugin for Cordova applications with Google Firebase FCM. | ||
#### Version 4.0.0 (06/28/2019) | ||
- Adds support for Google Analytics Events Tracking (`logEvent`, `setUserId` and `setUserProperty`). | ||
- This wrapper `@ionic-native/fcm` is not required any more. You need to install a new one [FCMNG](https://github.com/cmgustavo/fcm-ng) | ||
#### Version 3.0.4 (06/23/2019) | ||
@@ -16,3 +20,2 @@ - Upgrade Android plugin for Gradle, revision 1.1.3 (March 2015) | ||
- Added data payload parameter to check whether the user tapped on the notification or was received while in foreground. | ||
- **Free testing server available for free! https://cordova-plugin-fcm.appspot.com** | ||
@@ -44,3 +47,2 @@ ## Installation | ||
:warning: It's highly recommended to use REST API to send push notifications because Firebase console does not have all the functionalities. **Pay attention to the payload example in order to use the plugin properly**. | ||
You can also test your notifications with the free testing server: https://cordova-plugin-fcm.appspot.com | ||
@@ -50,5 +52,5 @@ #### Receiving Token Refresh | ||
```javascript | ||
//FCMPlugin.onTokenRefresh( onTokenRefreshCallback(token) ); | ||
//FCMPluginNG.onTokenRefresh( onTokenRefreshCallback(token) ); | ||
//Note that this callback will be fired everytime a new token is generated, including the first time. | ||
FCMPlugin.onTokenRefresh(function(token){ | ||
FCMPluginNG.onTokenRefresh(function(token){ | ||
alert( token ); | ||
@@ -61,5 +63,5 @@ }); | ||
```javascript | ||
//FCMPlugin.getToken( successCallback(token), errorCallback(err) ); | ||
//FCMPluginNG.getToken( successCallback(token), errorCallback(err) ); | ||
//Keep in mind the function will return null if the token has not been established yet. | ||
FCMPlugin.getToken(function(token){ | ||
FCMPluginNG.getToken(function(token){ | ||
alert(token); | ||
@@ -72,6 +74,6 @@ }); | ||
```javascript | ||
//FCMPlugin.subscribeToTopic( topic, successCallback(msg), errorCallback(err) ); | ||
//FCMPluginNG.subscribeToTopic( topic, successCallback(msg), errorCallback(err) ); | ||
//All devices are subscribed automatically to 'all' and 'ios' or 'android' topic respectively. | ||
//Must match the following regular expression: "[a-zA-Z0-9-_.~%]{1,900}". | ||
FCMPlugin.subscribeToTopic('topicExample'); | ||
FCMPluginNG.subscribeToTopic('topicExample'); | ||
``` | ||
@@ -82,4 +84,4 @@ | ||
```javascript | ||
//FCMPlugin.unsubscribeFromTopic( topic, successCallback(msg), errorCallback(err) ); | ||
FCMPlugin.unsubscribeFromTopic('topicExample'); | ||
//FCMPluginNG.unsubscribeFromTopic( topic, successCallback(msg), errorCallback(err) ); | ||
FCMPluginNG.unsubscribeFromTopic('topicExample'); | ||
``` | ||
@@ -90,5 +92,5 @@ | ||
```javascript | ||
//FCMPlugin.onNotification( onNotificationCallback(data), successCallback(msg), errorCallback(err) ) | ||
//FCMPluginNG.onNotification( onNotificationCallback(data), successCallback(msg), errorCallback(err) ) | ||
//Here you define your application behaviour based on the notification data. | ||
FCMPlugin.onNotification(function(data){ | ||
FCMPluginNG.onNotification(function(data){ | ||
if(data.wasTapped){ | ||
@@ -106,3 +108,2 @@ //Notification was received on device tray and tapped by the user. | ||
Full documentation: https://firebase.google.com/docs/cloud-messaging/http-server-ref | ||
Free testing server: https://cordova-plugin-fcm.appspot.com | ||
```javascript | ||
@@ -145,3 +146,26 @@ //POST: https://fcm.googleapis.com/fcm/send | ||
## Usage of Google Analytics Methods | ||
Every method returns a promise that fulfills when a call was successful. | ||
### logEvent(_name_, _params_) | ||
Logs an app event. | ||
```js | ||
FCMPluginNG.analytics.logEvent("my_event", {param1: "value1"}); | ||
``` | ||
Be aware of [automatically collected events](https://support.google.com/firebase/answer/6317485). | ||
### setUserId(_id_) | ||
Sets the user ID property. | ||
```js | ||
FCMPluginNG.setUserId("12345"); | ||
``` | ||
This feature must be used in accordance with [Google's Privacy Policy](https://www.google.com/policies/privacy). | ||
### setUserProperty(_name_, _value_) | ||
Sets a user property to a given value. | ||
```js | ||
FCMPluginNG.setUserProperty("name1", "value1"); | ||
``` | ||
## License | ||
@@ -148,0 +172,0 @@ ``` |
@@ -39,10 +39,21 @@ var exec = require('cordova/exec'); | ||
} | ||
// FIRE READY // | ||
exec(function(result){ console.log("FCMPlugin Ready OK") }, function(result){ console.log("FCMPlugin Ready ERROR") }, "FCMPlugin",'ready',[]); | ||
// Analytics Plugin | ||
FCMPlugin.prototype.logEvent = function(eventName, eventParams, success, error){ | ||
exec(success, error, 'FCMPlugin', 'logEvent', [eventName, eventParams || {}]); | ||
} | ||
FCMPlugin.prototype.setUserId = function(userId, success, error){ | ||
exec(success, error, 'FCMPlugin', 'setUserId', [userId]); | ||
} | ||
FCMPlugin.prototype.setUserProperty = function(name, value, success, error){ | ||
exec(success, error, 'FCMPlugin', 'setUserProperty', [name, value]); | ||
} | ||
// FIRE READY // | ||
exec(function(result){ console.log("FCMPlugin NG Ready OK") }, function(result){ console.log("FCMPlugin Ready ERROR") }, "FCMPlugin",'ready',[]); | ||
var fcmPlugin = new FCMPlugin(); | ||
module.exports = fcmPlugin; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
24778842
158
186