如何在目标c中添加文本字段来推送通知?

时间:2016-05-19 09:13:13

标签: ios objective-c iphone swift

我想添加文本字段来推送通知,即当应用程序处于后台时。我将一些代码添加到UIUserNotificatioSetting.But我没有得到texfield推送通知,任何人都可以解决这个问题?

1 个答案:

答案 0 :(得分:0)

查看此帖子对您有用 Adding text field in Remote Notificaton, iOS 8

//creating the inline reply notification action
   let replyAction = UIMutableUserNotificationAction()
   replyAction.title = "Say Something"
   replyAction.identifier = "inline-reply"
   replyAction.activationMode = .Background
   replyAction.authenticationRequired = false
   replyAction.behavior = .TextInput

 //creating a category
   let notificationCategory:UIMutableUserNotificationCategory = UIMutableUserNotificationCategory()
   notificationCategory.identifier = "INVITE_CATEGORY"
   notificationCategory .setActions([replyAction], forContext: UIUserNotificationActionContext.Default)

 //registerting for the notification.
      application.registerUserNotificationSettings(UIUserNotificationSettings(forTypes:[ UIUserNotificationType.Sound, UIUserNotificationType.Alert,
            UIUserNotificationType.Badge], categories: NSSet(array:[notificationCategory]) as? Set<UIUserNotificationCategory>))