From cd347383a4ec4afdb469b4d5ba8879e0d99a887a Mon Sep 17 00:00:00 2001 From: Chris Bianca Date: Mon, 19 Jun 2017 13:14:36 +0100 Subject: [PATCH] [messaging] Correctly bind messaging listeners --- lib/modules/messaging/index.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/modules/messaging/index.js b/lib/modules/messaging/index.js index 43a6cfba..8e3b174b 100644 --- a/lib/modules/messaging/index.js +++ b/lib/modules/messaging/index.js @@ -204,7 +204,7 @@ export default class Messaging extends Base { * @returns {*} */ onMessage(listener: Function): () => any { - return FirebaseMessagingEvt.addListener( + const rnListener = FirebaseMessagingEvt.addListener( EVENT_TYPE.Notification, async(event) => { const data = { @@ -217,7 +217,8 @@ export default class Messaging extends Base { data.finish(); } } - ).remove; + ); + return () => rnListener.remove(); } /** @@ -226,7 +227,8 @@ export default class Messaging extends Base { * @returns {*} */ onTokenRefresh(listener: Function): () => any { - return FirebaseMessagingEvt.addListener(EVENT_TYPE.RefreshToken, listener).remove; + const rnListener = FirebaseMessagingEvt.addListener(EVENT_TYPE.RefreshToken, listener); + return () => rnListener.remove(); } /**