gpt4 book ai didi

ios - Apple Watch 通知镜像

转载 作者:行者123 更新时间:2023-11-30 13:43:42 25 4
gpt4 key购买 nike

我正在尝试通过 Apple Watch 上的操作创建通知。然而,文档并没有真正说明什么是 native 的以及应该制作什么。

目前我正在 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 应用程序仅用于通知?

最佳答案

您免费获得默认通知,但用户唯一的选择是关闭它。

如果您想要自定义内容,那么您需要创建自己的监视目标并在监视目标 Storyboard 中构建不同的通知 View

这是page Apple 的 Watch 编程套件解释了您可以发出的不同自定义通知

关于ios - Apple Watch 通知镜像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35241545/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com