tvOS中的Apple推送通知

嗨,我是tvOS的新手。 我有一个注册APNS的电视应用程序。

但是当我推送通知时,我无法收到通知。 我正在获取设备令牌但不是通知。

当我尝试移动设备时,我收到通知,但不是在tvOS为什么会这样……?

我怎么能解决这个问题?

let center = UNUserNotificationCenter.current() center.requestAuthorization(options: [.alert, .sound, .badge]) { (granted, error) in if granted == true { print("Allow") UIApplication.shared.registerForRemoteNotifications() } else { print("Don't Allow") } } func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) { let deviceTokenString = deviceToken.reduce("", {$0 + String(format: "%02X", $1)}) print("DEVICE TOKEN = \(deviceTokenString)") } func application(_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: Error) { print(error) } func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any]) { print(userInfo) } 

tvOS仅支持两种类型的通知: badgescontent-available 。 所以你需要将这两种类型中的一种发送给APNS。 任何这些类型的通知仅更改应用程序图标上的徽章编号。 当您打开应用程序时,只会将最新通知发送到您的应用程序。 iOS上的通知没有视觉呈现,如何看WWDC 2016 / Session 206 / tvOS的演示,从21:20开始观看

在此处输入图像描述

在此处输入图像描述

更新:在tvOS 11上出现了Silent notifications ,它唤醒了应用程序并允许在后台刷新内容

在此处输入图像描述

WWDC 2017观看时间为7:50