Skip to content

gyfak/instant-games-bridge

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Instant Games Bridge

One SDK for cross-platform publishing HTML5 games.

Supported platforms:

Plugins for game engines:

Join community: https://t.me/instant_games_bridge.

Usage

Setup

First you need to initialize the SDK:

<script src="https://cdn.jsdelivr.net/gh/mewtongames/[email protected]/dist/instant-games-bridge.js"></script>
<script>
    instantGamesBridge
        .initialize()
        .then(() => {
            // Initialized. You can use other methods.
        })
        .catch(error => {
            // Error
        })
</script>

Platform

// Get ID of current platform ('vk', 'yandex', 'mock')
instantGamesBridge.platform.id

Advertisement

Methods

let seconds = 30 // Default = 60
instantGamesBridge.advertisement.setMinimumDelayBetweenInterstitial(seconds)

// Optional parameter
let interstitialOptions = {
    ignoreDelay: true // Default = false
}

// Request to show interstitial ads
instantGamesBridge
    .advertisement
    .showInterstitial(interstitialOptions)
    .then(() => {
        // Success
    })
    .catch(error => {
        // Error
    })

// Request to show rewarded video ads
instantGamesBridge
    .advertisement
    .showRewarded()
    .then(() => {
        // Success
    })
    .catch(error => {
        // Error
    })

Events

instantGamesBridge.advertisement.on('interstitial_state_changed', state => console.log('Interstitial state:', state))
instantGamesBridge.advertisement.on('rewarded_state_changed', state => console.log('Rewarded state:', state))

Game Data

// Get game data from storage
instantGamesBridge
    .game
    .getData(key)
    .then(data => {
        // Data has been received and you can work with them
        // data = null if there is no data for this key
        console.log('Data:', data)
    })
    .catch(error => {
        // Error
    })

// Set game data in storage
instantGamesBridge
    .game
    .setData(key, value)
    .then(() => {
        // Success
    })
    .catch(error => {
        // Error
    })

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%