应用关闭后无法显示本地通知(iOS)

时间:2018-08-20 18:53:52

标签: ios react-native push-notification firebase-cloud-messaging firebase-notifications

我正在使用react-native-firebase从我的Firebase实例接收数据消息。在这两个平台上,我的应用程序都接收FC​​M发送的数据。在Android中,在所有三种情况下(前景,背景,关闭),都有可能在某些数据到达时显示本地通知。但是在iOS中,我的应用程序只能在前台和后台情况下显示本地通知,而在关闭应用程序时则不能(在这种情况下,应用程序会接收数据消息)。所以我的问题是:在关闭应用程序(iOS)时真的不可能显示本地通知吗?还是我遗漏了什么?

我正在使用转化酶(https://github.com/invertase/react-native-firebase)提供的库

在AppDelegate.m中的通知注册事件:

 // Required for the register event.
 - (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
 {
  [RCTPushNotificationManager didRegisterForRemoteNotificationsWithDeviceToken:deviceToken];
 }

 // Required for the registrationError event.
 - (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error
 {
  [RCTPushNotificationManager didFailToRegisterForRemoteNotificationsWithError:error];
 }

- (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];
}

谢谢!

0 个答案:

没有答案