我正在尝试使用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应用程序?
答案 0 :(得分:0)
您可以免费获得默认通知,但仅限用户选项是将其解除。
如果您想要自定义内容,则需要创建自己的观看目标,并在观看目标情节提要中构建不同的通知视图
这是Apple手表编程套件上的page,解释了您可以制作的不同自定义通知