gpt4 book ai didi

ios - ANCS : what is the concept of PositiveAction?

转载 作者:塔克拉玛干 更新时间:2023-11-02 10:30:50 32 4
gpt4 key购买 nike

我正在尝试使用 Apple 通知中心服务在蓝牙外围设备和 iOS 设备之间进行交互。在documentation Apple 提到了 2 个通知操作:EventFlagPositiveAction 和 EventFlagNegativeAction ...

到目前为止,Negative 部分起作用:一旦通知被传输到外设,后一个可以触发否定 Action ,导致通知被驳回。

但我无法触发力的正面面...我的通知只有一个操作按钮,我希望此按钮被视为正面操作...但我没有知道它是如何工作的:它是隐式的吗?所有的 Action 都有positive标志吗?或者我应该做些什么让它被公认为是积极的

这更多是关于 ACNS 的概念性问题,但为了获得信息,下面是我正在使用的代码:

第一个在AppDelegate中注册本地通知:

    let notificationTypes = UIUserNotificationType.Alert.union(UIUserNotificationType.Sound).union(UIUserNotificationType.Badge)

let launchAction = UIMutableUserNotificationAction()
launchAction.identifier = "LAUNCH_ACTION"
launchAction.title = "OK"
launchAction.activationMode = UIUserNotificationActivationMode.Foreground
launchAction.destructive = false
/* this is this UIMutableUserNotificationAction that I want to trigger from my external device, and should be considered as the famous positive action I am looking for */

let notificationCategory = UIMutableUserNotificationCategory()

notificationCategory.identifier = "LAUNCH_NOTIFICATION"
notificationCategory.setActions([launchAction], forContext: .Minimal)
application.registerUserNotificationSettings(UIUserNotificationSettings(forTypes: notificationTypes, categories: NSSet(array:[notificationCategory]) as? Set<UIUserNotificationCategory>))

第二,稍后创建通知

    let localNotification:UILocalNotification = UILocalNotification()
localNotification.alertAction = "Hello"
localNotification.alertBody = "World"
localNotification.fireDate = NSDate(timeIntervalSinceNow: 5)
localNotification.soundName = UILocalNotificationDefaultSoundName
localNotification.hasAction = true
localNotification.category = "LAUNCH_NOTIFICATION"
UIApplication.sharedApplication().scheduleLocalNotification(localNotification)

最佳答案

好的,那么我已经从 Apple 开发人员技术支持那里得到了我的问题的答案。在这里发布,希望这会对其他人有所帮助:

the first thing to understand is that “Positive actions are only wired up for telephony related notifications (incoming call, missed call, and voicemail). There is currently no way to pass through the positive action for an app alert.

现在事情更容易理解了……

关于ios - ANCS : what is the concept of PositiveAction?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37795587/

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