MSDK System Tools
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 / IOS / Precondition

Access guide

You have completed access configurationby the instructions for accessing the MSDK configuration module.

Check if mobile QQ and WeChat are installed

The detailed description of the interface is as follows

1)Interface declaration
bool WGIsPlatformInstalled(ePlatform platformType);
2)Parameter description
Parameter name Parameter type Description
platform ePlatform platform type passed in by the game; possible values: ePlatform_QQ,ePlatform_Weixin
3)Return value
Return value type Description
bool false indicates the platform is not installed; true indicates the platform is installed
4)Demo code
bool installed = WGPlatform::GetInstane()->WGIsPlatformInstalled(ePlatform_QQ);

Get MSDK version

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

1)Interface declaration
const std::string WGGetVersion();
2)Parameter description

None

3)Return value
Return value type Description
std::string MSDK version, such as:2.14.5i
4)Demo code
std::string version = WGPlatform::GetInstane()->WGGetVersion()

Get the installation channel

Installation channel: CHANNEL_DENGTA field in info.plist returned by iOS.

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

1)Interface declaration
const std::string WGGetChannelId();
2)Parameter description

None

3)Return value
Return value type Description
std::string Return installation channel id.
IOS returns CHANNEL_DENGTA field in plist,ios channel number is fixed as 1001, namely, App Store
4)Demo code
std::string channelId = WGPlatform::GetInstane()->WGGetChannelId();

Get the registration channel

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.Ios channel number is fixed as 1001, namely, App Store

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

1)Interface declaration
const std::string WGGetRegisterChannelId();
2)Parameter type

None

3)Return value type
Return value type Description
std::string Return registration channel id, such as: 1001
4)Demo code
std::string registerChannelId = WGPlatform::GetInstane()->WGGetRegisterChannelId();

Open MSDK log

Check MSDK log in test environment, and this interface will be called to turn on the MSDK log switch. The log at the iOS terminal can’t write any file but is output only at the console. Log switch needs to be opened.

1)Interface declaration
void WGOpenMSDKLog(bool enabled);
2)Parameter type
Parameter name Parameter type Description
enabled bool true:open  false:close
3)Return value type

None

4)Demo code
WGPlatform::GetInstance()->WGOpenMSDKLog(true);

User feedback

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:

1)Interface declaration
void WGFeedback(unsigned char* body);
2)Parameter description
Parameter name Type Description
body unsigned char* Feedback content
3)Return value

None

4)Demo code
WGPlatform::GetInstance()->WGFeedback((unsigned char*)"TestFeedBack");

Deeplink link skip

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

1)Interface declaration
void WGOpenWeiXinDeeplink(unsigned char* link);
2)Parameter description
Parameter name Type Description
link unsigned char* 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:LIBRARY:skip to WeChat game center's game library
specific skip url (it is needed to first configure the url in WeChat game center)
3)Return value

None

