Integrating Live Activities with Xtremepush

Prev Next
This content is currently unavailable in Portuguese (Brazil). You are viewing the default (English) version.

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:

  1. 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, where live_activity_token is referred to as push_token

  2. User Subscription: Your application subscribes a user to a specific sporting event by calling the relevant Xtremepush SDK method with the user's live_activity_token and the sport_event_id
    The sport_event_id is the identifier for the sporting event from Sportradar's feed.

  3. 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): The sport_event_id for the sport event

  • activityToken (string): The unique live_activity_token for 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., awayTeamScore as 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:

  1. On the Overview tab, locate the event in the mapping list.

  2. Select edit next to the event.

  3. 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.

  1. Navigate to the Live Activity Test Tool tab in your integration settings. The tab displays the data fields for a sporting event.

  2. Edit the data fields as needed.

  3. Click Send Update

  4. A live activity update will be sent to your connected device, allowing you to see how your changes appear in real-time.