1.0.17 • Published 5 years ago

cordova-plugin-firebase-messaging-ka v1.0.17

Weekly downloads
8
License
MIT
Repository
github
Last release
5 years ago

cordova-plugin-firebase-messagingNPM version NPM downloads

Cordova plugin for Firebase Cloud Messaging

Installation

cordova plugin add cordova-plugin-firebase-messaging --save

You can also specify variables ANDROID_NOTIFICATION_ICON and ANDROID_NOTIFICATION_COLOR.

Supported Platforms

  • iOS
  • Android

Methods

onMessage(callback)

Called when a message is received.

window.cordova.plugins.firebase.messaging.onMessage(function(payload) {
    console.log("New FCM message: ", payload);
});

In general (for both platforms) you can only rely on custom data fields from a FCM payload.

For iOS APNS payload is stored in aps object. It's available when a message arrives in both foreground and background.

For Android GCM payload is stored in gcm. It's available ONLY when a message arrives in foreground. For a some reason Google applied this limitation into their APIs. Anyway I've created an issue for a future improvement.

onTokenRefresh(callback)

Logs an instance id token received.

window.cordova.plugins.firebase.messaging.onTokenRefresh(function(token) {
    console.log("Got device token: ", token);
});

Use this callback to get initial token and to refresh stored value in future.

subscribe(topic)

Subscribe to topic in background.

window.cordova.plugins.firebase.messaging.subscribe("New Topic");

unsubscribe(topic)

Unsubscribe from topic in background.

window.cordova.plugins.firebase.messaging.unsubscribe("New Topic");

getBadge(callback)

Reads current badge number (if supported).

window.cordova.plugins.firebase.messaging.getBadge(function(value) {
    console.log("Badge value: ", value);
});

setBadge(value)

Sets current badge number (if supported).

window.cordova.plugins.firebase.messaging.setBadge(value);

requestPermission (iOS only)

Grant permission to recieve push notifications (will trigger prompt).

window.cordova.plugins.firebase.messaging.requestPermission(function(token) {
    console.log("APNS device token: ", token);
});
1.0.17

5 years ago

1.0.16

5 years ago

1.0.15

5 years ago

1.0.14

5 years ago

1.0.13

5 years ago

1.0.12

5 years ago

1.0.11

5 years ago

1.0.10

5 years ago

1.0.9

5 years ago

1.0.8

5 years ago

1.0.7

5 years ago

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

7 years ago