我已经设置了本地通知,如下所示:
-(void)startLocalNotification
{
UILocalNotification *notification = [[UILocalNotification alloc] init];
notification.fireDate = [NSDate dateWithTimeIntervalSinceNow:7];
notification.alertBody = @"This is local notification!";
notification.timeZone = [NSTimeZone defaultTimeZone];
notification.soundName = UILocalNotificationDefaultSoundName;
notification.applicationIconBadgeNumber = 10;
NSDictionary *infoDict = [NSDictionary dictionaryWithObject:@"Hello! This is Local Notification!" forKey:@"Notification"];
notification.userInfo = infoDict;
[[UIApplication sharedApplication] scheduleLocalNotification:notification];
}
我在 iPhone 模拟器上收到了通知。但它不会触发 watchkit 应用程序的通知。我在 watchkit 扩展中的 NotificationController.m 中使用以下方法-
- (void)didReceiveLocalNotification:(UILocalNotification *)localNotification withCompletion:(void (^)(WKUserNotificationInterfaceType))completionHandler
{
NSLog(@"Notification Received ..");
completionHandler(WKUserNotificationInterfaceTypeCustom);
}
谁能告诉我为什么我没有在 watchkit App 中收到本地通知。
提前致谢。