-3
最初的工作,我们导入UserNotifications
框架 ,我们在AppDelegate.swift
类初始化委托方法推送通知不SWIFT 3.0
if #available(iOS 10.0, *){
UNUserNotificationCenter.current().delegate = self
let center = UNUserNotificationCenter.current()
center.requestAuthorization(options:[.badge, .alert, .sound]) { (granted, error) in
if (granted)
{
UIApplication.shared.registerForRemoteNotifications()
}
else{
//Do stuff if unsuccessful...
}
// Enable or disable features based on authorization.
}
}
你有没有检查http://stackoverflow.com/questions/41035878/how-可以-I-STORE-推通知警报消息功能于userdefault/41037919#41037919 – Amanpreet