我想向我的 tvOS 应用程序发送静默通知。这是否需要向用户询问通知权限?或者仅仅注册远程通知并在 Info.plist 中启用匹配的应用程序功能就足够了吗?
UNUserNotificationCenter.current().requestAuthorization(options: [.alert, .sound, .badge]) { (granted: Bool, error: Error?) in
if error != nil {
print(error?.localizedDescription ?? "error requesting notification authorization")
}
}
UIApplication.shared.registerForRemoteNotifications()