This page provides a technical implementation overview for the live activities integration and the details required from you to enable the integration.
Implementation Overview
This integration uses live data from Sportradar's data feed.
The integration works in three stages:
Start Live Activity: You start a live activity on your user's device, which generates a
live_activity_token. Ideally, you should start the live activity as close to the game start as possible.
For more information, see Apple's documentation on Starting and updating Live Activities with ActivityKit push notifications, wherelive_activity_tokenis referred to aspush_tokenUser Subscription: Your application subscribes a user to a specific sporting event by calling the relevant Xtremepush SDK method with the user's
live_activity_tokenand thesport_event_id
Thesport_event_idis the identifier for the sporting event from Sportradar's feed.Live Activity Updates: As the live sporting event unfolds, Xtremepush processes the data and sends correctly formatted APNs updates to the user's device, which provides the real-time data for the live activity.
Subscribing Users to an Event
When a user in your app subscribes to a sporting event, your application must call the following method in the Xtremepush SDK to register the device. This method handles the API call to Xtremepush and registers the device to receive real-time updates for that specific sporting event.
Method
XPush.followSportsFeed(sportEventID, withToken: activityToken ?? "")sportEventID(string): Thesport_event_idfor the sport eventactivityToken(string): The uniquelive_activity_tokenfor the live activity
Receiving Live Activity Updates
Once a user is subscribed, Xtremepush automatically sends APNs updates to their device. You must ensure that your application's ActivityAttributes are configured to parse the incoming payload and display the data to your user.
Match Variable Names and Types
Your app's live activity code must use the exact variable names for the data points and types listed below (e.g.,
awayTeamScoreas an integer) to correctly display the updates.
Data Payload by Sport
NFL Live Activities
For NFL Live activities, Xtremepush ensures that all variables listed in the table below are included in every update payload. You can then choose which of these variables to implement and display.
Variable | Data Type | Default (set when nothing is sent by Sportradar) |
|---|---|---|
homeTeamScore | Int | 0 |
awayTeamScore | Int | 0 |
lastEvent | String | |
homeTeamPossesses | Bool | false |
awayTeamPossesses | Bool | false |
isLive | Bool | false |
currentQuarter | Int | |
timeLeftInQuarter | String | '00:00' |
currentDown | Int | 0 |
yardsToGoForFirst | Int | 0 |
currentYardLine | String | " " |
eventType | String |
MLB Live Activities
For MLB activities, the homeTeamScore, awayTeamScore, and eventType attributes are included in every payload. All other attributes are optional, and are only included in the update payload if the information is available from the data feed at that moment.
Attribute | Type | Status |
|---|---|---|
homeTeamScore | int | Required |
awayTeamScore | int | Required |
eventType | string | Required |
currentInning | int | Optional |
lastEvent | string | Optional |
outs | int | Optional |
balls | int | Optional |
strikeCount | int | Optional |
homeTeamHits | int | Optional |
awayTeamHits | int | Optional |
baseRunners | array | Optional |
isTopOfInning | bool | Optional |
isBottomOfInning | bool | Optional |
isLive | bool | Optional |
Details to Send Xtremepush
You must provide the following details to Xtremepush, so we can configure the live activities integration for your account:
Your iOS Bundle ID
Your APNs Auth Key (.p8 file)
The corresponding Key ID and Team ID for your .p8 key
Once our team receives these details, we will configure the Real-Time Sports Update integration for your account, which enables the live activities functionality.
You will be notified when the setup is complete, at which point you can view the integration by navigating to Settings > Marketplace > Configured Integrations in Xtremepush.
Configure Event Alerts
From the Overview tab of your integration, you can control which events trigger a Live Activity alert for your users. By default, alerts for all events are turned off.
To enable an alert for a specific event:
On the Overview tab, locate the event in the mapping list.
Select edit next to the event.
Turn on the toggle to enable alerts.
Testing your Integration
After the integration has been configured by our team, you can use the testing tool in the configured integration to send test updates and verify your setup.
Navigate to the Live Activity Test Tool tab in your integration settings. The tab displays the data fields for a sporting event.
Edit the data fields as needed.
Click Send Update
A live activity update will be sent to your connected device, allowing you to see how your changes appear in real-time.