繁体   English   中英

AppDelegate didFinishLaunchingWithOptions launchOptions始终返回(空)

[英]AppDelegate didFinishLaunchingWithOptions launchOptions always returning (null)

我正在尝试使用完全关闭(终止)的应用程序获取计划的UILocalNotification ,因为方法didReceiveLocalNotification:没有被调用,所以我尝试使用以下代码:

- (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) ,并且在关闭应用程序时无法触发Notification。 有谁能帮助我吗? 非常感谢!!

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM