Unhandled Promise rejection: this._next is not a function : Zone in @angular/fire/messaging

前端 未结 5 1808
耶瑟儿~
耶瑟儿~ 2021-01-06 06:13

When I am receiving firebase push notifications in the foreground, by using @angular/fire/messaging. The method is:

  this.angularFireMessaging.         


        
5条回答
  •  滥情空心
    2021-01-06 07:13

    There is workaround for it.

    You need to modify your custom messaging service little bit.

    Inside constructor you need to replace following code

    this.angularFireMessaging.messaging.subscribe(
        (_messaging: any) = > {
            _messaging.onMessage = _messaging.onMessage.bind(_messaging);
            messaging._next = (payload: any) = > {
                console.log(payload);
            };
            _messaging.onTokenRefresh = _messaging.onTokenRefresh.bind(_messaging);
        }
    );
    

    with that

    this.angularFireMessaging.messaging.subscribe(
        (_messaging: any) = > {
            // _messaging.onMessage = _messaging.onMessage.bind(_messaging);
            _messaging._next = (payload: any) = > {
                console.log(payload);
            };
            _messaging.onTokenRefresh = _messaging.onTokenRefresh.bind(_messaging);
        }
    );
    

    Then you will get push notification even you are in fore-ground.

提交回复
热议问题