【发布时间】:2015-04-16 06:02:39
【问题描述】:
本地通知在前台运行良好。但是当显示通知横幅时,我需要执行一些后台工作。当出现本地通知时,当我点击横幅时效果很好。
代码:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
UILocalNotification *notification = [launchOptions objectForKey:UIApplicationLaunchOptionsLocalNotificationKey];
if (notification)
{
NSLog(@"AppDelegate didFinishLaunchingWithOptions");
[self application:application didReceiveLocalNotification:notification];
}
return YES;
}
我的问题类似于this issue
我使用下面的代码来执行后台任务:
- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification
{
dispatch_async(dispatch_get_main_queue(), ^{
[[ReminderManger sharedMager] handleNotification:[[notification userInfo] objectForKey:@"reminderId"]];
});
}
【问题讨论】:
标签: ios