handleActionWithIdentifier:forLocalNotification:有时不会触发

时间:2015-10-07 21:57:59

标签: ios9 watchkit uilocalnotification

没有模式,但有时handleActionWithIdentifier:forLocalNotification:在本地通知的后台操作按钮上点击时不会被触发。当在Watch上发送的通知上点击操作按钮时会更频繁地发生这种情况,但有时也会在iPhone上发送通知时发生。

这就是我得出的结论,即该方法没有被解雇。

- (void)application:(UIApplication *)application handleActionWithIdentifier:(NSString *)identifier forLocalNotification:(UILocalNotification *)notification completionHandler:(void (^)())completionHandler {

NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSString *str = [[defaults objectForKey:@"WatchActionLog"]?[defaults objectForKey:@"WatchActionLog"]:@"" stringByAppendingString:[NSString stringWithFormat:@"**S**%@",[notification.userInfo valueForKeyPath:@"customDictionary.notificationName"]]];
[defaults setObject:str forKey:@"WatchActionLog"];
[defaults synchronize];

// Do something

str = [[defaults objectForKey:@"WatchActionLog"]?[defaults objectForKey:@"WatchActionLog"]:@"" stringByAppendingString:@"**E**"];
[defaults setObject:str forKey:@"WatchActionLog"];
[defaults synchronize];

completionHandler();}

每当动作没有完成它必须做的事情时,我注意到WatchActionLog也没有更新。

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSString *str = [defaults objectForKey:@"WatchActionLog"];
NSLog(@"Watch action log - %@",str);

// Remaining code follows }

还有其他人也看到过这个问题。 This是迄今为止我发现的另一个提及。我正在测试iOS 9 + watchOS 2。

0 个答案:

没有答案
相关问题