Skip to main content

Games

The library supports running games.

Usage​

To run game​

void openGame() async {
await InAppStoryManager.instance.openGame('<game id>');
}

To close game​

void closeGame() async {
await InAppStoryManager.instance.closeGame();
}

Preload games​

If you want to preload games by yourself (for example, in case your app doesn't show any stories immediately), you can call:

void preloadGames() async {
await InAppStoryManager.instance.preloadGames();
}

Callbacks​

To listen to callbacks from games, implement the IASGameReaderCallback mixin in your State and override the callbacks listed below:

Please note

finishGame callback is Deprecated, use closeGame instead.

class _MyAppState extends State<MyApp> with IASGameReaderCallback {

void startGame(ContentData? gameData) {
print('startGame: ${gameData?.contentType}');
}


void closeGame(ContentData? gameData) {
print('closeGame');
}


void eventGame(ContentData? contentData, String? gameId, String? eventName,
Map<String, Object?>? payload) {
print('event game: $eventName');
}


void gameError(ContentData? gameData, String? message) {
print('gameError: $message');
}
}

Models and Enums​

class ContentData {
final ContentType? contentType;
final SourceType? sourceType;
}

enum ContentType {
story,
ugc,
inAppMessage,
}