How can I execute a countdown timer on iOS?
First, I tried NSTimer . Then I discovered that NSTimer cannot work when the application enters the background.
Secondly, I used
counterTask = [[UIApplication sharedApplication] beg inBackgroundTaskWithExpirationHandler:^{ }];
so that NSTimer works in the background. But then I discovered that iOS allows you to work only on the background of no more than 600 s (10 minutes). I cannot figure out how to make NSTimer more than 10 minutes in the background.
Thirdly, I'm tired of using NSLocalNotification , and it works well. But I want to do this to pause music by calling a method. I found that UILocalNotification will show a warning when the time comes. If you do not click the warning button, the method - (void)application:(UIApplication *)app didReceiveLocalNotification:(UILocalNotification *)notification will not be called. I do not know how to call a method without pressing the warning button.
- (void)application:(UIApplication *)app didReceiveLocalNotification:(UILocalNotification *)notification { NSLog(@"Recieved Notification %@",notification); UIAlertView *alert=[[[UIAlertView alloc] initWithTitle:@"Local Notification" message:@"message" delegate:nil cancelButtonTitle:nil otherButtonTitles:nil, nil] autorelease]; [alert show]; }
So the question is: 1. How to let NSTimer run in the background for more than 10 minutes, or 2. How to call my own method without pressing the warning button when it is time for UILocalNotification .
Thanks a lot!
source share