OC申请后台运行时间

//申请后台运行程序时间(当程序进去后台时,单位分钟)

- (void)applicationDidEnterBackground:(UIApplication *)application {

    [[UIApplication sharedApplication]beginBackgroundTaskWithExpirationHandler:nil];

    NSTimer *timer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(pushAction) userInfo:nil repeats:NO];

    NSLog(@"%@",timer);

}

- (void)pushAction{

    NSLog(@"申请后台运行时间,时间为0,点击home键,直接后台挂起程序");

}

猜你喜欢

转载自www.cnblogs.com/-ios/p/9708869.html