MSDK System tTools
Unity3D
Check if mobile QQ and WeChat are installed
Get mobile QQ, WeChat versions
Check whether or not the interfaces support it
Get MSDK version
Get the installation channel
Get the registration channel
User feedback
Deeplink link skip
FAQ
Android
Check if mobile QQ and WeChat are installed
Get mobile QQ, WeChat versions
Check whether or not the interfaces support it
Get MSDK version
Get the installation channel
Get the registration channel
User feedback
Deeplink link skip
FAQ
IOS
Check if mobile QQ and WeChat are installed
Get mobile QQ, WeChat versions
Check whether or not the interfaces support it
Get MSDK version
Get the installation channel
Get the registration channel
User feedback
Deeplink link skip
FAQ
Others
Data Structure
System Tools
Tools / Android / Precondition

Preconditions

You have completed access configuration by the instructions for accessing the msdk unity configuration module.

Check if mobile QQ and WeChat are installed

1 Summary

Check if mobile QQ and WeChat are installed

2 Registration callback

None

3 Interface calling

1)Function description

Check if mobile QQ and WeChat are installed

2)Interface declaration
public static boolean WGIsPlatformInstalled(ePlatform platform);
3)Parameter description
Parameter name Parameter type Description
platform ePlatform platform type passed in by the game; possible values: ePlatform_QQ,ePlatform_Weixin
4)Return value
Return value type Description
bool false indicates the platform is not installed; true indicates the platform is installed
5)Demo code
bool isInstalled =  WGPlatform.WGIsPlatformInstalled(EPlatform.ePlatform_QQ);

Get mobile QQ or WeChat versions

1 Summary

Get the version of mobile QQ or WeChat

2 Registration callback

None

3 Interface calling

1)Function description

Now, only Android supports the function of getting the version of mobile QQ or WeChat. The detailed description of the interface is as follows

2)Interface declaration
public static String WGGetPlatformAPPVersion(ePlatform platform);
3)Parameter description
Parameter name Parameter type Description
platform ePlatform platform type passed in by the game; possible values: ePlatform_QQ,ePlatform_Weixin
4)Return value
Return value type Description
String APP version
5)Demo code
String wxVersion = WGPlatform.WGGetPlatformAPPVersion(EPlatform.ePlatform_Weixin);

Check whether or not the interfaces support it

1 Summary

Check if the current mobile QQ or WeChat version supports certain API

2 Registration callback

None

3 Interface calling

1)Function description

Some API can be used only in new versions of mobile QQ or WeChat. Call WGCheckApiSupport interface to check if the current mobile QQ or WeChat version supports certain API. The detailed description of the interface is as follows:

2)Interface declaration
public static bool WGCheckApiSupport(eApiName apiName);
3)Parameter description
Parameter name Parameter type Description
apiName eApiName such as: eApiName_WGSendToQQWithPhoto, eApiName_WGJoinQQGroup
4)Return value
Return value type Description
bool false means not support, true indicates support
5)Demo code
isSupport = WGPlatform.WGCheckApiSupport(ApiName.WGSendToQQWithPhoto);

Get MSDK version

1 Summary

Get MSDK's version

2 Registration callback

None

3 Interface calling

1)Function description

Call WGGetVersion interface to get MSDK's version. The detailed description of the interface is as follows

2)Interface declaration
public static String WGGetVersion();
3)Parameter description
4)Return value
Return value type Description
String MSDK version, such as: 2.14.5a
5)Demo code
String version = WGPlatform.WGGetVersion();

Get the installation channel

1 Summary

Get the installation channel
Remarks: After the interface for getting the installation channel number is accessed, when verifying whether the interface can work normally, you shall choose the real machine to verify it. If you use Tencent mobile game assistant simulator to verify it, please do not directly locally install apk to Tencent mobile game assistant simulator, because Tencent mobile game assistant simulator will mandatorily change the channel number of the locally installed apk to 100048 (the original channel number is less than 6 digits) or 10004822

2 Registration callback

None

3 Interface calling

1)Function description

Installation channel: before a game goes online, it is packed into apk packages with different channel numbers according to the channel name (such as MyApp, Wandoujia, 91 Mobile Assistant, etc.). The channel number in an apk package is called installation channel.

Calling WGGetChannelId can get a game's installation channel. The detailed description of the interface is as follows

2)Interface declaration
public static String WGGetChannelId();
3)Parameter description

None

4)Return value
Return value type Description
String Return installation channel id. If the interface's return value is null, please read channel number in assets/channel.ini again,
                                     so in the game's test stage, the game itself can write its channel number to assets/channel.ini for test.                      
IOS returns CHANNEL_DENGTA field in plist.Official channel id will read the value in the packet
5)Demo code
String channelId = WGPlatform.WGGetChannelId();
6)Special description

None

7)Name interpretation

Installation channel: before a game goes online, it is packed into apk packages with different channel numbers according to the channel name (such as MyApp, Wandoujia, 91 Mobile Assistant, etc.). The channel number in an apk package is called installation channel.

Get the registration channel

1 Summary

Get the registration channel

2 Registration callback

None

3 Interface calling

1)Function description

