AppDelegate didFinishLaunchingWithOptions launchOptions总是返回(null)

时间:2014-06-30 16:35:57

标签: ios objective-c uilocalnotification

我正在尝试让应用程序完全关闭(已终止)的预定UILocalNotification,因为方法didReceiveLocalNotification:未被调用,我正在尝试使用以下代码:< / p>

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
UILocalNotification *localNotification = [launchOptions objectForKey:UIApplicationLaunchOptionsLocalNotificationKey];
NSLog(@"LOCAL NOTIFICATION - %@",localNotification);
if (localNotification) {
    //HANDLE THE NOTIFICATION
}
return YES;

}

这就是我创建UILocalNotification的方式:

UILocalNotification * notificationRH = [UILocalNotification new];
notificationRH.fireDate = date;
notificationRH.repeatInterval = repetition;
notificationRH.alertBody = body;
notificationRH.alertAction = title;
notificationRH.hasAction = title ? 1 : 0;
notificationRH.timeZone = [NSTimeZone defaultTimeZone];
notificationRH.soundName = sounds ? UILocalNotificationDefaultSoundName : nil;
notificationRH.userInfo = @{@"test": title};

但问题是该方法上的launchOptions始终返回(null),并且我无法在应用关闭时触发通知。有没有人可以帮我这个? 非常感谢!!