tvOS
Airship SDK support for tvOS applications.
The Airship SDK can be built to support tvOS applications. Because of the difference in the underlying design between tvOS and iOS - only a subset of Airship’s iOS features are available on tvOS.
tvOS currently supports the following features:
- Badges
- Content-available Pushes
- Analytics (Including Airship Real-Time Data Streaming and Performance Analytics)
Requirements
- Minimum iOS version supported
14+
- Requires Xcode
14.3+
SDK Installation and set up
The Airship SDK can be installed using CocoaPods, Swift Package Manager, Carthage, or manually. Aside from differences in feature support, the process for installing and configuring the Airship SDK for tvOS devices is the same as iOS devices. Refer to the iOS SDK Setup guide for further set up instructions.
tvOS Sample
The tvOS sample is written in Swift and can be used to test and explore the supported feature set with minimal configuration steps. To get started with the tvOS sample , check out the tvOS Sample readme for step-by-step setup instructions.
Push Notifications
Push notifications on the tvOS platform are more restricted to promote a less distracting user experience. On tvOS, user-visible notifications are restricted to badges. Badge operations in tvOS are the same as in iOS. For more information about badge operations in tvOS see Badges in iOS.
Content-available pushes are also available for performing content fetching and other silent operations in the background.
Handling Push Notifications
Handling notifications on tvOS is nearly identical to iOS. tvOS handles push notifications received outside the application, but if a notification is received while the app is active, it’s up to the application developer to handle it.
Sample UAPushNotificationDelegate implementation
class PushHandler: NSObject, PushNotificationDelegate {
func receivedBackgroundNotification(_ notificationContent: UANotificationContent, completionHandler: @escaping (UIBackgroundFetchResult) -> Swift.Void) {
// Application received a background notification
print("The application received a background notification");
// Call the completion handler
completionHandler(.noData)
}
func receivedForegroundNotification(_ notificationContent: UANotificationContent, completionHandler: @escaping () -> Swift.Void) {
// Application received a foreground notification
print("The application received a foreground notification");
// Let system handle it
completionHandler()
}
func extendPresentationOptions(options: UNNotificationPresentationOptions, notification:UNNotification) -> UNNotificationPresentationOptions {
var newOptions : UNNotificationPresentationOptions = options
newOptions.insert(.badge)
return newOptions
}
}
@implementation PushHandler
-(void)receivedBackgroundNotification:(UANotificationContent *)notificationContent completionHandler:(void (^)(UIBackgroundFetchResult))completionHandler {
// Application received a background notification
UA_LDEBUG(@"The application received a background notification");
// Call the completion handler
completionHandler(UIBackgroundFetchResultNoData);
}
-(void)receivedForegroundNotification:(UANotificationContent *)notificationContent completionHandler:(void (^)(void))completionHandler {
// Application received a foreground notification
UA_LDEBUG(@"The application received a foreground notification");
// Let system handle it
completionHandler();
}
- (UNNotificationPresentationOptions)extendPresentationOptions:(UNNotificationPresentationOptions)options notification:(UNNotification *)notification {
return options | UNNotificationPresentationOptionBadge;
}
@end
The tvOS sample UI includes a complete implementation of the UAPushNotificationDelegate protocol that handles badges and content-available pushes. However, if you wish to customize this behavior, you can provide your own implementation.
Analytics
Airship on tvOS fully supports analytics for tvOS implementations written in Swift. For tvOS implementations written in TVML, screen tracking is currently unsupported. For more information see Analytics and Reporting.
Categories