Registration channel: the installation channel through which the user logs into WeChat or mobile QQ for the first time. The value is bound with the account and can't be changed.

Calling WGGetRegisterChannelId can return the user's registration channel. The detailed description of the interface is as follows

2)Interface declaration
public static String WGGetRegisterChannelId();
3)Parameter type

None

4)Return value type
Return value type Description
String Return registration channel id, such as: 2017
5)Demo code
String registerChannelId = WGPlatform.WGGetRegisterChannelId();
6)Special description

None

7)Name interpretation

Registration channel: the installation channel through which the user logs into WeChat or mobile QQ for the first time. The value is bound with the account and can't be changed.

User feedback

1 Summary

User feedback: User feedbacks can be made through this event interface.

2 Registration callback

None

3 Interface calling

1)Function description

User feedback: User feedbacks can be made through this event interface, and feedback content is shown at http://dev.ied.com/msdk/userfeedback/index (access through the Intranet, and the Tencent operation interface administrator may assist you in your search). The interface required for the function is: WGFeedback. The detailed description of the interface is as follows:

2)Interface declaration
public static void WGFeedback(String body);

//Version higher than 3.0.8 have deleted the interface of these two parameters
public static void WGFeedback(String gameName,String body);
3)Parameter description
Parameter name Type Description
gameName String Game name
body String Feedback content
4)Return value

None

5)Demo code
WGPlatform.WGFeedback("the user experience is made to the extreme");

//3Version higher than 3.0.8 have deleted the interface of these two parameters
WGPlatform.WGFeedback("MSDK","the user experience is made to the extreme");

Deeplink link skip

1 Summary

Deeplink link skip

2 Registration callback

None

3 Interface calling

1)Function description

Deeplink can support skipping to WeChat game center's native pages and activity pages. The specific presentation scheme and display entrance can be customized according to the game's actual situation. The game center's native pages include: WeChat game center's homepage, WeChat game center's details page, WeChat game center's game library, etc.. They are implemented through the game's backend parameter settings. Activity pages include: the game's H5 page. They are implemented through the game's backend setting the skip site

2)Interface declaration
public static void WGOpenWeiXinDeeplink(String link);
3)Parameter description
Parameter name Type Description
link String specific skip deeplink, which can be filled with:
INDEX:skip to WeChat game center's homepage
DETAIL:skip to WeChat game center's details page
LIBRARY:skip to WeChat game center's game library
specific skip url (it is needed to first configure the url in WeChat game center)
4)Return value

None

5)Demo code
WGPlatform.WGOpenWeiXinDeeplink("INDEX");

The third party APP Launch Privilege

1 Summary description

The third party APP Launch Privilege allows the user to launch a game in the third party APP and pass data to the game.It is used for the cooperation of the third party APP and games. For example, users who start games from Tencent videos can get scores, experience bonus and so on.

2 Registration callback

1) You have already registered your game at Tencent open platform and passed the review, or your Tencent contact person has registered your game through internal channels.

2) You have completed Access Configuration by following the instructions for accessing the configuration module.

3) You need to modify AndroidManifest.xml and add the corresponding configuration items to it, and replace qqappid with your application's qqappid.

Remarks: Note that the new and old versions are different in configuration. As for the specific configurations, please refer to the following notes. The old version’s configuration starts to be supported since 3.2.5a, and the new version’s configuration is supported by 3.2.8a and higher versions

<!-- The third party APP launch configuration -->
<activity
    android:name="com.tencent.msdk.SchemeActivity"
    android:launchMode="singleTask">
    <intent-filter>
        <action android:name="android.intent.action.VIEW" />
        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />
        <!-- 3.2.8a and higher versions set tencentmsdk+qqappid here; 3.2.5a~3.2.7a version sets tencentvideo+qqappid here-->
        <data android:scheme="tencentmsdk100703379" />
    </intent-filter>
</activity>

4) Need to implement OnWakeupNotify callback function

When the third party app launches the game, it will inform the game of the parameters and other information which the started platform needs to pass through WGPlatformObserver's OnWakeupNotify (WakeupRet), where WakeupRet.platform represents the platform which launches the game. For example, at this time, WakeupRet.platform is EWakeupPlatform. eWakeupPlatform_TencentMsdk(3.2.5a~3.2.7a version is EWakeupPlatform.eWakeupPlatform_TencentVideo); WakeupRet.extInfo is Vector type and carries the data passed by the platform.

3)Interface call

None

4)Return value

None

