【发布时间】:2016-09-19 05:42:46
【问题描述】:
在苹果文档Understanding When Your App Gets Launched into the Background
支持后台执行的应用程序可能会被系统重新启动 处理传入事件...
我正在做region monitoring,当我得到它时,我正在弹出一个UILocalNotification,但是当我点击UILocalNotification 时,我的应用程序didReceiveLocalNotification 被调用。可能是因为我的应用是在后台启动的。
我做的第二件事是我没有点击 UILocalNotification 并离开了几分钟,这意味着我的应用程序将被 iOS 终止。我拖动通知中心,然后点击UILocalNotification 仍然是我的应用输入didReceiveLocalNotification。
我期望应用程序现在在延迟UILocalNotification点击时启动的行为必须输入此方法
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
UILocalNotification *notification = [launchOptions objectForKey:UIApplicationLaunchOptionsLocalNotificationKey];
if (notification)
{
NSLog(@"notification caused app to launch, alert body = %@", notification.alertBody);
// do what ever action you want to do
// you could just copy the code from "didReceiveLocalNotification" and paste it here
}
return YES;
}
究竟发生了什么,可以请任何人详细解释一下吗?
即使在我点击UILocalNotification 应用程序延迟之后也无法进入
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
【问题讨论】:
标签: ios objective-c core-location uilocalnotification appdelegate