【发布时间】:2017-04-11 16:15:07
【问题描述】:
如何直接从 WatchKit 发送本地通知?甚至可能吗? Apple 文档说,从 Watch 安排的本地通知会直接发送到 Watch,因此似乎必须有办法做到这一点。
在 iOS 中我会这样做:
但是无法从 Watch 共享应用程序....
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];
【问题讨论】:
-
使用
UserNotifications框架
标签: ios objective-c watchkit apple-watch