当前位置:  开发笔记 > 编程语言 > 正文

交互式通知未显示按钮ios 9.2

如何解决《交互式通知未显示按钮ios9.2》经验,为你挑选了0个好方法。

我相信我正在正确地创建交互式通知,但是我在跳板/锁定屏幕上没有按钮的情况下收到通知.我究竟做错了什么?

AppDelegate中:

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {

    let notificationSettings: UIUserNotificationSettings! = UIApplication.sharedApplication().currentUserNotificationSettings()

    /// don't want to constantly set/re-set when this function fires
    if (notificationSettings.types == UIUserNotificationType.None){

      let yesAction = UIMutableUserNotificationAction()
      yesAction.identifier = "yesAction"
      yesAction.title = "Yes"
      yesAction.destructive = false
      yesAction.authenticationRequired = false
      yesAction.activationMode = UIUserNotificationActivationMode.Background

      let noAction = UIMutableUserNotificationAction()
      noAction.identifier = "noAction"
      noAction.title = "No"
      noAction.destructive = false
      noAction.authenticationRequired = false
      noAction.activationMode = UIUserNotificationActivationMode.Background

      let stopAction = UIMutableUserNotificationAction()
      stopAction.identifier = "stopAction"
      stopAction.title = "Stop"
      stopAction.destructive = true
      stopAction.authenticationRequired = false
      stopAction.activationMode = UIUserNotificationActivationMode.Background

      let encouragementCategory = UIMutableUserNotificationCategory()
      encouragementCategory.identifier = "GOCEncouragement"
      encouragementCategory.setActions([yesAction, noAction, stopAction], forContext: UIUserNotificationActionContext.Default)
      encouragementCategory.setActions([yesAction, noAction], forContext: UIUserNotificationActionContext.Minimal)

      let settings = UIUserNotificationSettings(forTypes: [.Alert, .Sound], categories: Set.init(arrayLiteral: encouragementCategory))
      UIApplication.sharedApplication().registerUserNotificationSettings(settings)

        }

    return true
}

其他地方,叫做application(application: UIApplication, didRegisterUserNotificationSettings notificationSettings: UIUserNotificationSettings):

notificationArray.forEach({

    let notification = UILocalNotification.init()
    notification.fireDate = fireDay
    notification.soundName = UILocalNotificationDefaultSoundName
    notification.alertBody = $0["Encouragement"] as! String!
    notification.repeatInterval = .Month
    notification.category = "GOCEncouragement"
    notification.userInfo = [ "UUID" : $0["UUID"] as! Int]

    if #available(iOS 8.2, *) {

      notification.alertTitle = "Choices Encouragement"
    }

    UIApplication.sharedApplication().scheduleLocalNotification(notification)

    nextDay.day++

    fireDay = NSCalendar.currentCalendar().dateByAddingComponents(nextDay, toDate: fireDay!, options: NSCalendarOptions.init(rawValue: 0))
})

重新解决问题; 通知按计划显示,但锁定屏幕上的左侧滑动不会显示任何按钮,也不会拖拽主屏幕.

欢迎任何建议!

编辑:认为它只是模拟器,但也在现场9.2设备上.其他iOS版本按预期工作.

推荐阅读
N个小灰流_701
这个屌丝很懒,什么也没留下!
DevBox开发工具箱 | 专业的在线开发工具网站    京公网安备 11010802040832号  |  京ICP备19059560号-6
Copyright © 1998 - 2020 DevBox.CN. All Rights Reserved devBox.cn 开发工具箱 版权所有