我已经设置了一个本地通知,它会以一定的时间间隔触发,当我点击横幅时,会调用“didReceiveLocalNotification”。现在,当我从后台删除应用程序时,当我在横幅上点击时,通知会一次又一次地出现,但这次是“didReceiveLocalNotification " 未调用。请告诉我在这种情况下如何知道通知触发。
问问题
1140 次
1 回答
3
如果应用程序没有在后台运行,didReceiveLocalNotification将不会调用,而是应用程序 didFinishLaunchingWithOptions:被调用。在启动选项中,您可以查看通知
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// If application is launched due to alarm notification, provide the option to snooze it.
UILocalNotification *notification = [launchOptions objectForKey:UIApplicationLaunchOptionsLocalNotificationKey];
if (notification)
{
// application is launched due to notification
}
}
于 2013-06-07T05:28:03.007 回答