Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: onTokenChange method causing app to crash #3552

Merged
merged 7 commits into from
May 5, 2020
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