Skip to content

Commit e170da1

Browse files
committed
fix(messaging): Fix for the binding issue and onTokenRefresh for Messaging
1 parent b4eca1b commit e170da1

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/messaging/messaging.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,9 @@ export class AngularFireMessaging {
5353
);
5454

5555
const tokenChanges = this.messaging.pipe(
56-
switchMap(messaging => new Observable(messaging.onTokenRefresh)),
56+
switchMap(messaging => new Observable(messaging.onTokenRefresh.bind(messaging)).pipe(
57+
switchMap(() => messaging.getToken())
58+
)),
5759
runOutsideAngular(zone)
5860
);
5961

@@ -62,7 +64,7 @@ export class AngularFireMessaging {
6264
);
6365

6466
this.messages = this.messaging.pipe(
65-
switchMap(messaging => new Observable(messaging.onMessage)),
67+
switchMap(messaging => new Observable(messaging.onMessage.bind(messaging))),
6668
runOutsideAngular(zone)
6769
);
6870

0 commit comments

Comments
 (0)