Merge pull request #117 from jerolimov/update-getbadgenumber-doc

Update the getBadgeNumber documentation and add android hint
This commit is contained in:
Elliot Hesp 2017-05-14 22:17:33 +01:00 committed by GitHub
commit 67960ddab4
2 changed files with 11 additions and 6 deletions

View File

@ -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 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. 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 ## API
### subscribeToTopic(topic: string) ### subscribeToTopic(topic: string)
@ -119,7 +123,7 @@ Requests app notification permissions in an Alert dialog.
firebase.messaging().requestPermissions(); firebase.messaging().requestPermissions();
``` ```
### [iOS] setBadgeNumber(value: number) ### setBadgeNumber(value: number)
Sets the badge number on the iOS app icon. 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); firebase.messaging().setBadgeNumber(2);
``` ```
### [iOS] getBadgeNumber(): number ### getBadgeNumber(): `Promise<number>`
Returns the current badge number on the app icon. Returns the current badge number on the app icon.
```javascript ```javascript
const badgeNumber = firebase.messaging().getBadgeNumber(); firebase.messaging().getBadgeNumber()
.then((badgeNumber) => {
console.log('Current badge number: ', badgeNumber);
});
``` ```

4
index.d.ts vendored
View File

@ -615,15 +615,13 @@ declare module "react-native-firebase" {
*/ */
requestPermissions(): void requestPermissions(): void
/** /**
* IOS
* Sets the badge number on the iOS app icon. * Sets the badge number on the iOS app icon.
*/ */
setBadgeNumber(value: number): void setBadgeNumber(value: number): void
/** /**
* IOS
* Returns the current badge number on the app icon. * Returns the current badge number on the app icon.
*/ */
getBadgeNumber(): number getBadgeNumber(): Promise<number>
/** /**
* Send an upstream message * Send an upstream message
* @param senderId * @param senderId