5)Demo code
virtual void OnWakeupNotify(WakeupRet &wakeupRet)
    {
        LOGD("OnWakeupNotify: platform:%d flag:%d openid:%s", wakeupRet.platform, wakeupRet.flag,
            wakeupRet.open_id.c_str());wakeupRet.extInfo
        // TODO GAME The game needs to add the logic to handle account inconsistency here
        switch (wakeupRet.flag)
        {
            case eFlag_Succ:
                if(wakeupRet.platform == eWakeupPlatform_TencentMsdk)//3.2.5a~3.2.7a version is eWakeupPlatform_TencentVideo
                {
                    jstring j_msg_title = mEnv->NewStringUTF("by the MSDK Scheme launche");
                    std::string c_extinfo;
                    for(int i =0;i<wakeupRet.extInfo.size();i++){
                        c_extinfo = c_extinfo + wakeupRet.extInfo[i].key + ":" + wakeupRet.extInfo[i].value + "\n";
                    }
                    jstring j_msg_msg = mEnv->NewStringUTF(c_extinfo.c_str());
                    jclass cls = mEnv->GetObjectClass(gActivity);
                    jmethodID methodShowTips = mEnv->GetMethodID(cls, "showTipsDialog", "(Ljava/lang/String;Ljava/lang/String;)V");
                    mEnv->CallVoidMethod(gActivity, methodShowTips, j_msg_title, j_msg_msg);
                    mEnv->DeleteLocalRef(j_msg_title);
                    mEnv->DeleteLocalRef(j_msg_msg);
                }
                std::string platformdata;
                std::string gamedata;
                for(int i = 0;i < wakeupRet.extInfo.size();i++){
                    if(wakeupRet.extInfo[i].key.compare("platformdata"))
                    {
                        platformdata = wakeupRet.extInfo[i].value;
                        LOGD("OnwakeupNotify: platformdata:%s",platformdata);
                    }
                    if(wakeupRet.extInfo[i].key.compare("gamedata"))
                    {
                        gamedata = wakeupRet.extInfo[i].value;
                        LOGD("OnwakeupNotify: gamedata:%s",gamedata);
                    }
                }

            default:
            {
                // default no processing
                LOGD("login%s", "");
                jclass cls = mEnv->GetObjectClass(gActivity);
                jmethodID methodletUserLogout = mEnv->GetMethodID(cls, "letUserLogout", "()V");
                mEnv->CallVoidMethod(gActivity, methodletUserLogout);
                LOGD("OnWakeupNotify call letUserLogout end%s", "");
                break;
            }
        }
    }

Launch WeChat business, and share the message to WeChat Games (Haowan)

1)Function description

Provide functions to third parties, such as notifying WeChat to launch the internal browser, sharing messages to WeChat Games (Haowan), and opening the webpage or miniApp of the designated business. The interface has been added since version 3.3.6.

2)Interface declaration

    void WGSendToWXWithOpenBusinessView(const unsigned char *businessType,
                                        const unsigned char *query,
                                        const unsigned char *extInfo,
                                        const unsigned char *extData);

3)Parameter description

Parameter Name Type Description
businessType const unsigned char * Business content; temporarily use nativeShareToGameHaoWan (required)
query const unsigned char * Business parameters (optional, not used currently)
extInfo const unsigned char * Additional information to be passed by the business (Json format) (refer to passing in businessType-related business parameters, which are agreed with the business. For example, when opening miniApp, extInfo can be added with parameters to specify the version of miniApp to be opened,appid and appName in gameinfo are required fields. appid transmits WeChat appid; and appName transmits the game's name. They can be filled with any values if their values are not restricted. The reference format for them is: {"appid": "YOUR_WECAHT_APPID", "appName": "MSDKDemo"})
extData const unsigned char * Android can fill in null; the parameter is dedicated for iOS and is used to deliver videos (optional; and business-related binary data. For example, if businessType is to share a game video to WeChat Haowan, extData passes in the binary data of the video)

4)Return value

None

5)Demo code

    //Local video
    WGPlatform::GetInstance()->WGSendToWXWithOpenBusinessView("nativeShareToGameHaoWan", "", "{\"videoPath\":\"/storage/emulated/0/test_video.mp4\", \"needEdit\":1, \"gameInfo\":{\"battleId\":\"game12345\",\"appid\":\"YOUR_WECAHT_APPID\",\"appName\":\"MSDKDemo\"}}", "");

    //Cloud video
    WGPlatform::GetInstance()->WGSendToWXWithOpenBusinessView((unsigned char*)"nativeShareToGameHaoWan", (unsigned char*)"", (unsigned char*)"{\"videoUrl\":\"https://qt.qq.com/php_cgi/cod_video/php/get_video_url.php?vid=2a495e10fc03426fb8e4def77fc68a57&game_id=1007039\", \"thumbUrl\":\"http://shp.qpic.cn/record_smoba/0/53209e869e71dc351129059fbb5f748dT1552892652598430/\" , \"needEdit\":1, \"gameInfo\":{\"battleId\":\"game12345\",\"appid\":\"YOUR_WECAHT_APPID\",\"appName\":\"MSDKDemo\"}}", (unsigned char*)"");

Get country information based on IP address

1)Function description

Get country information based on IP address. Version 3.3.7 began to add this interface. In order to receive the callback, you need to register WGPlatformObserver and handle it via OnLocationGotCountryFromIPNotify.

2)Interface declaration

    void WGGetCountryFromIP();

3)Parameter description

None

4)Return value

None. The sharing result is called back via WGPlatformObserver OnLocationGotCountryFromIPNotify function returns to the game.

5)Demo code

    //Callback function
    WGPlatformObserver::OnLocationGotCountryFromIPNotify(GetCountryFromIPRet& fromIPRet);
    //Interface example