-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