应用程序在前台时不会触发通知 - iOS

时间:2017-06-30 11:59:46

标签: ios objective-c firebase push-notification

我使用firebase在iOS中实现推送通知,目标c。 我有方法application:didReceiveRemoteNotification:fetchCompletionHandler,当应用程序处于后台并且用户点击通知时以及应用程序在前台时,应根据其描述触发该方法。事情是它只适用于后台(或应用程序没有运行时)。 我忘记了什么吗?

感谢您的帮助。

3 个答案:

答案 0 :(得分:3)

您可以使用以下代码:

RequestQueue

答案 1 :(得分:1)

对于iOS 10及以上版本,当应用程序处于前台时调用方法:

- (void)userNotificationCenter:(UNUserNotificationCenter *)center
       willPresentNotification:(UNNotification *)notification
         withCompletionHandler:(void (^)(UNNotificationPresentationOptions))completionHandler

因此,您需要观察此方法以在app处于前台时处理通知

答案 2 :(得分:1)

iOS Firebase通知的标准示例在AppDelegate中实现,如completionHandler(UIBackgroundFetchResultNewData);

如果你喜欢前景,你必须实现它。

相关问题