通知在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) }