我正在解决我的应用没有响应交互式本地通知或显示已收到通知的任何迹象的问题。我可以看到,该应用的willFinishLaunchingWithOptions
已被触发,但没有传递launchOptions
。这是我的代码:
- (BOOL) application:(UIApplication *)application willFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
NSLog(@"will finish launching last time launched was %@", [[[CoreManager sharedManager] userDefaults] objectForKey:@"lastTimeLaunched2"]);
[[[CoreManager sharedManager] userDefaults] setObject:[NSDate date] forKey:@"lastTimeLaunched2"];
[[[CoreManager sharedManager] userDefaults] synchronize];
NSLog(@"will finish launching most recent launch options are %@", [[[CoreManager sharedManager] userDefaults] objectForKey:@"launchOptions2"]);
if(launchOptions) [[[CoreManager sharedManager] userDefaults] setObject:launchOptions forKey:@"launchOptions2"];
else [[[CoreManager sharedManager] userDefaults] setObject:@"no launch options" forKey:@"launchOptions2"];
[[[CoreManager sharedManager] userDefaults] synchronize];
return YES;
}
当我在与本地通知交互后启动应用时,日志会指示上次启动时的正确时间是......作为我与之互动的时间本地通知但 launchOptions似乎总是为零。如果没有launchOptions,我的代码如何对用户在本地通知中的操作做出反应?
答案 0 :(得分:0)
您需要查看处理从本地通知启动的应用的application:handleActionWithIdentifier:forLocalNotification:completionHandler:
和application:handleActionWithIdentifier:forLocalNotification: withResponseInfo:completionHandler
。
并且,application:didReceiveLocalNotification:
可在您的应用处于有效状态时处理本地通知的接收。