Skip to content

Commit

Permalink
fix: onTokenChange method causing app to crash (#3552)
Browse files Browse the repository at this point in the history
Removed deprecation.

* fix: onTokenChange method causing app to crash

* fix: use token instead of token with string ancestor

Co-authored-by: Mike Diarmid <mike.diarmid@gmail.com>
  • Loading branch information
focux and Salakar authored May 5, 2020
1 parent 6d54d8c commit 1d7cd28
Showing 1 changed file with 1 addition and 13 deletions.
14 changes: 1 addition & 13 deletions packages/messaging/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,20 +198,8 @@ class FirebaseMessagingModule extends FirebaseModule {
}

const subscription = this.emitter.addListener('messaging_token_refresh', event => {
// TODO remove after v7.0.0, see: https://github.com/invertase/react-native-firebase/issues/2889
const { token } = event;
const tokenStringWithTokenAccessor = String(token);
Object.defineProperty(tokenStringWithTokenAccessor, 'token', {
enumerable: false,
get() {
// eslint-disable-next-line no-console
console.warn(
'firebase.messaging().onTokenRefresh(event => event.token) is deprecated, use onTokenRefresh(token => token) or call getToken() instead',
);
return token;
},
});
listener(tokenStringWithTokenAccessor);
listener(token);
});
return () => subscription.remove();
}
Expand Down

0 comments on commit 1d7cd28

Please sign in to comment.