Ios 在后台运行NSTimer或UILocalNotification

Ios 在后台运行NSTimer或UILocalNotification,ios,background,nstimer,uilocalnotification,Ios,Background,Nstimer,Uilocalnotification,如何在iOS上执行倒计时 counterTask = [[UIApplication sharedApplication] beginBackgroundTaskWithExpirationHandler:^{ }]; 首先,我尝试了NSTimer。然后我发现当应用程序进入后台时,NSTimer无法工作 counterTask = [[UIApplication sharedApplication] beginBackgroundTa

如何在iOS上执行倒计时

counterTask = [[UIApplication sharedApplication]
          beginBackgroundTaskWithExpirationHandler:^{
          }];
首先,我尝试了
NSTimer
。然后我发现当应用程序进入后台时,
NSTimer
无法工作

counterTask = [[UIApplication sharedApplication]
          beginBackgroundTaskWithExpirationHandler:^{
          }];
第二,我用

counterTask = [[UIApplication sharedApplication]
              beg
inBackgroundTaskWithExpirationHandler:^{
              }];
counterTask = [[UIApplication sharedApplication]
          beginBackgroundTaskWithExpirationHandler:^{
          }];
NSTimer
在后台工作。但后来我发现iOS只允许应用程序在后台工作不超过600秒(10分钟)。我不知道如何让
NSTimer
在后台超过10分钟

counterTask = [[UIApplication sharedApplication]
          beginBackgroundTaskWithExpirationHandler:^{
          }];
第三,我已经厌倦了使用
NSLocalNotification
,而且效果很好。但是我想做的是通过调用一个方法来暂停播放音乐。我发现,
UILocalNotification
将在该时间显示警报。如果未单击警报按钮,将不会调用方法-
(void)application:(UIApplication*)app didReceiveLocalNotification:(UILocalNotification*)notification
。我不知道如何在不单击警报按钮的情况下调用方法

- (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];
}
counterTask = [[UIApplication sharedApplication]
          beginBackgroundTaskWithExpirationHandler:^{
          }];
所以,问题是 1.如何让
NSTimer
在后台运行10分钟以上, 或 2.如何在
UILocalNotification
时调用我自己的方法而不单击警报按钮

counterTask = [[UIApplication sharedApplication]
          beginBackgroundTaskWithExpirationHandler:^{
          }];
非常感谢

counterTask = [[UIApplication sharedApplication]
          beginBackgroundTaskWithExpirationHandler:^{
          }];
在过期处理程序中放入一些东西,它将生成另一个计时器,该计时器具有另一个过期处理程序,该计时器具有另一个使

counterTask = [[UIApplication sharedApplication]
          beginBackgroundTaskWithExpirationHandler:^{
          }];