我希望我的应用程序通过点击通知启动应用程序时执行特定的操作.当应用程序已经运行到背景中时,我想做这些具体的事情,但是通过点击通知,当应用程序从SCRATCH启动(不运行到后台)时.
- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification
=>没问题 !
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { UILocalNotification *localNotif = [launchOptions objectForKey:UIApplicationLaunchOptionsLocalNotificationKey]; }
但是launchOptions总是没有!当应用程序通过点击应用程序图标(正常)从零开始,而且当应用程序从头开始通过点击通知(不正常)启动时,为零.
有谁知道如何解决这个问题?
谢谢 !!!
编辑1
以下是我的通知如何创建(Joe问题):
NSDictionary *userInfo = [NSDictionary dictionaryWithObjects: [NSArray arrayWithObjects:notifText,latitudeString,longitudeString,nil] forKeys:[NSArray arrayWithObjects:@"notifText",@"latitude",@"longitude",nil]]; UILocalNotification *localNotif = [[UILocalNotification alloc] init]; localNotif.fireDate = itemDate; localNotif.timeZone = [NSTimeZone defaultTimeZone]; localNotif.alertBody =msg; localNotif.alertAction = @"Ok"; localNotif.soundName = UILocalNotificationDefaultSoundName; localNotif.applicationIconBadgeNumber = 1; localNotif.userInfo = userInfo; [[UIApplication sharedApplication] scheduleLocalNotification:localNotif]; [localNotif release];
编辑2(回答我的问题:) 原文链接:https://www.f2er.com/iOS/336064.html