我正在尝试实现丰富的推送通知,但注册推送通知有问题。
有人帮我吗?
我正在尝试实现丰富的推送通知,但注册推送通知有问题。
有人帮我吗?
我检查了苹果文档并找到了一种方法,其中一些Class在 iOS 10 中被废弃,我们一直使用到 iOS 9.x
步骤有:
UserNotificationslet 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)
}