1

这是我的应用程序代表

 (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{

    [[UIApplication sharedApplication] setMinimumBackgroundFetchInterval:2];

    self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
    // Override point for customization after application launch.
    self.viewController = [[[ViewController alloc] initWithNibName:@"ViewController" bundle:nil] autorelease];
    UINavigationController *nav=[[[UINavigationController alloc]initWithRootViewController:self.viewController ] autorelease];
    nav.navigationBar.hidden=YES;
    self.window.rootViewController = nav;
    [self.window makeKeyAndVisible];
    return YES;
}

-(void)application:(UIApplication *)application performFetchWithCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler
{
    NSLog(@"########### Received Background Fetch ###########");
    //Download  the Content .

     [self sometask]; // i want to do some task here but this method get called only ones when i try to launch application 

    //Cleanup
    completionHandler(UIBackgroundFetchResultNoData);

}

所以问题是 performFetchWithCompletionHandler 只被调用是的,我已经在信息 pList 中完成了所有操作,但没有帮助,请提出一些建议

4

1 回答 1

2

请注意,仅当系统告诉您执行后台提取时才应调用此方法。

你可以在这里在 Xcode 中模拟它:

在此处输入图像描述

于 2013-10-16T21:36:50.527 回答