gpt4 book ai didi

iOS 7 后台获取

转载 作者:塔克拉玛干 更新时间:2023-11-02 21:37:22 25 4
gpt4 key购买 nike

我目前正在开发一个 iOS 应用程序,我在其中使用 [[UIApplication sharedApplication] setMinimumBackgroundFetchInterval:UIApplicationBackgroundFetchIntervalMinimum];。根据我以这种方式实现的文档。

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.

NSLog(@"Launched in background %d", UIApplicationStateBackground == application.applicationState);

[[UIApplication sharedApplication] setMinimumBackgroundFetchInterval:UIApplicationBackgroundFetchIntervalMinimum];
i =0;

return YES;
}


-(void)application:(UIApplication *)application performFetchWithCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler {
NSLog(@"Fetch started");
++i;

// Set up Local Notifications
[[UIApplication sharedApplication] cancelAllLocalNotifications];
UILocalNotification *localNotification = [[UILocalNotification alloc] init];
NSDate *now = [NSDate date];
localNotification.fireDate = now;

localNotification.soundName = UILocalNotificationDefaultSoundName;
localNotification.alertBody = @"BG Mode";
localNotification.applicationIconBadgeNumber = i;

[[UIApplication sharedApplication] scheduleLocalNotification:localNotification];

completionHandler(UIBackgroundFetchResultNewData);
NSLog(@"Fetch completed");
}

我的问题是我尝试调试它以了解此方法调用的频率。我没有得到任何澄清。我已经用 timeinterval 60 秒进行了测试,但这也不起作用。请给我任何想法或建议。提前致谢。

最佳答案

澄清一下,您还根据 Apple 的文档在 Info.plist 中设置了 UIBackgroundModes ...

This property has no effect for apps that do not have the UIBackgroundModes key with the fetch value in its Info.plist file.

关于iOS 7 后台获取,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21130741/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com