Skip to content

Commit 1084e3f

Browse files
authored
FCM.onNotification() and FCM.onTokenRefresh() now returns disposable.
1 parent ce67c9f commit 1084e3f

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,11 @@ const doesIt: boolean = await FCM.hasPermission()
9191

9292
Callback firing when receiving new notifications. It serves as a shortcut to listen to eventTarget's "notification" event.
9393
```typescript
94-
FCM.onNotification((payload: object) => {
94+
const disposable = FCM.onNotification((payload: object) => {
9595
// ...
9696
})
97+
// ...
98+
disposable.dispose() // To remove listener
9799
```
98100

99101
:warning: If the subscription to notification events happens after the notification has been fired, it'll be lost. As it is expected that you'd not always be able to catch the notification payload that the opened the app, the `FCM.getInitialPushPayload()` method was introduced.
@@ -102,9 +104,11 @@ FCM.onNotification((payload: object) => {
102104

103105
Callback firing when receiving a new Firebase token. It serves as a shortcut to listen to eventTarget's "tokenRefresh" event.
104106
```typescript
105-
FCM.onTokenRefresh((fcmToken: string) => {
107+
const disposable = FCM.onTokenRefresh((fcmToken: string) => {
106108
// ...
107109
})
110+
// ...
111+
disposable.dispose() // To remove listener
108112
```
109113

110114
##### FCM.requestPushPermission()

0 commit comments

Comments
 (0)