首页 > 解决方案 > react-native-firebase 在通知打开时没有注册的监听器 ios

问题描述

我正在使用 onNotificationOpened。在 Android 上它工作得很好,但在 ios 上单击 Xcode 中的推送会在“打开没有侦听器的通知时”写入控制台。我怎样才能解决这个问题?这是我的代码:

  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);
    });
  1. 应用目标平台:iOS 11.3

  2. React Native 版本:0.55.2

  3. RNFirebase 版本:4.0.5

  4. Firebase 模块:通知、云消息传递

标签: iosfirebasereact-native-firebase

解决方案


推荐阅读