ios 7:didreceiveremotenotification fetchcompletionhandler在应用程序保留在后台进行过夜测试时没有被调用

时间:2013-11-18 07:48:48

标签: ios7

  1. 我使用VoIP和远程通知作为后台模式。

  2. 我让应用程序闲置在后台进行隔夜测试。

  3. 我在applicationDidEnterBackground

    中编写了以下代码
        - (void)applicationDidEnterBackground:(UIApplication *)application
    

    {

    [[UIApplication sharedApplication] setKeepAliveTimeout:600 handler:^{
        NSString *message = @"voip keep alive timeout executed....";
        NSLog(@"%@",message);
         [Logger addEntry:CAT_ML_CORE andSubCategory:SUBCAT_DEBUG andMessage:message];
    }];
    

    }

  4. 在应用程序空闲后的1天后,我发现“voip keep alive timeout execution ....”已打印在我的日志中。

  5. 这表明我的应用程序还活着。

  6. 但是当我向我的应用程序发送推送通知时,“didreceiveremotenotification fetchcompletionhandler”方法不会被调用。

  7. 这与Apple的声明相矛盾“与应用程序不同:didReceiveRemoteNotification:方法,仅在您的应用程序运行时调用,系统调用didreceiveremotenotification fetchcompletionhandler方法,无论您的应用程序状态如何。如果您的应用程序暂停或未运行,系统会在调用方法之前唤醒或启动您的应用并将其置于后台运行状态。“

  8. 有人可以告诉我为什么会这样吗?

1 个答案:

答案 0 :(得分:0)

确保您的APNS有效负载具有“内容可用”

content-available - number - 为此密钥提供值1,表示新内容可用。这用于支持报亭应用和后台内容下载。

https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Chapters/ApplePushService.html