第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

在Xcode 8 / Swift 3.0中注冊推送通知?

在Xcode 8 / Swift 3.0中注冊推送通知?

慕哥9229398 2019-07-31 18:17:10
在Xcode 8 / Swift 3.0中注冊推送通知?我正在嘗試讓我的應用程序在Xcode 8.0中運行,并且遇到了錯誤。我知道這個代碼在以前版本的swift中運行良好,但我假設在新版本中更改了代碼。這是我正在嘗試運行的代碼:let settings = UIUserNotificationSettings(forTypes: [.Sound, .Alert, .Badge], categories: nil)     UIApplication.sharedApplication().registerUserNotificationSettings(settings)UIApplication.shared().registerForRemoteNotifications()我得到的錯誤是“參數(shù)標簽”(forTypes:,categories :)'與任何可用的重載都不匹配“是否有一個不同的命令,我可以嘗試使其工作?
查看完整描述

3 回答

?
鴻蒙傳說

TA貢獻1865條經(jīng)驗 獲得超7個贊

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

    if #available(iOS 10, *) {

        //Notifications get posted to the function (delegate):  func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: () -> Void)"

        UNUserNotificationCenter.current().requestAuthorization(options: [.alert, .badge, .sound]) { (granted, error) in

            guard error == nil else {
                //Display Error.. Handle Error.. etc..                return
            }

            if granted {
                //Do stuff here..
                //Register for RemoteNotifications. Your Remote Notifications can display alerts now :)                DispatchQueue.main.async {
                    application.registerForRemoteNotifications()
                }
            }
            else {
                //Handle user denying permissions..            }
        }

        //Register for remote notifications.. If permission above is NOT granted, all notifications are delivered silently to AppDelegate.        application.registerForRemoteNotifications()
    }
    else {
        let settings = UIUserNotificationSettings(types: [.alert, .badge, .sound], categories: nil)
        application.registerUserNotificationSettings(settings)
        application.registerForRemoteNotifications()
    }

    return true}


查看完整回答
反對 回復 2019-07-31
  • 3 回答
  • 0 關注
  • 667 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網(wǎng)微信公眾號