Events
Subscribe to events with the dedicated onXxx methods on storyManager. Each listener
receives an event object whose payload is in event.body:
storyManager.onShowStory((event: any) => {
console.log('showStory', event.body);
});
Story reader events
| Method | Native event | event.body |
|---|---|---|
onShowStory | showStory | {id: String, feed: String, action: String} |
onCloseStory | closeStory | {id: String, feed: String, index: Number, action: String} |
onShowSlide | showSlide | {id: String, index: Number} |
onClickOnButton | clickOnButton | {id: String, feed: String, index: Number, url: String} |
onLikeStory | likeStory | {id: String, feed: String, value: Boolean} |
onDislikeStory | dislikeStory | {id: String, feed: String, value: Boolean} |
onFavoriteStory | favoriteStory | {id: String, feed: String, value: Boolean} |
onShareStory | clickOnShareStory | {} |
onStoryWidgetEvent | storyWidgetEvent | {id: String, feed: String, name: String, data: String} |
Reader lifecycle events
| Method | Native event | event.body |
|---|---|---|
onStoryReaderWillShow | storyReaderWillShow | {type: String} |
onStoryReaderDidClose | storyReaderDidClose | {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 event | event.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
| Method | Native event | event.body | Description |
|---|---|---|---|
onGoodItemSelected | goodItemSelected | {sku: String} | User tapped a product in the goods widget |
onProductCartClicked | productCartClicked | {} | User tapped the product cart widget |
Banner events
| Method | Native event | event.body | Description |
|---|---|---|---|
onBannerWidgetEvent | bannerWidgetEvent | {bannerData: Object, name: String, data: Object} | Interactive widget event in banner |
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);