UserNotifications ios10 通知使用

通知在ios10 中推荐使用 

导入  import UserNotifications  头文件

 if #available(iOS 10.0, *) {
            UNUserNotificationCenter.current().requestAuthorization(options: [.carPlay,.badge,.sound,.alert]) { (Success, error) in
            }
        } else {
            let setting = UIUserNotificationSettings(types: [.alert,.badge,.sound], categories: nil)
            application.registerUserNotificationSettings(setting)
        }

 

posted @ 2017-05-11 21:41  ZhangShengjie  阅读(218)  评论(0)    收藏  举报