首页 > 解决方案 > 无法在 ios 中接收通知:发送 FcmTokenRefreshed 且未注册监听器

问题描述

我使用 fire-base 发送通知,在 ios 应用程序中我有这个错误:发送 FcmTokenRefreshed,如果应用程序打开接收通知但没有注册监听器,但当应用程序关闭时不接收并显示错误。
对不起我的英语不好!

“反应”:“16.4.1”

“反应原生”:“0.55.4”

"react-native-fcm": "^16.2.4",

“xcode 10.1”

标签: firebasereact-nativereact-native-fcm

解决方案


确保将这些行放在您的

文件:AppDelegate.m:

1)

import "RNFirebaseNotifications.h"  
import "RNFirebaseMessaging.h"

2 ) 将此行添加到 didFinishLaunchingWithOptions [RNFirebaseNotifications 配置];

3)添加方法

(void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification {
  [[RNFirebaseNotifications instance] didReceiveLocalNotification:notification];
}

 (void)application:(UIApplication *)application didReceiveRemoteNotification:(nonnull NSDictionary *)userInfo
                                                       fetchCompletionHandler:(nonnull void (^)(UIBackgroundFetchResult))completionHandler{
  [[RNFirebaseNotifications instance] didReceiveRemoteNotification:userInfo fetchCompletionHandler:completionHandler];
}

  (void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings {
  [[RNFirebaseMessaging instance] didRegisterUserNotificationSettings:notificationSettings];
}

推荐阅读