@inappstory/game-center-api
TypeScript icon, indicating that this package has built-in type declarations

1.2.0 • Public • Published

game-center-api

API for integration with GameReader (WebView) inside native apps

Usage example

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 */
    },
});

Game first render

// 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={() => gameLoadedSdkCallback()} />);

Readme

Keywords

none

Package Sidebar

Install

npm i @inappstory/game-center-api

Weekly Downloads

102

Version

1.2.0

License

MIT

Unpacked Size

113 kB

Total Files

62

Last publish

Collaborators

  • artem.strebizh.inappstory
  • dev.inappstory