Skip to main content

Events

Subscribe to events with the dedicated onXxx methods on storyManager. Each listener is strongly typed and receives an event object whose payload is in event.body:

storyManager.onShowStory((event) => {
console.log('showStory', event.body.id, event.body.action, event.body.extraFields);
});

Story reader events​

All story reader events receive typed StoryEvent payloads based on StoryData (id, feed, slidesCount, and extraFields: Record<string, string> | null):

MethodNative eventevent.body
onShowStoryshowStory{id: number, feed: string, action: string, slidesCount: number, extraFields}
onCloseStorycloseStory{id: number, feed: string, index: number, action: string, extraFields}
onShowSlideshowSlide{id: number, index: number, extraFields}
onClickOnButtonclickOnButton{id: number, feed: string, index: number, url: string, extraFields}
onLikeStorylikeStory{id: number, feed: string, index: number, value: boolean, extraFields}
onDislikeStorydislikeStory{id: number, feed: string, index: number, value: boolean, extraFields}
onFavoriteStoryfavoriteStory{id: number, feed: string, index: number, value: boolean, extraFields}
onShareStoryclickOnShareStory{id: number, feed: string, index: number, payload: string, extraFields}
onStoryWidgetEventstoryWidgetEvent{id: number, feed: string, name: string, data: Record<string, string>, extraFields}

Reader lifecycle events​

MethodNative eventevent.body
onStoryReaderWillShowstoryReaderWillShow{type: String}
onStoryReaderDidClosestoryReaderDidClose{type: String}

Failure events​

onFailure fires for every failure event below with the same listener:

storyManager.onFailure((event: any) => {
console.log('failure', event.body);
});
Native eventevent.body
sessionFailure{message: String}
storyFailure{message: String}
currentStoryFailure{message: String}
networkFailure{message: String}
requestFailure{message: String, statusCode: String}

Game events​

onGameEvent fires for every game event with the same listener — see Games.

In-App Messaging events​

onIamEvent fires for every IAM event with the same listener — see In-App Messaging.

Goods and product cart events​

MethodNative eventevent.bodyDescription
onGoodItemSelectedgoodItemSelected{sku: String}User tapped a product in the goods widget
onProductCartClickedproductCartClicked{}User tapped the product cart widget
MethodNative eventevent.bodyDescription
onBannerWidgetEventbannerWidgetEvent{bannerData: BannerData, name?: string, data?: Record<string, string>}Interactive widget event in banner

Receives a typed BannerWidgetEvent. bannerData (BannerData) includes id, bannerPlace, payload, and extraFields: Record<string, string> | null. See Banners.

Logging events​

Enable SDK internal logging and subscribe to log messages:

storyManager.setLoggingEnabled(true);

storyManager.onLog((entry: { level: 'debug' | 'error'; message?: string }) => {
console.log(`[IAS ${entry.level}] ${entry.message ?? ''}`);
});

Call to action​

Button and deeplink clicks from readers, games, and banners are routed to storyLinkClickHandler. See Call To Action.

Unsubscribing (destroy)​

All onXxx subscriptions are bound to the StoryManager instance. When replacing a manager (e.g. upon user logout/login), call destroy() to drop all active native subscriptions and prevent duplicate event callbacks:

// Clean up previous instance
oldStoryManager.destroy();

// Create new instance
const newStoryManager = await StoryManager.create(newConfig);