tvOS

Airship SDK support and setup for Apple tvOS applications

Because of the difference in the underlying design between tvOS and iOS, only a subset of Airship’s iOS features are available for tvOS:

FeatureUse case
BadgesBadge an app icon to draw users' attention to new content.
Content-available Push NotificationsA message that can appear on any screen on a mobile device. Push notifications appear as banners.Fetch new content in the background without requiring user action.
Analytics, including Real-Time Data StreamingA service that delivers engagement events in real time via the Data Streaming API or an Airship partner integration. and Performance AnalyticsA customizable marketing intelligence tool that provides access to reports and graphs based on engagement data.Track which in-app views your users navigate to the most.

Requirements

  • Minimum iOS version supported 14+
  • Requires Xcode 14.3+

SDK Installation and Setup

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 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 and Badges

The tvOS platform restricts push notifications to promote a less distracting user experience.

Badges are the only allowed user-visible notification. Their operations in tvOS are the same as in iOS. For more information about badge operations in tvOS see Badges in Getting Started with Push Notifications. For messages sent from the Airship dashboard, this is the Badge option.

Content-available pushes are available for performing content fetching and other silent operations in the background. Set the content_available property to true in the iOS override object. For messages sent from the Airship dashboard, this is the Background Processing option.

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 not unsupported. For more information see Analytics and Reporting.