非常失望,音乐试了,viop试了,但是据说都会被拒。
- (void)applicationDidEnterBackground:(UIApplication *)application {
// NSLog(@"进入后台");
// [application beginBackgroundTaskWithExpirationHandler:nil];
BOOL backgroundAccepted = [[UIApplication sharedApplication] setKeepAliveTimeout:600 handler:^{ [self backgroundHandler]; }];
if (backgroundAccepted)
{
NSLog(@"backgrounding accepted");
}
[self backgroundHandler];
}
static int counter = 0;
- (void)backgroundHandler {
NSLog(@"### -->backgroundinghandler");
UIApplication *app = [UIApplication sharedApplication];
__block UIBackgroundTaskIdentifier bgTask = [app beginBackgroundTaskWithExpirationHandler:^{
[app endBackgroundTask:bgTask];
bgTask = UIBackgroundTaskInvalid;
}];
// Start the long-running task
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
while (1) {
NSLog(@"counter:%ld", counter++);
sleep(1);
}
});