Methods and parameters - React Native
Global Static Methods
initialize
Initialization method of the SDK.
Parameters:
apiKey: The API key.externalUserId: The viewer ID for a logged-in viewer. Your app supplies this value. From React Native SDK 2.0.1, the SDK keeps it across launches until you call logout. See Viewer ID specifications.restoreExternalUserId: Available from React Native SDK 2.0.1. Optional, defaults totrue. With noexternalUserId,initrestores the previous session's viewer. Set it tofalseto start this launch anonymous: the SDK logs out a stored viewer. Ignored when you passexternalUserId. On Android, a blankexternalUserIdcounts as not passed; on iOS, it is used as the user ID.externalUserToken: The viewer token for content entitlement checks, available from React Native SDK 1.21.0. The SDK holds it in memory only, so supply it on every launch. See setExternalUserToken.cachingSize: The amount of possible cached content size restricted in MBs. Optional from React Native SDK 2.0.1. When omitted, the SDK uses the native cache size.cachingLevel: OptionalBlazeCachingLevel, the level of content prefetching:'LOW','DEFAULT','HIGH', or'EXTREME'.geoLocation: specifies a geo-location-based restriction using a geo-location code. Defaults to null, meaning no geo-restriction is applied. If set to a valid geo-location code, access is restricted to that specific geographic area. For more information, see Geolocation restrictions.forceLayoutDirection:'ltr'or'rtl'. Forces the SDK screens into that layout direction, regardless of the device's system locale. When omitted, the SDK follows the system layout direction. Initialization-time only. See forceLayoutDirection.appOverridesCTAHandling: Optionalboolean, defaults tofalse. Set it totruewhen your app opens CTA links itself, for players opened from entry points such asplayStory. Widgets have their own prop. See appOverridesCTAHandling.interactionLinkHandling:'Deeplink','Web', or'Handled', how the SDK handles a link that an Engagement Layer interaction asks to open. When omitted, the SDK opens the link externally ('Deeplink'). A widget's owninteractionLinkHandlingtakes precedence. See interactionLinkHandling.defaultStoryPlayerStyle,defaultMomentsPlayerStyle,defaultVideosPlayerStyle: The default player style for each content type. See Default player styles.globalDelegate: You can provide a delegate that will be notified upon different events from the sdk. You can find more here.playerEntryPointDelegate: You can provide a delegate that will be notified upon different events from the sdk. You can find more here.
try {
await BlazeSDK?.init({
apiKey: 'Your Api Key',
cachingSize: 512,
cachingLevel: 'DEFAULT',
....
}
);
} catch (e) {
console.log('Init error', e);
}After successfully completing the initialization process, all methods are prepared for immediate use.
Ensure that you import the SDK in all React Native components that need to utilize it.
OverviewThe
externalUserIdparameter is used to uniquely identify a viewer session when initializing the SDK. This identifier serves as a key for customizing and tracking viewer-related activities during the SDK session.
Restoring the viewer
From React Native SDK 2.0.1, the SDK keeps the external user ID across launches. If you initialize the SDK withoutexternalUserId, it restores the previous session's viewer by default. To start every launch anonymous, passrestoreExternalUserId: false. To log the viewer out at any other time, call logout. Activities in an anonymous session aren't associated with any viewer identifier until you set anexternalUserId.
Overriding Behavior
If you initialize the SDK with a newexternalUserId, the SDK overrides the previous viewer identifier. The newexternalUserIdis used for all subsequent activities and tracking. When the previous viewer was identified, their unsynced activity is sent to WSC Sports and their local activity is cleared from the device. The SDK then loads the activity stored for the new identifier, so setting a previous identifier again loads that viewer's activity.
Recommended Practice
Due to the persistence, overriding, and logout behavior, use careful logic in your app to manage when and how to initialize new sessions. Make sure that you intentionally set, restore, or clearexternalUserIdbased on the desired outcome for viewer tracking and activity management.
Is Initialized
isInitialized
Return a boolean value that indicates whether the SDK has been initialized successfully or not.
const isInitialized = BlazeSDK?.isInitialized();Viewer ID
setExternalUserId
Sets the viewer ID for the current viewer. From React Native SDK 2.0.1, the SDK keeps the ID across launches until you call logout. See Viewer ID specifications.
Parameters:
externalUserId:string. Required and non-blank.
A blank externalUserId rejects with a BlazeException whose blazeError.reason is invalidExternalUserId, and nothing changes. Before 2.0.1, a blank value logged the viewer out on Android: call logout() instead. Setting the ID the SDK already has is a no-op. A viewer that could not be switched rejects with failedToSetExternalUserId.
try {
await BlazeSDK?.setExternalUserId('<EXTERNAL_USER_ID>');
} catch (error) {
console.error('Error setting external user ID:', error);
}logout
Available from React Native SDK 2.0.1. Logs out the current viewer. The SDK clears the viewer's local activity and follows, and continues as an anonymous viewer. Calling logout while anonymous succeeds without changes.
Call logout only after init resolves: an earlier call may reject with a BlazeException whose blazeError.reason is applicationNotInitialised, and nothing is logged out. A viewer that could not be logged out rejects with failedToLogout.
To log the viewer out at app launch, pass restoreExternalUserId: false to init instead.
try {
await BlazeSDK?.logout();
} catch (error) {
console.error('Error logging out:', error);
}Content entitlements
setExternalUserToken
Available from React Native SDK 1.21.0. Sets the viewer token used for content entitlement checks. See Content entitlements. In React Native, onContentRestricted is a notification and returns nothing, and reasons arrive as strings such as 'ExternalUserTokenMissing'.
The SDK holds the token in memory only, so supply it on every launch: through externalUserToken in the init options, or through this method once init resolves.
Parameters:
externalUserToken: The viewer token. Passnullto clear it.cachedContentPolicy:BlazeFetchedContentPolicy, what the SDK does with content it already fetched when the token changes. It has no default, because only your app knows whether the viewer changed.
| Value | Description |
|---|---|
'Keep' | Keep what was fetched. The same viewer got a fresh token, such as a routine refresh. |
'Evict' | Discard and refetch. The viewer identity changed, such as a sign-in or an account switch. |
With 'Evict', an open full-screen player keeps showing its content until it is reopened on iOS, and re-resolves the item on screen on Android.
Returns: Promise<string | null>. Resolves with the token the SDK stored, or null when externalUserToken is blank or cleared. Rejects when cachedContentPolicy is missing or not one of the values above.
try {
const storedToken = await BlazeSDK?.setExternalUserToken('<EXTERNAL_USER_TOKEN>', 'Evict');
console.log('Token stored:', storedToken !== null);
} catch (error) {
console.error('Error setting external user token:', error);
}Cold start
isInColdStart
Available from React Native SDK 1.21.0. Resolves whether the current viewer is in cold start for the given player type.
Parameters:
playerType:BlazePlayerType, one of'Moments','Stories', or'Videos'.
Returns: Promise<boolean | null>:
true: The For You feed for that content type serves cold-start content instead of the personalized model.false: The personalized model is served.null: The status is unknown, for example, because the viewer is anonymous (no external user ID was set) or user activity has not been fetched yet in this session.
The value refreshes with every user activity fetch: SDK initialization, returning to the foreground, and a viewer ID change. It does not change mid-session as the viewer interacts. Right after setExternalUserId, it resolves null until the new viewer's activity is fetched. An unrecognized playerType rejects the promise.
try {
const inColdStart = await BlazeSDK?.isInColdStart('Moments');
if (inColdStart === null) {
// Status unknown
} else {
console.log('Moments cold start:', inColdStart);
}
} catch (error) {
console.error('Error reading cold start status:', error);
}Do Not Track
setDoNotTrack
Apps can ask for analytics reporting to be flagged as anonymous usage only.
This is a globally setting affecting all analytics.
try {
await BlazeSDK?.setDoNotTrack(doNotTrackUser: boolean);
// 'setDoNotTrack success' action
} catch (error) {
// 'Error set do not track:' error action
}WSC Sports can enforce do not track for the app. When enforcement is on, the app cannot set this value to false. See Viewer privacy considerations and privacy compliance.
Disable Analytics
setDisableAnalytics
Apps can stop the SDK from collecting and sending analytics data to WSC Sports.
Content delivery and event callbacks keep working as usual.
try {
await BlazeSDK?.setDisableAnalytics(disableAnalytics: boolean);
// 'setDisableAnalytics success' action
} catch (error) {
// 'Error set disable analytics:' error action
}WSC Sports can enforce analytics off for the app. When enforcement is on, the app cannot set this value to false. See Viewer privacy considerations and privacy compliance.
Player sound state
setPlayerSoundState
Sets the SDK-wide sound state for Stories, Moments, and Videos players.
Parameters:
state:BlazePlayerSoundState, either'mute'or'unmute'.
try {
await BlazeSDK?.setPlayerSoundState('unmute');
// Player sound state updated successfully.
} catch (error) {
console.error('Error setting player sound state:', error);
}isMuted
Returns the current SDK-wide mute state.
The native default is muted, so isMuted() resolves to true until your app changes the sound state. The SDK does not persist this value across launches; re-apply it when your app starts.
try {
const muted = await BlazeSDK?.isMuted();
console.log('SDK player muted:', muted);
} catch (error) {
console.error('Error reading player sound state:', error);
}Liquid Glass
setLiquidGlassEnabled
Available from React Native SDK 1.21.0. iOS only: no-op on Android.
Determines whether the SDK renders real Liquid Glass (iOS 26 and later) behind its default player and widget elements. Defaults to false. Below iOS 26, nothing renders as glass.
Set it before a style is applied, for example, before BlazeSDK.init: a change has no effect until the style is next applied.
To override the flag for a single element, set glassBackground ('automatic', 'on', or 'off') on that element's style. See BlazePlayerButtonStyle.
Parameters:
enabled:trueto render Liquid Glass,falseto turn it off.
try {
await BlazeSDK?.setLiquidGlassEnabled(true);
await BlazeSDK?.init(blazeSdkInitOptions);
} catch (error) {
console.error('Error enabling Liquid Glass:', error);
}isLiquidGlassEnabled
Available from React Native SDK 1.21.0. Resolves the value last set with setLiquidGlassEnabled (default false). Below iOS 26, nothing renders as glass whatever the value. On Android, it always resolves false.
try {
const liquidGlassEnabled = await BlazeSDK?.isLiquidGlassEnabled();
console.log('Liquid Glass enabled:', liquidGlassEnabled);
} catch (error) {
console.error('Error reading Liquid Glass state:', error);
}Universal Links
handleUniversalLink
Handles a universal link URL.
This method takes a universal link URL as a string, processes it and optionally returns a result via a completion handler.
try {
await BlazeSDK?.handleUniversalLink(link: String);
// 'set universal link success' action
} catch (error) {
// 'Error set universal link:' error action
}canHandleUniversalLink
Determines if a given URL is recognized as a universal link for the Experiences SDK. The function checks if the provided link contains the domain specified as a universal link within the SDK configuration.
Parameters:
- link: The URL to be checked against the universal link domain.
Returns:
trueif the URL contains the domain considered as a universal link for the SDK,falseotherwise.
BlazeSDK.canHandleUniversalLink(link: string).then(canHandle => {
if (canHandle) {
// Can handle
} else {
// Can't handle
}
}).catch(error => {
// Handle error
});Notifications
When your app receives a push notification, check its payload with canHandlePushNotification, then pass the same payload to handleNotificationPayload so the SDK can process it. Pass the notification's custom data: remoteMessage.data with Firebase Cloud Messaging, or the push payload's extras with Airship.
async function handleBlazeNotification(data: object) {
try {
const canHandle = await BlazeSDK.canHandlePushNotification(data);
if (canHandle) {
await BlazeSDK.handleNotificationPayload(data);
}
} catch (error) {
// Handle error
}
}canHandlePushNotification
Checks whether the SDK can handle a notification's payload.
canHandlePushNotification(payload: object): Promise<boolean>Parameters:
- payload: An object representing the payload to be checked. The keys and values are specific to the notification's data structure.
Returns: A promise that resolves to true if the SDK can handle the payload, otherwise false.
BlazeSDK.canHandlePushNotification(payload).then(canHandle => {
if (canHandle) {
// Can handle
} else {
// Can't handle
}
}).catch(error => {
// Handle error
});handleNotificationPayload
Handles a notification's payload.
handleNotificationPayload(payload: object): Promise<void>Parameters:
- payload: An object representing the payload to be handled. The keys and values are specific to the notification's data structure.
Returns: A promise that resolves when the SDK finishes processing the payload, or rejects with an error if processing fails.
On Android, every value in the payload must be a string. The React Native method doesn't take a sourceId parameter.
BlazeSDK.handleNotificationPayload(payload).then(() => {
// Handled successfully
}).catch(error => {
// Handle error
});Geolocation Restrictions
updateGeoRestriction
Updates or removes the geo restriction based on the provided geo location code.
This method validates the given geo location code and updates the geo restriction settings accordingly. A null value for the geo location code indicates that the system should remove any existing restrictions.
The operation is executed asynchronously.
Parameters:
geoLocation: The geo location code, It should conform to the ISO 3166-1 alpha-2 standard. Whennull, it signals the removal of any existing geo restrictions.
try {
await BlazeSDK?.updateGeoRestriction(geoLocation: string?);
} catch (error) {
console.error(error);
}Search
showSearchScreen
Launches the built-in full-screen search experience. Viewers can browse suggestion content when the field is empty, then see search results grouped by Stories, Moments, and Videos. For how search works in your app, see Free text search and Data sources.
Platform reference: iOS | Android
Parameters:
- options: Optional
BlazeSearchScreenOptions. - iOS: Omit
options, or omitsuggestionsDataSource, to open the search screen without a suggestions grid. - Android: Pass
suggestionsDataSourceinoptions(required).
BlazeSearchScreenOptions:
| Property | Type | Description |
|---|---|---|
suggestionsDataSource | BlazeDataSourceType | Label-based data source for the suggestions grid shown before the viewer types. Use a labels data source (not search type). Required on Android; optional on iOS. See DataSource. |
Returns: Promise<void>. Rejects if the screen fails to launch.
const showSearchScreen = async (
options?: BlazeSearchScreenOptions,
): Promise<void> => {
try {
await BlazeSDK?.showSearchScreen(options);
} catch (error) {
console.error('Error opening search screen:', error);
}
};Example:
import BlazeSDK, { BlazeWidgetLabel } from '@wscsports/blaze-rtn-sdk';
await BlazeSDK?.showSearchScreen({
suggestionsDataSource: {
labels: BlazeWidgetLabel.singleLabel('moments'),
},
});Playback configuration defaults
Use default playback configuration methods to set playback behavior for each player type.
bufferingSpinnerDelayMs is the delay in milliseconds before the buffering spinner becomes visible. When omitted, the native default of 1000 ms applies. Negative values are clamped to 0.
multiAspectRatio on BlazeVideosPlaybackConfiguration is optional. When omitted, the native default of true applies: the player uses the biggest available aspect ratio for each orientation to maximize screen utilization. Set it to false to use the first available rendition regardless of orientation changes.
From React Native SDK 2.0.1, a Moments or Stories playback configuration that you pass per widget, per playStory / playStories call, or to setDefaultMomentsPlaybackConfiguration / setDefaultStoriesPlaybackConfiguration starts from the current default configuration, as Videos already did. A field it omits keeps the default value, for example, loopBehavior, ads.enablePreroll, or bufferingSpinnerDelayMs, instead of the SDK preset. A second partial setDefault… call therefore updates the default rather than replacing it. A configuration that you pass per call or per widget doesn't change the default. On Android, a per-call or per-widget pipConfiguration.enterPipOnAppBackground used to rewrite the default Videos configuration.
ads.enablePreroll on BlazeStoriesPlaybackConfiguration plays the ad configured on the first unread page as a pre-roll on the first page the viewer interacts with. It defaults to false, in which case that ad is skipped.
try {
await BlazeSDK?.setDefaultStoriesPlaybackConfiguration({
bufferingSpinnerDelayMs: 750,
ads: {
enablePreroll: true,
},
});
await BlazeSDK?.setDefaultMomentsPlaybackConfiguration({
bufferingSpinnerDelayMs: 750,
});
await BlazeSDK?.setDefaultVideosPlaybackConfiguration({
bufferingSpinnerDelayMs: 750,
multiAspectRatio: true,
});
} catch (error) {
console.error('Error setting playback configuration:', error);
}Use the matching getter to read the current default configuration:
const storiesPlaybackConfiguration = await BlazeSDK?.getDefaultStoriesPlaybackConfiguration();
const momentsPlaybackConfiguration = await BlazeSDK?.getDefaultMomentsPlaybackConfiguration();
const videosPlaybackConfiguration = await BlazeSDK?.getDefaultVideosPlaybackConfiguration();Stories
playStory
Plays a story with the specified story ID and page ID.
Parameters:
storyId: The ID of the story to be played.pageId: The ID of the page in the story to start from.playbackConfiguration: OptionalBlazeStoriesPlaybackConfigurationfor this player call.
const playStory = async (
storyId: string,
pageId?: string,
): Promise<void> => {
try {
await BlazeSDK?.playStory({
storyId,
pageId,
playbackConfiguration: {
bufferingSpinnerDelayMs: 750,
},
});
} catch (error) {
console.error('Error playing story:', error);
}
};playStories
Plays stories for a specific dataSource type.
This method plays the stories for the provided dataSourceType, which is built using BlazeDataSourceType.
Parameters:
dataSourceType:BlazeDataSourceTypeto filter the stories.playbackConfiguration: OptionalBlazeStoriesPlaybackConfigurationfor this player call.
const playStories = async (
dataSource: BlazeDataSourceType,
): Promise<void> => {
try {
await BlazeSDK?.playStories({
dataSource,
playbackConfiguration: {
bufferingSpinnerDelayMs: 750,
},
});
} catch (error) {
console.error('Error playing stories:', error);
}
};
prepareStories
Prepares stories for a specific dataSource type.
This method prepares the stories for the provided dataSourceType, which is built using BlazeDataSourceType.
Parameters:
- dataSourceType:
BlazeDataSourceTypeto filter the moments.
const prepareStories = async (
dataSource: BlazeDataSourceType,
): Promise<void> => {
try {
await BlazeSDK?.prepareStories(dataSource);
} catch (error) {
console.error('Error preparing stories:', error);
}
};
Moments
playMoment
Plays a moment with the specified moment ID.
Parameters:
- momentId: The ID of the moment to be played.
const playMoment = async (momentId: string): Promise<void> => {
try {
await BlazeSDK?.playMoment({momentId});
} catch (error) {
// ('Error playing moment:', error)
}
};
playMoments
Plays moments for a specific dataSource type.
This method plays the moments for the provided dataSourceType, which is built using BlazeDataSourceType.
Parameters:
- dataSourceType:
BlazeDataSourceTypeto filter the moments.
const playMoments = async (
dataSource: BlazeDataSourceType,
): Promise<void> => {
try {
await BlazeSDK?.playMoments(dataSource);
} catch (error) {
console.error('Error playing moments:', error);
}
};
prepareMoments
Prepares moments for a specific dataSource type.
This method prepares the moments for the provided dataSourceType, which is built using BlazeDataSourceType.
Parameters:
- dataSourceType:
BlazeDataSourceTypeto filter the moments.
const prepareMoments = async (
dataSource: BlazeDataSourceType,
): Promise<void> => {
try {
await BlazeSDK?.prepareMoments(dataSource);
} catch (error) {
console.error('Error preparing moments:', error);
}
};
Videos
playVideo
Plays a video with the specified video ID.
Parameters:
videoId: The ID of the video to be played.playbackConfiguration: OptionalBlazeVideosPlaybackConfigurationfor this player call.
const playVideo = async (videoId: string): Promise<void> => {
try {
await BlazeSDK?.playVideo({
videoId,
playbackConfiguration: {
bufferingSpinnerDelayMs: 750,
},
});
} catch (error) {
console.error('Error playing video:', error);
}
};playVideos
Plays videos for a specific data source.
Parameters:
dataSourceType:BlazeDataSourceTypeto filter the videos.playbackConfiguration: OptionalBlazeVideosPlaybackConfigurationfor this player call.videosFilterParams: OptionalBlazeVideosFilterParamsto filter by content type and live-stream state.
const playVideos = async (
dataSource: BlazeDataSourceType,
): Promise<void> => {
try {
await BlazeSDK?.playVideos({
dataSource,
playbackConfiguration: {
bufferingSpinnerDelayMs: 750,
},
videosFilterParams: {
contentTypes: ['video', 'stream'],
streamStates: ['live', 'upcoming'],
},
});
} catch (error) {
console.error('Error playing videos:', error);
}
};videosFilterParams
Optional BlazeVideosFilterParams on the Videos entry points (playVideos, prepareVideos) and on the Videos row and grid widgets. It filters a Videos data source by content type and by live-stream state, so a single data source can serve regular videos, live streams, or a mix of both.
| Value | Description |
|---|---|
| contentTypes | Array of 'video' | 'stream' Content types to include. When omitted, the native default applies: regular videos only. |
| streamStates | Array of 'live' | 'upcoming' | 'ended' Live-stream states to include. When omitted, no stream-state filtering is applied. |
Players
dismissPlayer
Dismisses the current playing player if exists. Returns a promise.
await BlazeSDK.dismissPlayer();On iOS, the promise resolves after the player is closed. On Android, it resolves right away, before the player closes. To close the player before your app opens its own screen from a CTA, see appOverridesCTAHandling.
Enums
BlazeDataSourceType
Represents the source of data for a specific content request.
| Value | Description |
|---|---|
| labels | Single String A case that uses BlazeWidgetLabel to represent the data source. |
| ids | Array of strings A case that uses an array of strings to represent unique identifiers for the data source. |
| search | Free text search Use type: "search". Supports searchText (required), optional maxItems, and an optional labels filter. Search does not support label priority or ordering. |
BlazeOrderType
The following orderType values are supported on BlazeDataSourceType:
| Value | Description |
|---|---|
| startTimeDesc | Items with the most recent content or stream start time appear first. Meaningful for Videos only; other content types keep the default ordering. |
| startTimeAsc | Items with the most recent content or stream start time appear last. Meaningful for Videos only; other content types keep the default ordering. |
BlazePlayerType
The player type, as reported in playerType by the delegate callbacks and passed to isInColdStart. Exported from the package in React Native SDK 1.21.0 and later.
| Value | Description |
|---|---|
'Moments' | Moments player |
'Stories' | Stories player |
'Videos' | Videos player |
Types
BlazeError
SDK promises reject with a BlazeException, a named export of the package. Read the error from its blazeError property. Every property is optional, so domain and reason can be undefined.
| Property | Type | Description |
|---|---|---|
domain | string | The error domain. Optional. |
reason | string | The error reason. Optional. |
message | string | The error message. Optional. |
metadata | Record<string, string> | Extra details about the error. Optional. |
underlyingError | string | The underlying error, if any. Optional. |
From React Native SDK 2.0.1, on Android domain and reason are the values the native SDK declares, for example, initialization, userManagement, applicationNotInitialised, and failedFetchingContent. This applies to every rejection and to the error in onErrorThrown and onDataLoadComplete. Before 2.0.1, Android sent constant names such as INITIALIZATION and APPLICATION_NOT_INITIALIZED.
On iOS, the setExternalUserId() and logout() rejections carry the same strings: userManagement with invalidExternalUserId, failedToSetExternalUserId, or failedToLogout, and initialization with applicationNotInitialised. Other iOS rejections send no reason.
import BlazeSDK, { BlazeException } from '@wscsports/blaze-rtn-sdk';
try {
await BlazeSDK?.logout();
} catch (error) {
if (error instanceof BlazeException) {
console.error(error.blazeError.domain, error.blazeError.reason);
}
}BlazeResult
The React Native SDK has no BlazeResult type. Methods such as setExternalUserId and logout return Promise<void>: the promise resolves with undefined on success and rejects with a BlazeException on failure. See BlazeError.
import BlazeSDK, { BlazeException } from '@wscsports/blaze-rtn-sdk';
try {
await BlazeSDK?.setExternalUserId('<EXTERNAL_USER_ID>');
} catch (e) {
if (e instanceof BlazeException) {
console.error(e.blazeError.reason);
}
}Updated 10 days ago
