Skip to main content

StoryManager

StoryManager is the entry point of the SDK. It holds the configuration, opens readers (stories, games, in-app messages), manages favorites, and delivers events. Create a single instance and share it across your app (see the full setup in Stories List).

Creating a manager

import { StoryManager, type StoryManagerConfig } from '@inappstory/react-native-sdk';

const config: StoryManagerConfig = {
apiKey: '<your-api-key>',
userId: '<user-id>',
};

const storyManager = new StoryManager(config);

For most apps, prefer the asynchronous factory, which waits until the native SDK has been initialized with the supplied config:

import { StoryManager, type StoryManagerConfig } from '@inappstory/react-native-sdk';

async function bootstrap() {
const config: StoryManagerConfig = {
apiKey: '<your-api-key>',
userId: '<user-id>',
};

const storyManager = await StoryManager.create(config);
return storyManager;
}

StoryManagerConfig

OptionTypeDescription
apiKeystring (required)Project API key
userIdstring | numberCurrent user identifier (≤ 255 bytes; no personal data). See User settings
userIdSignstringHMAC signature for userId. See User settings
tagsstring[]Targeting tags. See Tags
placeholdersRecord<string, string>Text placeholders. See Placeholders
langstringContent language (e.g. 'en-US')
defaultMutedbooleanOpen readers muted by default. See Sound
sendStatisticsbooleanSend statistics to the platform
cacheSize'small' | 'medium' | 'large'Native story cache size. Android-only (iOS manages its own cache)
anonymousbooleanAnonymous mode — no userId is sent to the backend
appVersion{ version: string; build: number }Override app version/build for targeting. See How to get started
optionsRecord<string, string>Additional key-value options (e.g. pos). See Options

Every native initialization applies the current config. Runtime setters call reinit internally, so a later setApiKey, setUserId, or tag change triggers a new native session.

Updating configuration at runtime

MethodDescription
setApiKey(apiKey)Change the API key (reinitializes the session)
setUserId(userId, userIdSign)Change the user. See User settings
setTags(tags) / addTags(tags) / removeTags(tags)Update targeting tags. See Tags
setLang(lang)Change the content language
setPlaceholders(map) / setImagePlaceholders(map)Update placeholders. See Placeholders
setSendStatistics(value)Toggle statistics at runtime
setAppVersion(version, build)Override app version/build
changeSound(value)Toggle sound. See Sound
setOptions(options)Pass additional native options (advanced). See Options
logout()Clear the current user session. See User settings
destroy()Remove all native event subscriptions from this manager

Showing content

MethodReturnsDescription
showStory(storyId, signal?, appearanceManager?)Promise<{loaded}>Open a single story
showStoryOnce(storyId, signal?)Promise<boolean>Open a story only if it hasn't been shown before
showGame(id)Promise<boolean>Open a game. See Games
showOnboardings(feed?, limit?, tags?, signal?)Promise<boolean>Show unseen onboarding stories
showIAMById(id, onlyPreloaded, signal?)Promise<boolean>Show an in-app message. See In-App Messaging
showIAMByEvent(event, onlyPreloaded, signal?)Promise<boolean>Show an in-app message by event name
preloadIAM(ids?, tags?)Promise<boolean>Preload in-app messages
preloadGames()voidPreload games
preloadBannerPlace(placeId, tags?)Promise<boolean>Preload a banner place. See Banners
clearCache()voidClear the native content cache

The signal argument accepts an AbortSignal to cancel long-running loads — see Cancellation of actions.

Favorites

MethodReturnsDescription
removeFromFavorite(storyId)voidRemove one story from favorites
removeAllFavorites()voidClear all favorites
favoritesCount()Promise<number>Current number of favorites

See Favorites for the favorites feed and cell handling.

Goods

Provide goods for the native goods widget with getGoods:

storyManager.getGoods((skus) => {
return skus.map((sku) => ({
sku,
title: `Title ${sku}`,
subtitle: `Subtitle ${sku}`,
imageURL: '',
price: '10.00',
oldPrice: '12.00',
}));
});

For the interactive cart, use setProductCartHandlers and onProductCartClicked — see Product cart.

Logging

Enable native SDK logging and receive log entries with onLog:

storyManager.setLoggingEnabled(true);

storyManager.onLog((entry) => {
console.log(`[${entry.level}] ${entry.message ?? ''}`);
});

Events and Call To Action

Subscribe with the dedicated onXxx methods — see Events. Button / deeplink clicks are handled via storyLinkClickHandler — see Call To Action.