TVOS remote notification replacement
What part of the registration errors out for you? Notification dialogs and banners may not really make sense on tvOS, but can you send a silent push notification? All you need to do to register for these is
[application registerForRemoteNotifications];
You do not need to display the request dialog to the user for permission for silent notifications (you do need to have the remote notifications entitlement though.)
According to Apple's documents here, they allow CloudKit. CloudKit subscriptions rely on silent push notifications that I would assume would work on tvOS (without them it would severely cripple CloudKit)
If that still does't work, then you could create your own long polling connection (essentially, you would be making your own custom push notifications). It would only be able to send messages to devices that have the app opened however.
Apple Push Notifications in tvOS
tvOS supports only 2 types of notifications: badges
and content-available
. So you need to send one of these two types to APNS. Any of these types notification only changes badge number on App Icon. And only the lastest notification will be delivered to your application when you open the app. There is no visual presentation of notification as it was on iOS
How it looks see on presentation from WWDC 2016/Session 206/tvOS, start watching from 21:20
UPDATE:
On tvOS 11 appeared Silent notifications
which wakes the application up and allow to refresh content in background
WWDC 2017 watch from 7:50
How to detect touches on UIViewController on tvOS
You can use touchesBegan
and touchesEnded
just like on iOS.
Can an iOS push notification selectively replace a prior notification?
Link: Local and Push Notification Programming Guide:
Quality of Service
Apple Push Notification service includes a default Quality of Service
(QoS) component that performs a store-and-forward function.If APNs attempts to deliver a notification but the device is offline,
the notification is stored for a limited period of time, and delivered
to the device when it becomes available.Only one recent notification for a particular application is stored.
If multiple notifications are sent while the device is offline, each
new notification causes the prior notification to be discarded. This
behavior of keeping only the newest notification is referred to as
coalescing notifications.If the device remains offline for a long time, any notifications that
were being stored for it are discarded.
How to detect volume button press on tvOS remote
It is not clear all other code, but you have to keep reference to created observer.
Here is possible solution (tested with Xcode 12.1)
private var observer: NSKeyValueObservation?
// ... other code
self.observer = audioSession?.observe(\.outputVolume) { [weak self] (audioSession, _) in
guard let `self` = self else { return }
let mute = audioSession.outputVolume
var isMuted = false
if (mute == 0) && (!self.player.isMuted) {
isMuted = true
} else if (mute.isZero) && (self.player.isMuted) {
isMuted = false
}
// do what's needed here with `isMuted`
}
Related Topics
How to Retrieve All Available Finder Tags
Check If a Character Is Lowercase or Uppercase
Firebasecore Lexical or Preprocessor Issue
Uibezierpath Appending Overlapping Isn't Filled
Timer Not Firing Every Second on Watchkit
Swift Repl: How to Save/Load the Repl State? (A.K.A. Suspend/Resume, Snapshot, Clone)
Classes in Swift Files Inside Folder References Not Seen by Xcode 10's Compiler
In Swift, Why Can't I Instantiate a Protocol When It Has an Initialiser
Swiftui: How to Find the Height of an Image and Use It to Set the Size of a Frame
Ios8 Swift Uisearchcontroller Hides Navigationbar
Uitableviewautomaticdimension Not Working on iOS 8
Notification Extension Access Core Data
How to Set Avaudioengine Input and Output Devices (Swift/Macos)
How to Use the "Handler" of Uialertaction to Call Another Uialertaction
Is It Safe to Force Unwrap an Optional After Checking It Is Not Nil
Create a Loading Image/ Activity Indicator, Until the Image Is Shown in the Screen in Swift