From 96d4fab8c11b11a9672621f141775e5aa2bfc884 Mon Sep 17 00:00:00 2001 From: Christoph Jerolimov Date: Sun, 14 May 2017 22:50:07 +0200 Subject: [PATCH] Update the getBadgeNumber documentation and add android hint --- docs/modules/cloud-messaging.md | 13 ++++++++++--- index.d.ts | 4 +--- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/docs/modules/cloud-messaging.md b/docs/modules/cloud-messaging.md index 5b37ce41..72a490d4 100644 --- a/docs/modules/cloud-messaging.md +++ b/docs/modules/cloud-messaging.md @@ -6,6 +6,10 @@ cost to both Android & iOS platforms. Assuming the installation instructions hav As the Firebase Web SDK has limited messaging functionality, the following methods within `react-native-firebase` have been created to handle FCM in the React Native environment. +Badge notification is well known on the iOS platform, but also supported by different Android devices / launchers. +This library uses the [ShortcutBadger](https://github.com/leolin310148/ShortcutBadger) library to set the badge number +also on Android. A list of supported launcher can be found there. + ## API ### subscribeToTopic(topic: string) @@ -119,7 +123,7 @@ Requests app notification permissions in an Alert dialog. firebase.messaging().requestPermissions(); ``` -### [iOS] setBadgeNumber(value: number) +### setBadgeNumber(value: number) Sets the badge number on the iOS app icon. @@ -127,10 +131,13 @@ Sets the badge number on the iOS app icon. firebase.messaging().setBadgeNumber(2); ``` -### [iOS] getBadgeNumber(): number +### getBadgeNumber(): `Promise` Returns the current badge number on the app icon. ```javascript -const badgeNumber = firebase.messaging().getBadgeNumber(); +firebase.messaging().getBadgeNumber() + .then((badgeNumber) => { + console.log('Current badge number: ', badgeNumber); + }); ``` diff --git a/index.d.ts b/index.d.ts index 82e1540e..78312310 100644 --- a/index.d.ts +++ b/index.d.ts @@ -615,15 +615,13 @@ declare module "react-native-firebase" { */ requestPermissions(): void /** - * IOS * Sets the badge number on the iOS app icon. */ setBadgeNumber(value: number): void /** - * IOS * Returns the current badge number on the app icon. */ - getBadgeNumber(): number + getBadgeNumber(): Promise /** * Send an upstream message * @param senderId