Apple Watch 通知镜像
Apple watch notification mirroring
我正在尝试在 Apple Watch 上创建带有操作的通知。然而,文档并没有真正说明什么是原生的以及应该制作什么。
目前我正在 iPhone 上创建一个 UILocalNotification。但是我想知道的是,操作按钮将在 Apple Watch 上镜像。
我用来在 iPhone 上创建通知的代码是:
let incrementAction = UIMutableUserNotificationAction()
incrementAction.identifier = "OPEN_ACTION"
incrementAction.title = "Open"
incrementAction.activationMode = UIUserNotificationActivationMode.Background
incrementAction.authenticationRequired = false
incrementAction.destructive = false
let counterCategory = UIMutableUserNotificationCategory()
counterCategory.identifier = "SLAGBOOM_CATEGORY"
counterCategory.setActions([incrementAction],
forContext: UIUserNotificationActionContext.Default)
counterCategory.setActions([incrementAction],
forContext: UIUserNotificationActionContext.Minimal)
let types = UIUserNotificationType.Alert
let settings = UIUserNotificationSettings(forTypes: types, categories: NSSet(object: counterCategory) as? Set<UIUserNotificationCategory>)
UIApplication.sharedApplication().registerUserNotificationSettings(settings)
let notification:UILocalNotification = UILocalNotification()
notification.alertBody = message
notification.category = "SLAGBOOM_CATEGORY"
UIApplication.sharedApplication().scheduleLocalNotification(notification)
我是否应该采取任何措施来确保按钮在 Apple Watch 上正常工作?还是我只需要为通知创建一个 watchkit 应用程序?
您可以免费获得默认通知,但用户唯一的选择是关闭它。
如果你想要一些自定义的东西,那么你想要创建自己的监视目标并在监视目标情节提要中构建不同的通知视图
这是 Apple 手表编程工具包上的page,它解释了您可以制作的不同自定义通知
我正在尝试在 Apple Watch 上创建带有操作的通知。然而,文档并没有真正说明什么是原生的以及应该制作什么。
目前我正在 iPhone 上创建一个 UILocalNotification。但是我想知道的是,操作按钮将在 Apple Watch 上镜像。
我用来在 iPhone 上创建通知的代码是:
let incrementAction = UIMutableUserNotificationAction()
incrementAction.identifier = "OPEN_ACTION"
incrementAction.title = "Open"
incrementAction.activationMode = UIUserNotificationActivationMode.Background
incrementAction.authenticationRequired = false
incrementAction.destructive = false
let counterCategory = UIMutableUserNotificationCategory()
counterCategory.identifier = "SLAGBOOM_CATEGORY"
counterCategory.setActions([incrementAction],
forContext: UIUserNotificationActionContext.Default)
counterCategory.setActions([incrementAction],
forContext: UIUserNotificationActionContext.Minimal)
let types = UIUserNotificationType.Alert
let settings = UIUserNotificationSettings(forTypes: types, categories: NSSet(object: counterCategory) as? Set<UIUserNotificationCategory>)
UIApplication.sharedApplication().registerUserNotificationSettings(settings)
let notification:UILocalNotification = UILocalNotification()
notification.alertBody = message
notification.category = "SLAGBOOM_CATEGORY"
UIApplication.sharedApplication().scheduleLocalNotification(notification)
我是否应该采取任何措施来确保按钮在 Apple Watch 上正常工作?还是我只需要为通知创建一个 watchkit 应用程序?
您可以免费获得默认通知,但用户唯一的选择是关闭它。
如果你想要一些自定义的东西,那么你想要创建自己的监视目标并在监视目标情节提要中构建不同的通知视图
这是 Apple 手表编程工具包上的page,它解释了您可以制作的不同自定义通知