This section explains the steps to integrate the now.gg Embed SDK.
To integrate the now.gg 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>
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:
iframeParentElement
, the appEventCallbackFunction
, and the sdkEventCallbackFunction
.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, });
Using this section, you can locate your appId
within nowStudio.
appId
is a unique identifier for your app on nowStudio.appId
for your app on testing and production environments.
appId
will be visible only after the app is deployed.appId
is also available under the App Details section after you add your app.appId
is listed on the live test release, as shown below:appId
is listed on the live production release, as shown below: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. – Refer – Define appLaunchData section. |
appEventCallback | function | No | App Event callback function for App-related events handling. Refer – Start Game in Iframe section. |
sdkEventCallback | function | No | SDK Event callback function for SDK-related events handling. Refer – Start 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.
Document Rev. 1.0