#import
<AVFoundation/AVFoundation.h>
- (BOOL)a(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
#warning 这是为了后台保存长存的代码
// NSError *setCategoryErr = nil;
// NSError *activationErr = nil;
// [[AVAudioSession sharedInstance]
// setCategory: AVAudioSessionCategoryPlayback
// error: &setCategoryErr];
// [[AVAudioSession sharedInstance]
// setActive: YES
// NSError *setCategoryErr = nil;
// NSError *activationErr = nil;
// [[AVAudioSession sharedInstance]
// setCategory: AVAudioSessionCategoryPlayback
// error: &setCategoryErr];
// [[AVAudioSession sharedInstance]
// setActive: YES
// error: &activationErr];
}
- (void)applicationDidEnterBackground:(UIApplication *)application {
UIApplication* app = [UIApplication sharedApplication];
__block UIBackgroundTaskIdentifier bgTask;
bgTask = [app beginBackgroundTaskWithExpirationHandler:^{
dispatch_async(dispatch_get_main_queue(), ^{
if (bgTask != UIBackgroundTaskInvalid)
{
NSTimer * timerStep = [NSTimer scheduledTimerWithTimeInterval:20 target:self selector:@selector(timerFireMethod:) userInfo:nil repeats:YES];
}
});
}];
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
dispatch_async(dispatch_get_main_queue(), ^{
if (bgTask != UIBackgroundTaskInvalid)
{
bgTask = UIBackgroundTaskInvalid;
NSTimer * timerStep = [NSTimer scheduledTimerWithTimeInterval:20 target:self selector:@selector(timerFireMethod:) userInfo:nil repeats:YES];
}
});
});
UIApplication* app = [UIApplication sharedApplication];
__block UIBackgroundTaskIdentifier bgTask;
bgTask = [app beginBackgroundTaskWithExpirationHandler:^{
dispatch_async(dispatch_get_main_queue(), ^{
if (bgTask != UIBackgroundTaskInvalid)
{
NSTimer * timerStep = [NSTimer scheduledTimerWithTimeInterval:20 target:self selector:@selector(timerFireMethod:) userInfo:nil repeats:YES];
}
});
}];
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
dispatch_async(dispatch_get_main_queue(), ^{
if (bgTask != UIBackgroundTaskInvalid)
{
bgTask = UIBackgroundTaskInvalid;
NSTimer * timerStep = [NSTimer scheduledTimerWithTimeInterval:20 target:self selector:@selector(timerFireMethod:) userInfo:nil repeats:YES];
}
});
});
}