Games
The library supports running games.
Usage
To run game
void openGame() async {
await IASGamesHostApi().openGame('<game id>');
}
To close game
void closeGame() async {
await IASGamesHostApi().closeGame();
}
Preload games
If you want to preload games by yourself (f.e. in case if your app doesn't use any stories), you can call next method:
void preloadGames() async {
await IASGamesHostApi().preloadGames();
}
Callbacks
To listen to callbacks from games you need to implement IASGameReaderCallback mixin and override callbacks listed
below:
Please note
finishGame callback is Deprecated, use closeGame instead.
class _MyAppState extends State<MyApp> with IASGameReaderCallback {
void startGame(ContentDataDto? gameData) {
print('startGame ${gameData?.contentType.toString()}');
}
void closeGame(ContentDataDto? gameData) {
print('closeGame');
}
void eventGame(ContentDataDto? contentData, String? gameId, String? eventName,
Map<String?, Object?>? payload) {
print('event game');
}
void gameError(ContentDataDto? gameData, String? message) {
print('gameError');
}
}