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
| Option | Type | Description |
|---|---|---|
apiKey | string (required) | Project API key |
userId | string | number | Current user identifier (≤ 255 bytes; no personal data). See User settings |
userIdSign | string | HMAC signature for userId. See User settings |
tags | string[] | Targeting tags. See Tags |
placeholders | Record<string, string> | Text placeholders. See Placeholders |
lang | string | Content language (e.g. 'en-US') |
defaultMuted | boolean | Open readers muted by default. See Sound |
sendStatistics | boolean | Send statistics to the platform |
cacheSize | 'small' | 'medium' | 'large' | Native story cache size. Android-only (iOS manages its own cache) |
anonymous | boolean | Anonymous mode — no userId is sent to the backend |
appVersion | { version: string; build: number } | Override app version/build for targeting. See How to get started |
options | Record<string, string> | Additional key-value options (e.g. pos). See Options |
Every native initialization applies the current config. Most runtime setters call reinit
internally (e.g. setApiKey, setUserId, or tag changes), while dynamic setters such as
setSendStatistics update native SDK settings directly without restarting the session.
Updating configuration at runtime
| Method | Description |
|---|---|
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 without reinitializing |
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
| Method | Returns | Description |
|---|---|---|
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 |
closeReaders() | void | Close any active reader (stories, onboarding, IAM) |
preloadIAM(ids?, tags?) | Promise<boolean> | Preload in-app messages |
preloadGames() | void | Preload games |
preloadBannerPlace(placeId, tags?) | Promise<boolean> | Preload a banner place. See Banners |
clearCache() | void | Clear the native content cache |
The signal argument accepts an AbortSignal to cancel long-running loads — see
Cancellation of actions.
Favorites
| Method | Returns | Description |
|---|---|---|
removeFromFavorite(storyId) | void | Remove one story from favorites |
removeAllFavorites() | void | Clear 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.