diff --git a/src/messaging/messaging.ts b/src/messaging/messaging.ts index 89c4fce64..8a288c31b 100644 --- a/src/messaging/messaging.ts +++ b/src/messaging/messaging.ts @@ -53,7 +53,9 @@ export class AngularFireMessaging { ); const tokenChanges = this.messaging.pipe( - switchMap(messaging => new Observable(messaging.onTokenRefresh)), + switchMap(messaging => new Observable(messaging.onTokenRefresh.bind(messaging)).pipe( + switchMap(() => messaging.getToken()) + )), runOutsideAngular(zone) ); @@ -62,7 +64,7 @@ export class AngularFireMessaging { ); this.messages = this.messaging.pipe( - switchMap(messaging => new Observable(messaging.onMessage)), + switchMap(messaging => new Observable(messaging.onMessage.bind(messaging))), runOutsideAngular(zone) );