Gathering detailed insights and metrics for cordova-plugin-firebase-messaging
Gathering detailed insights and metrics for cordova-plugin-firebase-messaging
Gathering detailed insights and metrics for cordova-plugin-firebase-messaging
Gathering detailed insights and metrics for cordova-plugin-firebase-messaging
@firebase/messaging
This is the Firebase Cloud Messaging component of the Firebase JS SDK.
firebase
Firebase JavaScript library for web and Node.js
@firebase/messaging-interop-types
@firebase/messaging-interop-types Types
@firebase/messaging-compat
This is the compat package that recreates the v8 APIs.
npm install cordova-plugin-firebase-messaging
Module System
Unable to determine the module system for this package.
Min. Node Version
Typescript Support
Node Version
NPM Version
164 Stars
265 Commits
160 Forks
12 Watching
1 Branches
9 Contributors
Updated on 24 Jul 2024
Java (43.62%)
Objective-C (39.05%)
JavaScript (17.33%)
Cumulative downloads
Total Downloads
Last day
7.4%
420
Compared to previous day
Last week
-3.7%
2,072
Compared to previous week
Last month
4.4%
9,062
Compared to previous month
Last year
-11.3%
109,471
Compared to previous year
2
Your help is appreciated. Create a PR, submit a bug or just grab me :beer: |
---|
$ cordova plugin add cordova-plugin-firebase-messaging
If you get an error about CocoaPods being unable to find compatible versions, run
$ pod repo update
Use variables IOS_FIREBASE_POD_VERSION
and ANDROID_FIREBASE_BOM_VERSION
to override dependency versions on Android:
$ cordova plugin add cordova-plugin-firebase-messaging \
--variable IOS_FIREBASE_POD_VERSION="9.3.0" \
--variable ANDROID_FIREBASE_BOM_VERSION="30.3.1"
Cordova supports resource-file
tag for easy copying resources files. Firebase SDK requires google-services.json
on Android and GoogleService-Info.plist
on iOS platforms.
google-services.json
and/or GoogleService-Info.plist
into the root directory of your Cordova project1<platform name="android"> 2 ... 3 <resource-file src="google-services.json" target="app/google-services.json" /> 4</platform> 5... 6<platform name="ios"> 7 ... 8 <resource-file src="GoogleService-Info.plist" /> 9</platform>
This way config files will be copied on cordova prepare
step.
Setting a custom default icon allows you to specify what icon is used for notification messages if no icon is set in the notification payload. Also use the custom default icon to set the icon used by notification messages sent from the Firebase console. If no custom default icon is set and no icon is set in the notification payload, the application icon (rendered in white) is used.
1<platform name="android"> 2 ... 3 <config-file parent="/manifest/application" target="app/src/main/AndroidManifest.xml"> 4 <meta-data 5 android:name="com.google.firebase.messaging.default_notification_icon" 6 android:resource="@drawable/my_custom_icon_id"/> 7 </config-file> 8</platform>
You can also define what color is used with your notification. Different android versions use this settings in different ways: Android < N use this as background color for the icon. Android >= N use this to color the icon and the app name.
1<platform name="android"> 2 ... 3 <config-file parent="/manifest/application" target="app/src/main/AndroidManifest.xml"> 4 <meta-data 5 android:name="com.google.firebase.messaging.default_notification_color" 6 android:resource="@drawable/my_custom_color"/> 7 </config-file> 8</platform>
PushPayload: Object
In general (for both platforms) you can only rely on custom data fields.
message_id
and sent_time
have google.
prefix in property name (will be fixed).
Name | Type | Description |
---|---|---|
aps? | Record <string , any > | IOS payload, available when message arrives in both foreground and background. |
data | Record <string , any > | Custom data sent from server |
gcm? | Record <string , any > | Android payload, available ONLY when message arrives in foreground. |
message_id | string | Message ID automatically generated by the server |
sent_time | number | Time in milliseconds from the Epoch that the message was sent. |
clearNotifications(): Promise
<void
>
Clear all notifications from system notification bar.
Example
1cordova.plugins.firebase.messaging.clearNotifications();
Promise
<void
>
Callback when operation is completed
deleteToken(): Promise
<void
>
Delete the Instance ID (Token) and the data associated with it.
Call getToken to generate a new one.
Example
1cordova.plugins.firebase.messaging.deleteToken();
Promise
<void
>
Callback when operation is completed
getBadge(): Promise
<number
>
Gets current badge number (if supported).
Example
1cordova.plugins.firebase.messaging.getBadge().then(function(value) { 2 console.log("Badge value: ", value); 3});
Promise
<number
>
Promise fulfiled with the current badge value
getToken(format?
): Promise
<string
>
Returns the current FCM token.
Example
1cordova.plugins.firebase.messaging.getToken().then(function(token) { 2 console.log("Got device token: ", token); 3});
Name | Type | Description |
---|---|---|
format? | "apns-buffer" | "apns-string" | Token representation (iOS only) |
Promise
<string
>
Promise fulfiled with the current FCM token
onBackgroundMessage(callback
, errorCallback?
): void
Registers background push notification callback.
Example
1cordova.plugins.firebase.messaging.onBackgroundMessage(function(payload) { 2 console.log("New background FCM message: ", payload); 3});
Name | Type | Description |
---|---|---|
callback | (payload : PushPayload ) => void | Callback function |
errorCallback? | (error : string ) => void | Error callback function |
void
onMessage(callback
, errorCallback?
): void
Registers foreground push notification callback.
Example
1cordova.plugins.firebase.messaging.onMessage(function(payload) { 2 console.log("New foreground FCM message: ", payload); 3});
Name | Type | Description |
---|---|---|
callback | (payload : PushPayload ) => void | Callback function |
errorCallback? | (error : string ) => void | Error callback function |
void
onTokenRefresh(callback
, errorCallback?
): void
Registers callback to notify when FCM token is updated.
Use getToken
to generate a new token.
Example
1cordova.plugins.firebase.messaging.onTokenRefresh(function() { 2 console.log("Device token updated"); 3});
Name | Type | Description |
---|---|---|
callback | () => void | Callback function |
errorCallback? | (error : string ) => void | Error callback function |
void
requestPermission(options
): Promise
<void
>
Ask for permission to recieve push notifications (will trigger prompt on iOS).
Example
1cordova.plugins.firebase.messaging.requestPermission({forceShow: false}).then(function() { 2 console.log("Push messaging is allowed"); 3});
Name | Type | Description |
---|---|---|
options | Object | Additional options. |
options.forceShow | boolean | When value is true incoming notification is displayed even when app is in foreground. |
Promise
<void
>
Filfiled promise when permission is granted.
setBadge(badgeValue
): Promise
<void
>
Sets current badge number (if supported).
Example
1cordova.plugins.firebase.messaging.setBadge(value);
Name | Type | Description |
---|---|---|
badgeValue | number | New badge value |
Promise
<void
>
Callback when operation is completed
subscribe(topic
): Promise
<void
>
Subscribe to a FCM topic.
Example
1cordova.plugins.firebase.messaging.subscribe("news");
Name | Type | Description |
---|---|---|
topic | string | Topic name |
Promise
<void
>
Callback when operation is completed
unsubscribe(topic
): Promise
<void
>
Unsubscribe from a FCM topic.
Example
1cordova.plugins.firebase.messaging.unsubscribe("news");
Name | Type | Description |
---|---|---|
topic | string | Topic name |
Promise
<void
>
Callback when operation is completed
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
0 commit(s) and 3 issue activity found in the last 90 days -- score normalized to 2
Reason
Found 3/30 approved changesets -- score normalized to 1
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Reason
security policy file not detected
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2024-11-25
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More