iOS 7 后台获取
<p><p>我目前正在开发一个 iOS 应用程序,我在其中使用 <code>[ setMinimumBackgroundFetchInterval:UIApplicationBackgroundFetchIntervalMinimum];</code>。根据我以这种方式实现的文档。</p>
<pre><code>- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
NSLog(@"Launched in background %d", UIApplicationStateBackground == application.applicationState);
[ setMinimumBackgroundFetchInterval:UIApplicationBackgroundFetchIntervalMinimum];
i =0;
return YES;
}
-(void)application:(UIApplication *)application performFetchWithCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler {
NSLog(@"Fetch started");
++i;
// Set up Local Notifications
[ cancelAllLocalNotifications];
UILocalNotification *localNotification = [ init];
NSDate *now = ;
localNotification.fireDate = now;
localNotification.soundName = UILocalNotificationDefaultSoundName;
localNotification.alertBody = @"BG Mode";
localNotification.applicationIconBadgeNumber = i;
[ scheduleLocalNotification:localNotification];
completionHandler(UIBackgroundFetchResultNewData);
NSLog(@"Fetch completed");
}
</code></pre>
<p>我的问题是我尝试调试它以了解此方法调用的频率。我没有得到任何澄清。我已经用 60 秒的时间间隔进行了测试,但这也不起作用。请给我任何想法或建议。提前致谢。</p></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>澄清一下,您还根据 Apple 的文档在 Info.plist 中设置了 UIBackgroundModes ...</p>
<blockquote>
<p>This property has no effect for apps that do not have the UIBackgroundModes key with the fetch value in its Info.plist file.</p>
</blockquote></p>
<p style="font-size: 20px;">关于iOS 7 后台获取,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/21130741/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/21130741/
</a>
</p>
页:
[1]