fix: onTokenChange method causing app to crash (#3552)

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>
This commit is contained in:
Leonardo E. Dominguez
2020-05-05 17:52:23 -04:00
committed by GitHub
parent 6d54d8c743
commit 1d7cd28f85

View File

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