2
我目前正在使用一個iOS應用程序,其中我正在使用[[UIApplication sharedApplication] setMinimumBackgroundFetchInterval:UIApplicationBackgroundFetchIntervalMinimum];
。根據我以這種方式實施的文檔。iOS 7後臺抓取
- (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");
}
我的問題是我試圖調試它知道這種方法調用的頻率。我沒有得到任何澄清。我用60秒的時間間隔進行了測試,但那也不起作用。請給我任何想法或建議。提前致謝 。