Skip to main content

External API

You can use the exported StoryManager instance to consume the external API

import { storyManager } from "@inappstory/react-sdk"

Properties​

PropertyTypeDescription
sdkVersionNamestringSDK version name (e.g., 3.7.0).
sdkVersionCodenumberNumeric SDK version code (e.g., 30700).
inAppMessagingInAppMessagingModule for displaying in-app messages.
storyLinkClickHandlerStoryLinkClickHandlerHandler for story link clicks. More details.

showOnboardingStories(options?)​

Displays onboarding stories.

storyManager.showOnboardingStories({ feed: "main" })
.then(result => console.log(result.stories))
.catch(console.error);
  • Parameters: options?: { feed?: string; customTags?: string[]; limit?: number }
  • Returns: Promise<{ stories: { id: number; title: string }[] }>

showSharePage(storyId)​

Displays the share page for a specific story.

storyManager.showSharePage(123).catch(console.error).catch(console.error);;
  • Parameters: storyId: number | string
  • Returns: Promise<void>

showStory(id, options?)​

Displays a specific story.

storyManager.showStory("456").catch(console.error);;
  • Parameters:
    • id: number | string
    • options?: { signal?: AbortSignal; targeting?: boolean }
  • Returns: Promise<void>

showStoryOnce(id, options?)​

Displays a story only once.

storyManager.showStoryOnce(789).catch(console.error);;
  • Parameters:
    • id: number | string
    • options?: { signal?: AbortSignal; targeting?: boolean }
  • Returns: Promise<void>

openGame(gameInstanceId)​

Opens a game by its instance ID.

storyManager.openGame("game-123").catch(console.error);;
  • Parameters: gameInstanceId: string | number
  • Returns: Promise<void>

closeGame()​

Closes the currently active game.

storyManager.closeGame().catch(console.error);
  • Returns: Promise<boolean>

closeStoryReader()​

Closes the story view.

storyManager.closeStoryReader().catch(console.error);
  • Returns: Promise<boolean | undefined>

closeGoodsWidget()​

Closes the goods widget.

storyManager.closeGoodsWidget();
  • Returns: void

on(eventName, listener)​

Subscribes to an SDK events.

inAppStoryManager.on("showStory", (event) => {
console.log("Story opened:", event);
});
  • Parameters:

    • eventName: string
    • listener: (...args: any[]) => void
  • Returns: this