performFetchWithCompletionHandler 永远不会被解雇 [英] performFetchWithCompletionHandler never gets fired

查看:17
本文介绍了performFetchWithCompletionHandler 永远不会被解雇的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

1) 我的 plist 配置提供背景模式:

1) My plist configuration to provide backgroundmode:

<key>UIBackgroundModes</key>
<array>
    <string>fetch</string>
</array> 

2) 在 didFinishLaunchingWithOptions 我有:

[[UIApplication sharedApplication] setMinimumBackgroundFetchInterval:1.0];

3) 我在委托中声明了协议 UIApplicationDelegate.

3) I declared the protocol UIApplicationDelegate in the delegate.

4) 我实现了以下方法,但它从未被解雇.(它仅在我使用XCode->Debug->Simulate Background Fetch"模拟提取时才有效.)

4) I implemented the following method, but it never gets fired. (It only works if I simulate the fetch with "XCode->Debug->Simulate Background Fetch".)

-(void)application:(UIApplication *)application performFetchWithCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler

为什么?这是 DP5 测试版错误吗?我应该注意这个吗?

Why? Is this a DP5 beta error? Should I radar this?

推荐答案

恐怕这很难在设备上调试,因为您不能保证在您指定的时间内调用它.

I'm afraid this is hard to debug on a device because you're not guaranteed it is called in the amount of time you specify.

setMinimumBackgroundFetchInterval 表示不会在小于您指定的值的时间间隔内调用它.但是没有setMaximumBackgroundFetchInterval.因此,如果 iOS 决定每天只调用一次您的应用程序,甚至每周只调用一次,那么无论您的 minimumBackgroundFetchInterval 都不会更频繁地调用它.AFAIK iOS 决定何时调用 performFetchWithCompletionHandler 由模式衡量的用户启动应用程序的时间和频率.

setMinimumBackgroundFetchInterval means that it is not called in an interval which is smaller than the value you specified. But there's no setMaximumBackgroundFetchInterval. So if iOS decides to call your app just once a day or even just once a week than it won't be called more often regardless your minimumBackgroundFetchInterval. AFAIK iOS decides when to call performFetchWithCompletionHandler measured by the pattern when and how often the users start the app.

这篇关于performFetchWithCompletionHandler 永远不会被解雇的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