1.use configuration
Since the plug-in needs to access its own server and CDN, so you need to add security domain name to the accessing mini-games, which “request” legal domain name needs to add https://goplatform.minigame.qq.com.
2. Script introduction
Put the script into the SRC folder in the project root directory.
3. Instantiate the plug-in
In the “main.ts” or other implemented “ts” create a RecommendUI instance of mgplugin, inserted in the parent node. And then you need to pass in the appid parameter assigned by WeChat,for example, 'wxd0e404d795ea6f81'.
When creating RecommendUI instance, you can register callback methods “onClose” in the optional second parameter when the plug-in is closed. when users click on the plug-in back button in the upper left corner, the callback will be triggered :
4、Bind this event
Bind more game buttons(the project party realizes it by itself according to the game style) to displayed plug-in events. More game buttons need to be added to the switch, to control button display and shielding.
Starting parameters reporting
In order to count game jumps achieved through cross-marketing plug-ins.The mini-games which jump in through the cross-marketing plug-in can directly invoke the interface in the plug-in for channel reporting if a marketing plug-in is also introduced. (For example : players in the game A click games in the plug-in ,and then enter the game B by scanning QR code. If game B accesses plug-in,and the game B can call the interface of channel reporting for channel reporting when game initialization.)
When the game is initializing, call mgplugin.enterReport(‘appid’, ‘userid’. The parameters of the interface are: the appid of the game, the user id (as far as possible to use openid; if not, use the user id defined in the server of the game, which is mainly used to ensure the uniqueness of reporting users).
Notes:
1. The game side needs to add the plug-in switch to support the display and shielding of the version control plug-in. It needs to be closed by default before going online and opened when informed.
2. After the completion of access, you should inform us about it,for we need to do some testing. After that, it can be released online.