【发布时间】:2019-11-20 23:15:40
【问题描述】:
所以这就是故事。我最终继承了一个我试图帮助支持的 iphone 应用程序。我更像是一个 python 开发人员,而不是 swift,但我边走边学。我修复了这个应用程序的其他一些问题,但我卡在徽章通知上。显然,“UIUserNotificationType”在 iOS 10 之后已弃用。谁能给我指点教程或任何好的文档?
我需要更新以下方法:
func initialize(application:UIApplication){
let notificationTypes: UIUserNotificationType = [UIUserNotificationType.alert, UIUserNotificationType.badge, UIUserNotificationType.sound]
let pushNotificationSettings = UIUserNotificationSettings(types: notificationTypes, categories: nil)
application.registerUserNotificationSettings(pushNotificationSettings)
application.registerForRemoteNotifications()
}
我遇到以下 3 个问题:
'UIUserNotificationType' 在 iOS 10.0 中已弃用:使用 UserNotifications Framework 的 UNAuthorizationOptions'
“UIUserNotificationSettings”在 iOS 10.0 中已弃用:使用 UserNotifications Framework 的 UNNotificationSettings”
'registerUserNotificationSettings' 在 iOS 10.0 中已弃用:使用 UserNotifications Framework 的 -[UNUserNotificationCenter requestAuthorizationWithOptions:completionHandler:] 和 -[UNUserNotificationCenter setNotificationCategories:] 我找到了苹果文档https://developer.apple.com/documentation/usernotifications/unauthorizationoptions
我怎样才能把它放到 UIUserNotificationType 数组中?任何帮助,将不胜感激。谢谢!
【问题讨论】:
标签: ios swift iphone apple-push-notifications