GuidesAPI ReferenceRelease Notes
HomeLog InHome
Guides

Follow entities - React Native

Viewers follow players, teams, and properties from the follow button in the Moments player. Your app can set and read the user's followed entities through BlazeSDK.followEntitiesManager, receive a callback when the user taps the follow button, and build content from the followed entities with the followedEntities data source.

For how the follow button works across platforms, see Follow button for Moments.

Platform reference: iOS | Android

Persistence and sync

The SDK persists followed entities across app launches and restores them at initialization, so your app doesn't need to call setFollowedEntities on every launch.

Once synced, setFollowedEntities replaces the user's followed entities on every device, and the latest call wins. Use insertFollowedEntities and removeFollowedEntities for incremental changes.

Entities are compared by id only.

BlazeFollowEntity

An entity the user follows. React Native SDK 1.21.0 adds the optional providerName and entityType fields.

PropertyTypeDescription
idstringThe entity id. Identity is id only.
providerNamestring (optional)The name of the data provider that sourced the entity, for example stats-perform. The SDK does not validate it.
entityTypeBlazeFollowedEntityCategory (optional)The category of the entity.

The SDK forwards providerName and entityType with the user's follow activity. Omitting either field never clears a value the SDK already knows for that id.

entityType is not the follow button style's entityType selector on BlazeMomentsPlayerStyle.followEntity.

BlazeFollowedEntityCategory

The category of a followed entity.

type BlazeFollowedEntityCategory = 'Player' | 'Team' | 'Property';

followEntitiesManager

Available from React Native SDK 1.21.0. BlazeSDK.followEntitiesManager sets and reads the followed entities with their metadata.

interface BlazeFollowEntitiesManager {
  setFollowedEntities(entities: BlazeFollowEntity[]): Promise<void>;
  insertFollowedEntities(entities: BlazeFollowEntity[]): Promise<void>;
  removeFollowedEntities(entities: BlazeFollowEntity[]): Promise<void>;
  getFollowedEntities(): Promise<BlazeFollowEntity[]>;
}

setFollowedEntities, insertFollowedEntities, and removeFollowedEntities reject, leaving the followed entities unchanged, if any entry is not an object with a string id. When one call passes the same id more than once, the first entry is kept.

setFollowedEntities

Sets the followed entities, replacing any existing ones. An entity passed without metadata keeps the metadata the SDK already knows for its id.

❗️

setFollowedEntities replaces the followed entities locally and, once synced, for the user on every device (latest wins). Use it only when the list you pass is the complete list. For incremental changes, use insertFollowedEntities and removeFollowedEntities.

insertFollowedEntities

Adds entities to the followed set without replacing it. For an entity that is already followed, the metadata passed here wins.

removeFollowedEntities

Removes entities from the followed set. Entities are matched by id only, whatever metadata they carry.

getFollowedEntities

Resolves with the current followed entities and their metadata.

The SDK can fill in a missing entityType from the content that a followedEntities data source loads, so getFollowedEntities can return an entityType your app did not set. An entityType your app set is never overwritten.

import BlazeSDK, { BlazeFollowEntity } from '@wscsports/blaze-rtn-sdk';

const entities: BlazeFollowEntity[] = [
  { id: 'player_123', providerName: 'stats-perform', entityType: 'Player' },
  { id: 'team_456', entityType: 'Team' },
];

try {
  await BlazeSDK?.followEntitiesManager.insertFollowedEntities(entities);
  await BlazeSDK?.followEntitiesManager.removeFollowedEntities([{ id: 'team_456' }]);
  const followedEntities = await BlazeSDK?.followEntitiesManager.getFollowedEntities();
  console.log('Followed entities:', followedEntities);
} catch (error) {
  console.error('Error updating followed entities:', error);
}

onFollowEntityClicked

onFollowEntityClicked is called when the user taps the follow button in the Moments player. It belongs to BlazeFollowEntitiesDelegate, a single app-wide delegate that you register with BlazeSDK.setFollowEntitiesDelegate. Pass null to remove it.

setFollowEntitiesDelegate(delegate?: BlazeFollowEntitiesDelegate | null): void;

interface BlazeFollowEntitiesDelegate {
  onFollowEntityClicked?: (params: BlazeFollowEntityClickedParams) => void;
}

interface BlazeFollowEntityClickedParams {
  sourceId: string;
  playerType: BlazePlayerType;
  newFollowingState: boolean;
  followEntity: BlazeFollowEntity;
}

From React Native SDK 1.21.0, followEntity carries providerName and entityType along with id:

  • providerName is present only when the backend supplies one.
  • entityType is always present on Android. On iOS, it is omitted when the SDK does not recognize the entity's content type.
BlazeSDK?.setFollowEntitiesDelegate({
  onFollowEntityClicked: (params) => {
    const { followEntity, newFollowingState } = params;
    console.log(
      'Follow entity clicked:',
      followEntity.id,
      followEntity.providerName,
      followEntity.entityType,
      newFollowingState,
    );
  },
});

Deprecated ID-based methods

React Native SDK 1.21.0 deprecates the ID-based follow methods on BlazeSDK in favor of BlazeSDK.followEntitiesManager. Their signatures and behavior are unchanged: each id is passed as an entity without metadata, and getFollowedEntities resolves with the ids only. Persistence and sync apply to them as well, so BlazeSDK.setFollowedEntities also replaces the user's followed entities on every device once synced.

Deprecated methodReplacement
BlazeSDK.setFollowedEntities(entityIds: string[]): Promise<void>BlazeSDK.followEntitiesManager.setFollowedEntities
BlazeSDK.insertFollowedEntities(entityIds: string[]): Promise<void>BlazeSDK.followEntitiesManager.insertFollowedEntities
BlazeSDK.removeFollowedEntities(entityIds: string[]): Promise<void>BlazeSDK.followEntitiesManager.removeFollowedEntities
BlazeSDK.getFollowedEntities(): Promise<string[]>BlazeSDK.followEntitiesManager.getFollowedEntities

setFollowEntitiesDelegate is not deprecated.

Follow button style

Style the follow button in the Moments player through followEntity on BlazeMomentsPlayerStyle. From React Native SDK 1.21.0, followEntity.isVisible defaults to true, so the follow chip shows on content that carries a follow entity. Set isVisible: false to hide it.

Content from followed entities

The followedEntities data source builds widgets, player entry points, Moments tabs, search suggestions, and composite entries from the entities the user follows, optionally narrowed by BlazeFollowedEntityCategory. See DataSource - React Native.

const dataSource: BlazeDataSourceType = {
  type: 'followedEntities',
  entityTypes: ['Team'],
};

Did this page help you?