Integrating Embed SDK

This section explains the steps to integrate the now.gg Embed SDK.

To integrate the now.gg Embed SDK:

  1. Add Embed SDK to your website.
  2. Start the game in an Iframe.
  3. Additionally, you can integrate advanced functionality with embedding using the next section.

Important Information

  • Ensure your game is deployed on either the Testing or Production track and you have the game link for embedding.
  • You can follow the following links to create a release and deploy your app:

1. Add Embed SDK

The first step is to add the Embed SDK to your website.

To add the now.gg Embed SDK to your website, add the SDK resource javascript in a script tag, as illustrated below:

<script type="text/javascript" src="https://cdn.now.gg/external/sdk/ifp-sdk-1.0.0.min.js"></script>

2. Start the Game in an Iframe

After the now.gg Embed SDK resource has been added, you can initialize the SDK to embed gameplay on your website using now.gg Embedding.

To do this:

  • Start by defining the iframeParentElement, the appEventCallbackFunction, and the sdkEventCallbackFunction.
  • Now, call the init function of the NowIfp class along with the required parameters to start the cloud game, as illustrated below:
const iframeParentElement = document.getElementById("your_iframe_element");

// Callback function to handle events sent from the Android app.
const appEventCallbackFunction = (event) => {
    console.log(event.name); 
    console.log(event.data);
    // can do your event-based handling here
}; 

// Callback function to handle javascript SDK events.
const sdkEventCallbackFunction = (event) => {
    console.log(event.name); 
    console.log(event.msg);
    // can do your event-based handling here
}; 


NowIfp.init({
    clientId: <"your_clientId"> ,
    appId: <"your_production_appId/your_test_track_appId"> , \\ appId example - Test Track: "1234_t1" | Production: "1234"
    iframeParentElement: iframeParentElement,
    customData: {} // for app-specific custom handling
    appLaunchData: {
        [key]: [value]
    } // pass launch arguments to Iframe, It will be serialized and passed to the app at launch intent.
    appEventCallback: appEventCallbackFunction,
    sdkEventCallback: sdkEventCallbackFunction,
});

Get your appId

Using this section, you can locate your appId within nowStudio.

Important Information

  • appId is a unique identifier for your app on nowStudio.
  • nowStudio generates different appId for your app on testing and production environments.
    • For Testing tracks, appId will be visible only after the app is deployed.
    • For Production, appId is also available under the App Details section after you add your app.
1. appId for Test Track
  • To locate appId for test track:
  • Navigate to All Apps > Select your app > Test Track
    • appId is listed on the live test release, as shown below:
2. appId for Production
  • To locate appId for production track:
  • Navigate to All Apps > Select your app > Release.
    • appId is listed on the live production release, as shown below:

Parameters

Params Type Required Summary
clientId string Yes Unique client identifier.
appId string Yes App ID associated with your app/game on nowStudio. nowStudio generates different appId for production and testing environments. Example – Production appId: “1234″. Test Track appId: “1234_t1″.
iframeParentElement element Yes The iframeParentElement in which the embedded player will be rendered.
customData object No Any app-specific data that you wish to pass to now.gg backend.
appLaunchData object No Extra data that is sent as app launch intent extras. – ReferDefine appLaunchData section.
appEventCallback function No App Event callback function for App-related events handling. ReferStart Game in Iframe section.
sdkEventCallback function No SDK Event callback function for SDK-related events handling. ReferStart Game in Iframe section.

Your game is now embedded on your web page, powered by the now.gg Cloud.

Additionally, if you would like to implement advanced functionality with embedding, you can continue to the next section.

×
Text copied to clipboard
Link copied to clipbord
Questions? Please reach out to us at dev-support@now.gg