Revision History
Date | Version |
2024/08/06 | 1.0.1 |
2024/10/23 | 1.0.2 |
Plugin Download
Go to theResource Download
page and download the corresponding plugin project based on your engine version.
Install SDK Plugin
Here, we take Cocos Creator 3.8 as an example:
Import the plugin package by clicking on Extension -> Extension Manager
Select the project, then click the
+
sign to import the extension package.
After the import is successful, open the extension.
Once the extension is open, a new menu item for
MiniGame SDK
will be added to the menu bar. Click onMiniGame SDK -> Control Panel
to open the control panel.
The control panel is shown in the following figure:
After clicking the Copy
button, the SDK directory will be copied to the assets directory. Additionally, the minigame-types
file in the declarations folder will be copied to the root directory, as shown in the figure:
At this point, you can integrate interfaces such as advertising.
Before packaging, check the box for
Build MiniGame Package
and select theweb-mobile
platform for packaging. This will automatically build the MiniGame package. If you do not want to build the MiniGame package, simply remove the checkmark (✅) next toBuild MiniGame Package
.
Integration
When the game finishes loading and enters the main scene, call setGameReadyAsync
when the main scene is initialized.
Before using it, initialize the SDK at the game initialization point (the game entry point) and implement a method to control the sound, which allows the SDK to uniformly manage the game audio during the playback of rewarded and interstitial ads:
After the initialization is completed, you can call the corresponding interfaces.
Below is an introduction to the SDK interfaces:
Advertisement
Rewarded Video Ads
showRewardedVideo(callback: BoolCallback)
callback A callback function that is called after the ad playback is completed, with the parameter indicating whether the playback was successful.
Interstitial Ads
showInterstitial(callback?: BoolCallback)
callback A callback function that is called after the ad playback is complete, with the parameter indicating whether the playback was successful.
Interstitial ads do not require the distribution of rewards, so you can choose not to handle the callback function.
Banner Ads
showBanner() : Display banner ads
hideBanner() : Hide banner ads
Language
getLocale()
Data Storage (Required)
Data Saving
setDataAsync (data: Object): Promise<void>
Get Data
getDataAsync (keys: string[]): Promise<Object>
===========================================
The following interfaces are not required to be integrated under normal conditions, and should only be integrated if our operations team instructs us to do so.
Event Tracking
onGameEvent(eventName: string, label: string)
eventName
Event Namelabel
Event label
Payment
Detecting the payment environment
onPaymentReady(readyCallback: Function, consumeCallback: ConsumeCallback)
consumeCallback
A callback function for order consumption. After a successful payment, the game needs to call this callback to inform that the payment is successful, and the game can then issue rewards.
Note that this interface needs to be called within the callback function of MiniGameSDK.init, as shown in the following code:
Payment
onPurchase(purchaseConfig: PurchaseConfig, consumeCallback: ConsumeCallback)
purchaseConfig
Configuration for payment parameters.consumeCallback
A callback function for order consumption. After a successful payment, the game needs to call this callback to inform that the payment is successful, and the game can then issue rewards.
Sharing
onShare(shareConfig: SharePayload, callback: BoolCallback)
shareConfig
Configuration for sharing parameters.callback
A callback function for sharing, with the parameter indicating whether the sharing was successful.
Shortcut
createShortcut(shortcutCallback: BoolCallback)
shortcutCallback
A callback function for sharing, with the parameter indicating whether the sharing was successful.
Simulating Online Environment
Steps:
Set isTest to
false
in minigame.json.Place the local game link after integrating the SDK into the address bar of the page.
After clicking "Start Testing," you can simulate the online environment for testing.
Note:If it's a Cocos Creator game, after integrating the SDK, you can directly use the address that runs in the Cocos Creator editor for testing, such as http://localhost:7457