forked from arnesson/cordova-plugin-firebase
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New vision for the installation of the plugin. Library dependencies a…
…re decided by the developer and not by the plugin. This is to improve the update of dependency libraries. In addition, some unpicked pull requests were included, due to the need for development. Improved Firebase Crashlitycs, adding non-fatal carsh tracking. Rewrite the documentation based on the official Firebase documentation.
- Loading branch information
Showing
204 changed files
with
1,286 additions
and
28,572 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
# Google Analytics for Firebase | ||
Official link https://firebase.google.com/docs/analytics/ | ||
|
||
|
||
## logEvent | ||
|
||
Log an event | ||
``` | ||
window.FirebasePlugin.logEvent("select_content", {content_type: "page_view", item_id: "home"}); | ||
``` | ||
|
||
## setScreenName | ||
|
||
Set the name of the current screen: | ||
``` | ||
window.FirebasePlugin.setScreenName("Home"); | ||
``` | ||
|
||
## setUserId | ||
|
||
Set a user id for use: | ||
``` | ||
window.FirebasePlugin.setUserId("user_id"); | ||
``` | ||
|
||
## setUserProperty | ||
|
||
Set a user property for use: | ||
``` | ||
window.FirebasePlugin.setUserProperty("name", "value"); | ||
``` | ||
|
||
## setAnalyticsCollectionEnabled | ||
|
||
Enable/disable analytics collection. | ||
|
||
``` | ||
window.FirebasePlugin.setAnalyticsCollectionEnabled(true/false); // Enables or disabled analytics collection | ||
``` | ||
|
||
<br> | ||
# Disable Analytics Collection | ||
### Permanently deactivate collection | ||
For more information read the documentation https://firebase.google.com/support/guides/disable-analytics | ||
|
||
#### Android | ||
If you need to deactivate Analytics collection permanently in a version of your app, set *firebase_analytics_collection_deactivated* to true in your app's AndroidManifest.xml in the application tag. For example: | ||
|
||
```xml | ||
<meta-data android:name="firebase_analytics_collection_deactivated" android:value="true" /> | ||
``` | ||
|
||
#### iOS | ||
If you need to deactivate Analytics collection permanently in a version of your app, set *FIREBASE_ANALYTICS_COLLECTION_DEACTIVATED* to YES in your app's Info.plist file. Setting *FIREBASE_ANALYTICS_COLLECTION_DEACTIVATED* to YES takes priority over any values for FIREBASE_ANALYTICS_COLLECTION_ENABLED in your app's Info.plist as well as any values set with setAnalyticsCollectionEnabled. | ||
|
||
To re-enable collection, remove *FIREBASE_ANALYTICS_COLLECTION_DEACTIVATED* from your Info.plist. Setting *FIREBASE_ANALYTICS_COLLECTION_DEACTIVATED* to NO has no effect and results in the same behavior as not having *FIREBASE_ANALYTICS_COLLECTION_DEACTIVATED* set in your Info.plist file. | ||
|
||
<br> | ||
### Disable Advertising ID collection | ||
#### Android | ||
If you wish to disable collection of the Advertising ID in your Android app, you can set the value of *google_analytics_adid_collection_enabled* to false in your app's AndroidManifest.xml in the application tag. For example: | ||
|
||
```xml | ||
<meta-data android:name="google_analytics_adid_collection_enabled" android:value="false" /> | ||
``` | ||
|
||
### iOS | ||
This feature does not exist. | ||
|
||
|
||
<br> | ||
# Debugging Events | ||
For more information read the documentation https://firebase.google.com/docs/analytics/debugview | ||
|
||
### Android | ||
For Android, enable or disable debugging using the adb command | ||
|
||
Enabled | ||
``` | ||
adb shell setprop debug.firebase.analytics.app <package_name> | ||
``` | ||
|
||
Disabled | ||
``` | ||
adb shell setprop debug.firebase.analytics.app .none. | ||
``` | ||
|
||
### iOS | ||
To enable Analytics Debug mode on your development device, specify the following command line argument in Xcode: | ||
|
||
1. In Xcode, select Product > Scheme > Edit scheme... | ||
2. Select Run from the left menu. | ||
3. Select the Arguments tab. | ||
4. In the Arguments Passed On Launch section, add -FIRAnalyticsDebugEnabled. | ||
|
||
Enabled | ||
``` | ||
-FIRDebugEnabled | ||
``` | ||
|
||
Disabled | ||
``` | ||
-FIRDebugDisabled | ||
``` | ||
You can also set this parameter using the Swift code, by inserting these lines in the *AppDelegate* file within the *didFinishLaunchingWithOptions* method. | ||
|
||
```swift | ||
var newArguments = ProcessInfo.processInfo.arguments | ||
newArguments.append("-FIRDebugEnabled") | ||
ProcessInfo.processInfo.setValue(newArguments, forKey: "arguments") | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
# Firebase Cloud Messaging | ||
Official link https://firebase.google.com/docs/cloud-messaging | ||
|
||
## getToken | ||
|
||
Get the device token (id): | ||
```js | ||
window.FirebasePlugin.getToken(function(token) { | ||
// save this server-side and use it to push notifications to this device | ||
console.log(token); | ||
}, function(error) { | ||
console.error(error); | ||
}); | ||
``` | ||
Note that token will be null if it has not been established yet | ||
|
||
## onTokenRefresh | ||
|
||
Register for token changes: | ||
```js | ||
window.FirebasePlugin.onTokenRefresh(function(token) { | ||
// save this server-side and use it to push notifications to this device | ||
console.log(token); | ||
}, function(error) { | ||
console.error(error); | ||
}); | ||
``` | ||
This is the best way to get a valid token for the device as soon as the token is established | ||
|
||
## onNotificationOpen | ||
|
||
Register notification callback: | ||
|
||
```js | ||
window.FirebasePlugin.onNotificationOpen(function(notification) { | ||
console.log(notification); | ||
}, function(error) { | ||
console.error(error); | ||
}); | ||
``` | ||
Notification flow: | ||
|
||
1. App is in foreground: | ||
1. User receives the notification data in the JavaScript callback without any notification on the device itself (this is the normal behaviour of push notifications, it is up to you, the developer, to notify the user) | ||
2. App is in background: | ||
1. User receives the notification message in its device notification bar | ||
2. User taps the notification and the app opens | ||
3. User receives the notification data in the JavaScript callback | ||
|
||
Notification icon on Android: | ||
|
||
[Changing notification icon](NOTIFICATIONS.md#changing-notification-icon) | ||
|
||
## grantPermission (iOS only) | ||
|
||
Grant permission to receive push notifications (will trigger prompt): | ||
|
||
```js | ||
window.FirebasePlugin.grantPermission(); | ||
``` | ||
## hasPermission | ||
|
||
Check permission to receive push notifications: | ||
|
||
```js | ||
window.FirebasePlugin.hasPermission(function(data){ | ||
console.log(data.isEnabled); | ||
}); | ||
``` | ||
|
||
## setBadgeNumber | ||
|
||
Set a number on the icon badge: | ||
|
||
```js | ||
window.FirebasePlugin.setBadgeNumber(3); | ||
``` | ||
|
||
Set 0 to clear the badge | ||
|
||
```js | ||
window.FirebasePlugin.setBadgeNumber(0); | ||
``` | ||
|
||
## getBadgeNumber | ||
|
||
Get icon badge number: | ||
|
||
```js | ||
window.FirebasePlugin.getBadgeNumber(function(n) { | ||
console.log(n); | ||
}); | ||
``` | ||
|
||
## clearAllNotifications | ||
|
||
Clear all pending notifications from the drawer: | ||
|
||
```js | ||
window.FirebasePlugin.clearAllNotifications(); | ||
``` | ||
|
||
## subscribe | ||
|
||
Subscribe to a topic: | ||
|
||
```js | ||
window.FirebasePlugin.subscribe("example"); | ||
``` | ||
|
||
## unsubscribe | ||
|
||
Unsubscribe from a topic: | ||
|
||
```js | ||
window.FirebasePlugin.unsubscribe("example"); | ||
``` | ||
|
||
## unregister | ||
|
||
Unregister from firebase, used to stop receiving push notifications. Call this when you logout user from your app. : | ||
|
||
```js | ||
window.FirebasePlugin.unregister(); | ||
``` |
Oops, something went wrong.