Skip to content

Commit

Permalink
[messaging] Correctly bind messaging listeners
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisbianca committed Jun 19, 2017
1 parent 782958d commit cd34738
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lib/modules/messaging/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand All @@ -217,7 +217,8 @@ export default class Messaging extends Base {
data.finish();
}
}
).remove;
);
return () => rnListener.remove();
}

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

/**
Expand Down

0 comments on commit cd34738

Please sign in to comment.