简体   繁体   English

didReceiveRemoteNotification fetchCompletionHandler没有在后台调用以进行静默推送

[英]didReceiveRemoteNotification fetchCompletionHandler is not getting called in background for silent push

So I have added didReceiveRemoteNotification delegate to handle silent push notification 所以我添加了didReceiveRemoteNotification委托来处理静默推送通知

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler

This method should be invoked in the background to update the content before notifying the user, so that the user can open the application and be presented with new content immediately. 应该在通知用户之前在后台调用此方法以更新内容,以便用户可以打开应用程序并立即看到新内容。

But this method is never getting called in background. 但是这种方法永远不会在后台调用。 I have tried to debug the issue but no success. 我试图调试问题,但没有成功。 Surprisingly this method is getting called properly if my app is in foreground and I am easily able to check content-available to update the UI. 令人惊讶的是,如果我的应用程序位于前台并且可以轻松地检查content-available以更新UI,则可以正确调用此方法。

Can anyone please help me with this issue that why didReceiveRemoteNotification:fetchCompletionHandler is not getting called in background ? 谁能帮我解决这个问题,为什么didReceiveRemoteNotification:fetchCompletionHandler没有在后台被调用?

Enable 'Remote Notifications' in 'Background Modes' of 'Capabilities' tab in xcode. 在xcode的“功能”标签的“背景模式”中启用“远程通知”。

For more information see this link 有关更多信息,请参见此链接

Hope this helps. 希望这可以帮助。

Issue was related to incorrect payload. 问题与有效载荷不正确有关。

I was getting content-available outside aps instead it should be part of aps. 我在aps之外获得了content-available而应该是aps的一部分。

Incorrect payload: 有效载荷不正确:

{
   "_" = "asd-dfsd-werdsf";
   aps =     {
   };
   "content-available" = 1;
}

Correct payload: 正确的有效载荷:

    {
       "_" = "asd-dfsd-werdsf";
       aps =     {
       "content-available" = 1;
       };
    }

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 application:didReceiveRemoteNotification:fetchCompletionHandler Not Called - application:didReceiveRemoteNotification:fetchCompletionHandler Not Called iOS推送通知-didReceiveRemoteNotification:fetchCompletionHandler:从不在前台调用 - iOS push notifications - didReceiveRemoteNotification:fetchCompletionHandler: never called in foreground Swift & Push Notification:application(_:didReceiveRemoteNotification:fetchCompletionHandler:) 没有被调用 - Swift & Push Notification : application(_:didReceiveRemoteNotification:fetchCompletionHandler:) does not get called didReceiveRemoteNotification:当应用程序处于后台且未连接到 Xcode 时,不会调用 fetchCompletionHandler - didReceiveRemoteNotification:fetchCompletionHandler not being called when app is in background and not connected to Xcode UA:当应用程序在后台并连接到Xcode时,不会调用didReceiveRemoteNotification:fetchCompletionHandler - UA: didReceiveRemoteNotification:fetchCompletionHandler not being called when app is in background AND connected to Xcode didReceiveRemoteNotification:当应用程序处于后台且处于非活动状态时未调用fetchCompletionHandler - didReceiveRemoteNotification:fetchCompletionHandler not being called when app is in background and inactive 为什么didReceiveRemoteNotification没有被调用但是didReceiveRemoteNotification:当我的应用程序在前台时调用fetchCompletionHandler? - Why is didReceiveRemoteNotification not called but didReceiveRemoteNotification:fetchCompletionHandler called when my app is in the foreground? didReceiveRemoteNotification:fetchCompletionHandler:但是从未调用完成处理程序 - didReceiveRemoteNotification:fetchCompletionHandler: but the completion handler was never called 使用didReceiveRemoteNotification:fetchCompletionHandler在后台启动AVAudioSession和AVAudioPlayer: - start AVAudioSession & AVAudioPlayer in Background using didReceiveRemoteNotification:fetchCompletionHandler: 为什么调用ReceiveRemoteNotification:fetchCompletionHandler被调用,但通常didReceiveRemoteNotification不是? - Why didReceiveRemoteNotification:fetchCompletionHandler is called but usual didReceiveRemoteNotification isn't?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM