1.3.7 • Published 7 months ago
@inappstory/game-center-api v1.3.7
game-center-api
API for integration with GameReader (WebView) inside native apps
Init API
import { createSdkApi } from "@inappstory/game-center-api";
const mounted = () => {
// ready to render UI
const rootElement = document.getElementById("root");
const root = createRoot(rootElement!);
root.render(<App />);
};
createSdkApi({
mounted,
beforeUnmount: () => {
/* Stop AudioContext for instance */
},
onPause: () => {
/* Call on focus lost. Stop game timers for instance */
},
onResume: () => {
/* Call on focus return. Resume game timers for instance */
},
onBackGesture: () => {
/* Call on Android back gesture */
},
gameShouldForeground: () => {
/* splash animation finished, now we can start bg music and etc */
},
});
Game first render
const gameLoaded = () => {
GameCenterApi.gameLoadedSdkCallback();
};
const gameStarted = () => {
setTimeout(() => {
// Wait for render complete - then remove native loader screen
GameCenterApi.gameShouldForegroundCallback();
}, 50);
};
const gameShouldForeground = () => {
// splash animation finished, now we can start bg music and etc
gameStarted();
};
// calling gameLoadedSdkCallback removes the loading screen
import { gameLoadedSdkCallback } from "@inappstory/game-center-api";
const rootElement = document.getElementById("root");
const root = createRoot(rootElement!);
root.render(<AppWithCallbackAfterRender cb={gameLoaded} />);
Get user ID
import GameCenterApi from "@inappstory/game-center-api";
// call only after mounted event (from GameCenterApi.createSdkApi
const getUserId = () => GameCenterApi.gameLaunchConfig.clientConfig.userId;
Get placeholder
import GameCenterApi, { type PlaceholderType, Placeholder } from "@inappstory/game-center-api";
// call only after mounted event (from GameCenterApi.createSdkApi
const getPlaceholder = (name: string, type: PlaceholderType): Placeholder | undefined => {
return GameCenterApi.gameLaunchConfig.clientConfig.placeholders.find(placeholder => placeholder.name === name && placeholder.type === type);
};
const avatarUrl = getPlaceholder("avatar", PlaceholderType.IMAGE);
Open url
import GameCenterApi from "@inappstory/game-center-api";
// closeGameReader - close or not GameReader
const openUrl = (url: string) => GameCenterApi.openUrl({ url, closeGameReader: true });
Close game
import GameCenterApi from "@inappstory/game-center-api";
const closeGame = () => GameCenterApi.closeGameReader();
Get Application version
import GameCenterApi from "@inappstory/game-center-api";
// 1.2.3
const version: string | null = GameCenterApi.getApplicationVersion();
Get Application build version
import GameCenterApi from "@inappstory/game-center-api";
// 300
const version: number | null = GameCenterApi.getApplicationBuildVersion();
1.3.7
7 months ago
1.3.6
8 months ago
1.3.5
8 months ago
1.3.4
8 months ago
1.3.3
10 months ago
1.3.2
10 months ago
1.2.0
1 year ago
1.1.1
1 year ago
1.2.3
12 months ago
1.3.1
10 months ago
1.2.2
1 year ago
1.3.0
11 months ago
1.2.1
1 year ago
1.1.0
1 year ago
1.0.11
1 year ago
1.0.10
1 year ago
1.0.9
1 year ago
1.0.8
1 year ago
1.0.7
1 year ago
1.0.6
1 year ago
1.0.1-rc.3
1 year ago
1.0.0-rc.29
1 year ago
1.0.0-rc.28
1 year ago
1.0.0-rc.27
1 year ago
1.0.0-rc.26
1 year ago
1.0.0-rc.25
1 year ago
1.0.0-rc.23
1 year ago
1.0.0-rc.22
1 year ago
1.0.0-rc.21
1 year ago
1.0.0-rc.20
1 year ago
1.0.0-rc.17
1 year ago
1.0.0-rc.19
1 year ago
1.0.0-rc.18
1 year ago
1.0.0-rc.16
1 year ago
1.0.0-rc.15
1 year ago
1.0.0-rc.14
2 years ago
1.0.0-rc.13
2 years ago
1.0.0-rc.12
2 years ago
1.0.0-rc.11
2 years ago
1.0.0-rc.10
2 years ago
1.0.0-rc.9
2 years ago
1.0.0-rc.8
2 years ago
1.0.0-rc.7
2 years ago
1.0.0-rc.6
2 years ago
1.0.0-rc.5
2 years ago
1.0.0-rc.4
2 years ago
1.0.0-rc.3
2 years ago
1.0.0-rc.2
2 years ago
1.0.0-rc.1
2 years ago