我正在尝试实现富推送通知,但遇到了注册推送通知的问题。
有没有人帮我?
发布于 2016-08-13 22:05:58
我查看了苹果文档,发现一种方法,一些Class在iOS 10中是独立的,我们一直使用它直到iOS 9.x
步骤如下:
在info plist中添加框架UserNotifications
注册远程通知
let center = UNUserNotificationCenter.current()
center.requestAuthorization(options: [.alert, .sound, .badge]) { (granted, error) in
// Enable or disable features based on authorization.
if granted == true
{
print("Allow")
UIApplication.shared.registerForRemoteNotifications()
}
else
{
print("Don't Allow")
}
}获取令牌
func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
print(deviceToken)
}

https://stackoverflow.com/questions/38933350
复制相似问题