Adding text field in Remote Notification, iOS 8

后端 未结 3 1459
忘了有多久
忘了有多久 2020-12-07 17:14

i want to add facility in my iOS application that user can reply to the my message directly from the push notification. Like iMessage app is doing it in iOS 8. I am able to

3条回答
  •  庸人自扰
    2020-12-07 17:34

    Swift 4.2, 4.0+ of satheeshwaran answer.

    //creating the inline reply notification action
    let replyAction = UIMutableUserNotificationAction()
    replyAction.title = "Say Something"
    replyAction.identifier = "inline-reply"
    replyAction.activationMode = .background
    replyAction.isAuthenticationRequired = false
    replyAction.behavior = .textInput
    
    //creating a category
    let notificationCategory = UIMutableUserNotificationCategory()
    notificationCategory.identifier = "INVITE_CATEGORY"
    notificationCategory.setActions([replyAction], for: .default)
    
    //registerting for the notification.
    let categories = NSSet(array: [notificationCategory]) as? Set
    let settings = UIUserNotificationSettings(types: [ .sound, .alert,.badge], categories: categories)
    application.registerUserNotificationSettings(settings)
    

提交回复
热议问题