02/25/2025 15:42:56
Tools Module
I. Overview
The Tools module mainly provides some common tool methods, such as to judge whether the app is installed. Where IsAppInstalled is a synchronous call and requires no callback.
II. Access Guide
Precondition
- Unity layer's CShalp file has been imported to Unity project
- Import the related files of iOS and Android into Unity project directory: Assets/Plugins/iOS (Android)
- Follow the steps below to complete access to the tool module
2.1 Judge whether the App is Installed
1) Function description
Judge whether the app is installed. Android platform passes in the "packageName" parameter, and iOS platform passes in the "channel" parameter, such as "QQ", "WeChat".iOS platform needs to configure LSApplicationQueriesSchemesin the info.plist file.
Application name | Android parameter | iOS parameter |
---|---|---|
com.tencent.mm | Use the channel name WeChat directly | |
com.tencent.mobileqq | Use the channel name QQ directly | |
com.facebook.katana | fb:// | |
com.twitter.android | twitter:// | |
Messenger | com.facebook.orca | fb-messenger:// |
2) Interface declaration
public static bool IsAppInstalled(string channel,string extra="")
static bool IsAppInstall(String channel,String extra="");
3) Demo code
#if UNITY_ANDROID
bool isQQInstalled = MSDKTools.IsAppInstalled("com.tencent.mobileqq");
bool isWeChatInstalled = MSDKTools.IsAppInstalled("com.tencent.mm");
#elif UNITY_IOS
bool isQQInstalled = MSDKTools.IsAppInstalled("QQ");
bool isWeChatInstalled = MSDKTools.IsAppInstalled("WeChat");
#endif
#if PLATFORM_ANDROID
bool isQQInstalled = MSDKTools::IsAppInstall("com.tencent.mobileqq");
bool isWeChatInstalled = MSDKTools::IsAppInstall("com.tencent.mm");
#else PLATFORM_IOS
bool isQQInstalled = MSDKTools::IsAppInstall("QQ");
bool isWeChatInstalled = MSDKTools::IsAppInstall("WeChat");
#endif
2.2 Channel number acquisition interface
1) Functional description
This interface is used to obtain the installation channel number in the Android APK package (before a game is launched, the channel number will be written into the APK package in Feiying system and the channel installation package will then be generated. The user downloads and installs the channel Installation package, and the channel number in the installation package is called the installation channel number).
2) Interface declaration
public static string GetConfigChannel();
static std::string GetConfigChannelID(const std::string &seqID);
3) Demo code
string channel = MSDKTools.GetConfigChannel();
MSDKTools::GetConfigChannelID();
Special Description:
- iOS installation channel number and registration channel are fixed at 1001;
- The method to modify the installation channel number (ie to rewrite the channel number) is provided by GCloud (Game Update Dolphin component). For details, please consult GCloud manual service;
- The registration channel of APK/IPA can be obtained through the regChannelDis parameter value in the login callback MSDKLoginRet. firstLogin indicates whether to log in to the game for the first time. If the value is 1, it indicates logging in for the first time; if the value is 0, it indicates logging in not for the first time.
Please note that registration channel number and the installation channel number are two fields. Please use them separately on the game side.
Case: A user downloaded a channel package with channel number 89900001 and then installed and logged into it during the game's closed beta testing period. After the game is officially launched, the user downloads a channel package with channel number 10000144 and then installs and logs into it. At this time, the user's registration channel number is 89900001 and the installation channel number is 10000144.
2.3 Report Addiction Prevention Information
1) Functional description
This interface is related to Tencent Center Console. It reports Prajna serial number. It currently supports domestic channels and does not support overseas channels temporarily now.
When a game is connected to Tencent Center Console, it will establish a long connection with Tencent Center Console. serialNumber is issued by Tencent Center Console. MSDK only reports relevant information.
2) Interface declaration
public static void ReportPrajna(string serialNumber)
static void ReportPrajna(String serialNumber);
3) Demo code
MSDKTools.ReportPrajna (serialNumber);
MSDKTools::ReportPrajna(serialNumber);
2.4 Open the Webpage of Tencent Center Console
1) Functional description
This interface is related to Tencent Center Console. It is used to open Tencent Center Console's webpage. It currently supports domestic channels and does not support overseas channels temporarily now.
jsonStr is issued by Tencent Center Console. MSDK will use this parameter to open Tencent Center Console's webview page.
2) Interface declaration
public static void OpenPrajnaWebView(string jsonStr)
static void OpenPrajnaWebView(String jsonStr);
3) Demo code
MSDKTools.OpenPrajnaWebView (jsonStr);
MSDKTools::OpenPrajnaWebView(jsonStr);
2.5 WeChat deeplink
1) Functional description
According to the current login status, open the corresponding app's deeplink (please contact each platform for the activation and configuration of the deeplink function)
2) Interface declaration
public static void OpenDeepLink(string link);
static void OpenDeepLink(String link);
3) Demo code
MSDKTools.OpenDeepLink ("INDEX");
// MSDKTools.OpenDeepLink ("DETAIL");
// MSDKTools.OpenDeepLink ("LIBRARY");
// MSDKTools.OpenDeepLink ("https://pvp.qq.com/match/kcc.shtml");
MSDKTools::SetToolsObserver(new MyToolsObserver());
// MSDKTools::OpenDeepLink("INDEX");
// MSDKTools::OpenDeepLink("DETAIL");
// MSDKTools::OpenDeepLink("LIBRARY");
// MSDKTools::OpenDeepLink("https://pvp.qq.com/match/kcc.shtml");
- INDEX: Skip to the WeChat Game Center's homepage
- DETAIL: Skip to the WeChat Game Center's details page
- LIBRARY: Skip to the WeChat Game Center's game library
- The specific skip's URL (this URL needs to be configured on WeChat first.The original address of the incoming skip URL)
Special Description:
For the deepLink function, you need to contact WeChat Game Center to activate and configure it. The URL configured on the WeChat side has a validity period, which is 6 months by default. After the URL expires, you need to go to the WeChat platform to renew the URL before you can continue to use it. When the UR is requested after it expires, SDK will return "Msg":"error from wx: {\"errcode\": -10016, \"errmsg\": \"openlink expired\"}".
As for the renewal of URL configured by deepLink, please refer to WeChat URL Renewal Documentation
2.6 The in-game scoring function in iOS
1) Function description
iOS pops up a scoring window in the app.
Special Description:
- The debugging version cannot submit the scoring result, but the release version can submit the scoring result.
- Under normal circumstances, the debugging version can pop up a scoring pop-up window, indicating that the function is normal.
2) Interface Declaration
public static void ShowRatingAlert();
static void ShowRatingAlert();
3) Demo code
MSDKTools.ShowRatingAlert();
MSDKTools::ShowRatingAlert();
2.7 Flow-free interface
Register callback
1) Function description
To accept the callback of MSDK's flow-free service query, the game needs to register the callback function for processing;
2) Interface Declaration
public static event OnMSDKRetEventHandler<MSDKToolsRet> ToolsRetEvent;
static void SetToolsObserver(MSDKToolsObserver *observer)
3) Demo code
MSDKTools.ToolsFreeFlowRetEvent += OnToolsRetEvent;
private void OnToolsRetEvent(MSDKToolsRet toolsRet){
//Here is the game's own logic processing of the callback
if (RetEventShouldCallBack(toolsRet))
{
string methodName = GetMSDKBaseRetName(toolsRet.MethodNameId);
RetEventHandlerCallBackResult(toolsRet, methodName);
}
}
MSDKTools::SetToolsObserver(new MyToolsObserver());
class MyToolsObserver : public MSDKToolsObserver
{
public :
virtual void OnToolsRetNotify(const MSDKToolsRet &toolsRet) {
//Here is the game's own logic processing of the callback
handleCallback(toolsRet);
}
virtual void OnToolsFreeFlowRetNotify(const MSDKToolsFreeFlowRet &toolsFreeFlowRet) {
//Here is the game's own logic processing of the callback
handleCallback(toolsFreeFlowRet);
}
};
4) Data structure
MSDKToolsFreeFlowRet
It is inherited from MSDKBaseRet, and contains basic information
Member variable name | Type | Description |
---|---|---|
freeFlowInfo | MSDKToolsFreeFlowInfo | Used to store free-traffic information |
MSDKToolsFreeFlowInfo
Member variable name | Type | Description |
---|---|---|
ipAll | string | List of all free-traffic IPs |
ipConnect | string | Return the corresponding key of the configuration information when traffic is free; otherwise, return the key of the input parameter |
isFree | int | 1: free traffic , 0: not free |
ccType | int | 1: China Unicom, 2: China Telecom, 3: China Mobile, 99: Others |
Query the flow-free service
1) Function description
The client calls the backend free-traffic service query interface to query the free-traffic service information.
The client request will transmit the 'key' parameter to the backend. This parameter is the game IP. If it is a free-traffic user, the server will send the corresponding VIP to the client.
2) Interface Declaration
/**
* Frow-free service query
* @param key: return the corresponding 'value' (corresponding svip) of the backend free-traffic configuration according to 'key' (originally 'IP')
* @param extraJson: extended field; temporarily not used
*/
public static bool GetFreeFlowInfo(string key, string extra="")
/**
* Free-traffic service query
* @param key: return the corresponding 'value' (corresponding svip) of the backend free-traffic configuration according to 'key' (originally 'IP')
* @param extraJson: extended field; temporarily not used
*/
static bool GetFreeFlowInfo(String key, String extraJson= "");
3) Demo code
MSDKTools.GetFreeFlowInfo(key);
MSDKTools::GetFreeFlowInfo(key);
All rights reserved.