我花了最后5个小时试图找出如何在swift2.1中显示REMOTE推送通知中的操作 .

事实:1-我收到通知,但它没有显示选项2-我能够生成一个本地通知,行动没有任何问题

码:

enum Actions:String{
    case increment = "INCREMENT_ACTION"
    case decrement = "DECREMENT_ACTION"
    case reset = "RESET_ACTION"
}

var categoryID:String {
    get{
        return "COUNTER_CATEGORY"
    }
}

    func registerNotification() {


    //removeNotification()


    // 1. Create the actions **************************************************

    // increment Action
    let incrementAction = UIMutableUserNotificationAction()
    incrementAction.identifier = Actions.increment.rawValue
    incrementAction.title = "Yes"
    incrementAction.activationMode = UIUserNotificationActivationMode.Background
    incrementAction.authenticationRequired = false
    incrementAction.destructive = false

    // decrement Action
    let decrementAction = UIMutableUserNotificationAction()
    decrementAction.identifier = Actions.decrement.rawValue
    decrementAction.title = "No"
    decrementAction.activationMode = UIUserNotificationActivationMode.Background
    decrementAction.authenticationRequired = true
    decrementAction.destructive = false

    // reset Action
    let resetAction = UIMutableUserNotificationAction()
    resetAction.identifier = Actions.reset.rawValue
    resetAction.title = "RESET"
    resetAction.activationMode = UIUserNotificationActivationMode.Foreground
    // NOT USED resetAction.authenticationRequired = true
    resetAction.destructive = true


    // 2. Create the category ***********************************************

    // Category
    let counterCategory = UIMutableUserNotificationCategory()
    counterCategory.identifier = categoryID

    // A. Set actions for the default context
    counterCategory.setActions([incrementAction, decrementAction, resetAction],
        forContext: UIUserNotificationActionContext.Default)

    // B. Set actions for the minimal context
    counterCategory.setActions([incrementAction, decrementAction],
        forContext: UIUserNotificationActionContext.Minimal)


    // 3. Notification Registration *****************************************

    let types = UIUserNotificationType.Alert //| UIUserNotificationType.Sound
    let settings = UIUserNotificationSettings(forTypes: types, categories: NSSet(object: counterCategory) as! Set<UIUserNotificationCategory>)


    print("About to register remote notification")

    UIApplication.sharedApplication().registerUserNotificationSettings(settings)
    UIApplication.sharedApplication().registerForRemoteNotifications()




}

func application(application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: NSData!) {
    print("Got token data! \(deviceToken)")
    print(deviceToken.hexString)


}

func application(application: UIApplication, didReceiveRemoteNotification userInfo: [NSObject : AnyObject]) {

    print("Recived: \(userInfo)")

    //Parsing userinfo:
    var temp : NSDictionary = userInfo
    if let info = userInfo["aps"] as? Dictionary<String, AnyObject>
    {
        var alertMsg = info["alert"] as! String

// var alert:UIAlertView! // alert = UIAlertView( Headers :“”,消息:alertMsg,delegate:nil,cancelButtonTitle:“OK”)// alert.show()

}


}

func application(application: UIApplication, handleActionWithIdentifier identifier: String?, forRemoteNotification userInfo: [NSObject : AnyObject], withResponseInfo responseInfo: [NSObject : AnyObject], completionHandler: () -> Void) {
    print("Im here")
    if userInfo["category"] as! String  == categoryID {
        print("Yes")
        let action:Actions = Actions(rawValue: identifier!)!
        var counter = 0;

        switch action{

        case Actions.increment:
            attemptReconnectionToSocket()

        case Actions.decrement:
            counter--

        case Actions.reset:
            counter=0

        }
    }

    completionHandler()

}

HELP!!!