4)Demo code
WGPlatform::GetInstance()->WGOpenWeiXinDeeplink((unsigned char*)"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 plist and add the corresponding URL Types configuration item to it, and replace some qqappid in the case 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.5i, and the new version’s configuration is supported by 3.2.8i and higher versions

////3.2.5i~3.2.7i versions are configured as follows:
Identifier:tencentvideo
URL Schemes:tencentlaunch100703379
Role:Editor

//3.2.8i versions and above are configured as follows:
Identifier:tencentmsdk
URL Schemes:tencentmsdk100703379
Role:Editor

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.5i~3.2.7i 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
- (void)onWakeupNotify:(WakeupRet&)wakeupRet
{
    NSString *message = @"";
    switch (wakeupRet.flag)
    {
        //Handle Tencent video launch logic
        case eFlag_Succ:
            NSLog (@"MSDKDemo: Wake up successfully");



            if(wakeupRet.platform == eWakeupPlatform_TencentMsdk)//3.2.5i~3.2.7i version is eWakeupPlatform_TencentVideo
            {
                for(KVPair kv :wakeupRet.extInfo){
                    NSString *key = [NSString stringWithCString:kv.key.c_str() encoding:NSUTF8StringEncoding];
                    NSString *value =[NSString stringWithCString:kv.value.c_str() encoding:NSUTF8StringEncoding];
                    message = [NSString stringWithFormat:@"%@%@:%@\n",message,key,value];
                }
                UIAlertView *alert = [[UIAlertView alloc] initWithTitle: @"Launched by Tencent Video"
                                                                message:message
                                                               delegate:nil
                                                      cancelButtonTitle: @"Sure"
                                                      otherButtonTitles: nil
                                      ];
                [alert show];
            }
            break;
        case eFlag_NeedLogin:
        {
            //Handle Tencent video launch logic
            if(wakeupRet.platform == eWakeupPlatform_TencentMsdk)//3.2.5i~3.2.7i version is eWakeupPlatform_TencentVideo
            {
                for(KVPair kv :wakeupRet.extInfo){
                    NSString *key = [NSString stringWithCString:kv.key.c_str() encoding:NSUTF8StringEncoding];
                    NSString *value =[NSString stringWithCString:kv.value.c_str() encoding:NSUTF8StringEncoding];
                    message = [NSString stringWithFormat:@"%@%@:%@\n",message,key,value];
                }
                UIAlertView *alert = [[UIAlertView alloc] initWithTitle: @"Launched by Tencent Video"
                                                                message:message
                                                               delegate:nil
                                                      cancelButtonTitle: @"Sure"
                                                      otherButtonTitles: nil
                                      ];
                [alert show];
            }else{
                NSLog (@"MSDKDemo: Account inconsistency occurs. It is needed to enter the login page");
                WGPlatform::GetInstance()->WGLogout();
                UIAlertView *alert = [[UIAlertView alloc] initWithTitle: @"Account inconsistency"
                                                                message: @"Account inconsistency is found. It is needed to enter the login page"
                                                               delegate:nil
                                                      cancelButtonTitle: @"Sure"
                                                      otherButtonTitles:nil];
                [alert show];
            }

            NSArray *vcArray = self.navigationController.viewControllers;
            if (vcArray.count >= 2)
            {
                [self.navigationController popToRootViewControllerAnimated:YES];
            }
        }

            break;
        case eFlag_UrlLogin:
        {
            NSLog (@"MSDKDemo: Account inconsistency occurs. Log in successful through external launch");
            UIAlertView *alert = [[UIAlertView alloc] initWithTitle: @"Account inconsistency"
                                                            message: @"Account inconsistency is found. Log in successful through launching the external account. Wait for OnLoginNotify callback"
                                                           delegate:nil
                                                  cancelButtonTitle: @"Sure"
                                                  otherButtonTitles:nil];
            [alert show];
        }

            break;
        case eFlag_NeedSelectAccount:
        {
            NSLog (@"MSDKDemo: Account inconsistency occurs. It is needed to prompt the user to select an account");
            UIAlertView *alert = [[UIAlertView alloc] initWithTitle: @"Account inconsistency"
                                                            message: @"Account inconsistency is found. Please choose to use which account to log in"
                                                           delegate:self
                                                  cancelButtonTitle: @"Do not switch. Use the original account"
                                                  otherButtonTitles: @"Switch to use the external account to log in", nil];
            [alert show];
        }
            break;
        case eFlag_AccountRefresh:
            NSLog (@"MSDKDemo: The external account is the same as the logged-in account. Use the external token to update the local token");
            break;
        default:
            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 * 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((unsigned char*)"nativeShareToGameHaoWan", (unsigned char*)"", (unsigned char*)"{\"thumbUrl\":\"http://shp.qpic.cn/record_smoba/0/53209e869e71dc351129059fbb5f748dT1552892652598430/\" , \"needEdit\":1, \"gameInfo\":{\"battleId\":\"game12345\",\"appid\":\"YOUR_WECAHT_APPID\",\"appName\":\"MSDKDemo\"}}", (unsigned char*)[testVideoPath UTF8String]);

    //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