Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- firebase.messaging().requestPermission();
- firebase.auth().onAuthStateChanged(async () => {
- const registerToken = await AsyncStorage.getItem('registerPushToken');
- firebase
- .messaging()
- .getToken()
- .then(async Devicetoken => {
- if (registerToken === Devicetoken) return;
- await dispatch(subscribeNotify(Devicetoken));
- await AsyncStorage.setItem('registerPushToken', Devicetoken);
- });
- });
- firebase.messaging().onTokenRefresh(async data => {
- const registerToken = await AsyncStorage.getItem('registerPushToken');
- if (registerToken) {
- await dispatch(
- unsubscribeNotify({
- registrationToken: registerToken,
- deleteInstance: false,
- }),
- );
- }
- await dispatch(subscribeNotify(data));
- await AsyncStorage.setItem('registerPushToken', data);
- });
- firebase.notifications().onNotificationOpened(notificationOpen => {
- pushController(notificationOpen.notification._data);
- });
Add Comment
Please, Sign In to add comment