我想显示两个可能的操作:一个文本输入UIUserNotificationActionBehavior.TextInput,另一个作为普通操作,看起来像一个按钮。
如果我只使用其中一个,它可以正常工作,但是一旦我使用它们中的两个,它就会被打破为通知横幅(未锁定的屏幕):只显示按钮,一旦我点击它出现了TextInput。
是否可以在横幅上同时使用它们?
这是我的代码:
let replyAction : UIMutableUserNotificationAction = UIMutableUserNotificationAction()
replyAction.identifier = "REPLY"
replyAction.title = "Reply"
replyAction.behavior = UIUserNotificationActionBehavior.TextInput
replyAction.destructive = false
replyAction.authenticationRequired = false
replyAction.activationMode = UIUserNotificationActivationMode.Background
let defaultReplyAction : UIMutableUserNotificationAction = UIMutableUserNotificationAction()
defaultReplyAction.identifier = "DEFAULT_REPLY"
defaultReplyAction.title = "Default"
defaultReplyAction.activationMode = UIUserNotificationActivationMode.Background
defaultReplyAction.authenticationRequired = false
defaultReplyAction.destructive = false
let notificationMessageCategory : UIMutableUserNotificationCategory = UIMutableUserNotificationCategory()
notificationMessageCategory.identifier = "MESSAGE_CATEGORY"
notificationMessageCategory.setActions([replyAction, defaultReplyAction], forContext: UIUserNotificationActionContext.Default)
notificationMessageCategory.setActions([replyAction, defaultReplyAction], forContext: UIUserNotificationActionContext.Minimal)
let settings = UIUserNotificationSettings(forTypes: [.Alert, .Sound], categories: NSSet(array: [notificationMessageCategory]) as? Set<UIUserNotificationCategory>)
UIApplication.sharedApplication().registerUserNotificationSettings(settings)