ANCS:PositiveAction的概念是什么?

时间:2016-06-13 17:17:01

标签: ios uilocalnotification

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

到目前为止,否定部分有效:一旦通知发送到外围设备,后者就会触发否定操作,从而导致通知被解雇。

但是我无法触发力量的正面方......我的通知有一个动作按钮,我希望这个按钮被视为积极行动......但我不知道它是如何工作的:是隐含的吗?所有操作都有正面标志吗?或者我应该做些什么来让它被认为是肯定的一个?

这是一个关于ACNS的概念性问题,但是有关信息,下面是我正在使用的代码:

第1次注册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)

1 个答案:

答案 0 :(得分:1)

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

  

首先要理解的是“积极行动仅用于与电话相关的通知(来电,未接来电和语音邮件)。目前无法通过应用提醒的正面操作。

现在更容易理解......