Methods and parameters - React Native
Global Static Methods
initialize
Initialization method of the BlazeSDK.
Parameters:
apiKey: The API key.externalUserId: The viewer ID for a logged-in viewer. Your app supplies this value. See Viewer ID specifications.cachingSize: The amount of possible cached content size restricted in MBs.cachingLevel: The level of content prefetching, which is determined by theCachingLevelenum type.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. further information could be found at Geo RestrictionsglobalDelegate: 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 externalUserId parameter is used to uniquely identify a user session when initializing our SDK. This identifier serves as a key for customizing and tracking user-related activities during the SDK session.
Overriding Behavior
If you re-initialize the SDK with a new externalUserId, the SDK will override the previous user identifier. The new externalUserId will be used for all subsequent activities and tracking. The previous viewer's unsynced activity is sent to WSC Sports, and their activity is cleared from the device. The previous identifier stays valid: set it again and that viewer's activity is restored.
Clearing Previous User Identifier
If you initialize the SDK with externalUserId set to nil, it will clear the previous user identifier, effectively anonymizing the session. Activities in this state will not be associated with any user identifier until a new externalUserId is set.
Recommended Practice
Due to our overriding and clearing behavior, it is crucial to use careful logic in your application to manage when and how to initialize new sessions. Make sure that you are intentionally setting or clearing externalUserId based on the desired outcome for user tracking and activity managemen
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. See Viewer ID specifications.
try {
await BlazeSDK?.setExternalUserId(userId: String);
// 'setExternalUserId success' action
} catch (error) {
// 'Error set External UserId:' error action
}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
}Disable Analytics
setDisableAnalytics
Apps can stop the SDK from collecting and sending analytics data to WSC.
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
}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);
}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 Blaze SDK. The function checks if the provided link contains the domain specified as a universal link within the Blaze SDK's 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
canHandlePushNotification
This method takes a notification's payload, processes it and indicates if it can be handled by the SDK.
Parameters:
- payload: An object representing the payload to be handled. The keys and values are specific to the notification's data structure.
- Returns:
trueif the SDK can handle the notification's payload, otherwise returnsfalse.
Note: This method can be used to determine whether the SDK can handle a given payload, returning the result asynchronously, before calling handleNotificationPayload.
BlazeSDK.canHandlePushNotification(payload: object).then(canHandle => {
if (canHandle) {
// Can handle
} else {
// Can't handle
}
}).catch(error => {
// Handle error
});handleNotificationPayload
Handles a notification's payload.
This method takes an object representing the payload of a notification, processes it, and optionally returns a result via a completion handler.
Parameters:
- payload: An object representing the payload to be handled. The keys and values are specific to the notification's data structure.
BlazeSDK.handleNotificationPayload(payload: object).then(result => {
// 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 as of React Native SDK 1.20.0. When omitted, the native default applies, and that default is now true: 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.
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, available from React Native SDK 1.20.0 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.
BlazeSDK?.dismissPlayer();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
React Native SDK 1.20.0 adds the following orderType values to 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. |
Types
BlazeError
Type alias for a closure that processes an error resulting from an operation.
Parameter:
- BlazeError: The error that was encountered during the operation.
interface IBlazeErrorBlazeResult
Type alias for a closure that processes the result of an asynchronous operation.
Parameter:
- Result<Void, BlazeError>: The result of the operation.
- If the operation was successful, the result will be
.success(). - If the operation encountered an error, the result will be
.failure(BlazeError),
whereBlazeErroris the error that has been thrown.
- If the operation was successful, the result will be
interface IBlazeResult-
- If the operation encountered an error, the result will be
.failure(BlazeError),
whereBlazeErroris the error that has been thrown.
- If the operation encountered an error, the result will be
interface IBlazeResultUpdated 16 days ago
