You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

@inappstory/game-center-api

Package Overview
Dependencies
Maintainers
2
Versions
72
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@inappstory/game-center-api

API for integration with GameReader (WebView) inside native apps

1.3.30
latest
Source
npmnpm
Version published
Weekly downloads
14
-86.79%
Maintainers
2
Weekly downloads
 
Created
Source

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

FAQs

Package last updated on 19 Jun 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts