相关疑难解决方法(0)

操作按钮未出现在通知iOS 10中

我在我的应用程序中使用本地推送通知.当在iOS 10中为通知添加操作按钮时,它不会出现在通知下方.通知正在显示,但通知底部缺少操作按钮.appdelegate代码如下.

import UIKit
import CoreData
import UserNotifications

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

  var window: UIWindow?


  func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
    // Override point for customization after application launch.

    UNUserNotificationCenter.current().requestAuthorization(options: [.alert, .sound]) {(accepted, error) in
      if !accepted {
        print("Notification access denied.")
      }
    }
    let action = UNNotificationAction(identifier: "markCompleted", title: "Mark as Completed", options: [])
    let category = UNNotificationCategory(identifier: "todoList", actions: [action], intentIdentifiers: [], options: [])
    UNUserNotificationCenter.current().setNotificationCategories([category])
    return true
  }

  func applicationWillResignActive(_ application: UIApplication) …
Run Code Online (Sandbox Code Playgroud)

ios swift swift3 unusernotificationcenter

12
推荐指数
2
解决办法
3174
查看次数

标签 统计

ios ×1

swift ×1

swift3 ×1

unusernotificationcenter ×1