[messaging] Correctly bind messaging listeners

This commit is contained in:
Chris Bianca 2017-06-19 13:14:36 +01:00
parent 782958d026
commit cd347383a4
1 changed files with 5 additions and 3 deletions

View File

@ -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();
}
/**