ormFetchWithCompletionHandler永远不

ormFetchWithCompletionHandler永远不

本文介绍了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 in代表。

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 beta错误吗?我应该对此进行雷达吗?

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's the app.

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

08-22 22:47