01/10/2025 10:53:00
I. Import plugins
Follow the instructions in the GCloudSDK documentation to import SDK into the project.
II. Configure the environment
Please refer to Environment Configuration documentation at first.
[info] If your project has accessed GCloudSDK, please refer to the GCloud documentation for the following file configuration operations for Android and iOS.
2.1 Android
In the 'androidManifestUpdates' node of the MSDK_UPL.xml file, add the required permission in every Channel Function .
The following Demo code is used to add QQ configuration:
<androidManifestUpdates>
<log text="MSDK-UPL AndroidManifestUpdates begin" />
<!-- *************** MSDK configuration ************** -->
<addElements tag="application">
<!-- *************** QQ channel configuration ************** -->
<activity
android:name="com.tencent.connect.common.AssistActivity"
android:configChanges="orientation|screenSize|keyboardHidden"
android:screenOrientation="portrait"
android:theme="@android:style/Theme.Translucent.NoTitleBar" />
<activity
android:name="com.tencent.tauth.AuthActivity"
android:launchMode="singleTask"
android:noHistory="true">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="tencent1106977030" />
</intent-filter>
</activity>
</addElements>
<log text="MSDK-UPL AndroidManifestUpdates finish" />
</androidManifestUpdates>
In MSDK_UPL.xml, the following code is used for the lifecycle and initialization of MSDK Android.
<!-- Import classes in GameActivity.java -->
<gameActivityImportAdditions>
<insert>
import com.tencent.gcloud.msdk.api.MSDKPlatform;
import com.tencent.gcloud.msdk.api.login.MSDKLoginRet;
import com.tencent.gcloud.msdk.tools.IT;
import com.tencent.gcloud.msdk.tools.MSDKLog;
import com.tencent.gcloud.msdk.tools.json.JsonSerializable;
</insert>
</gameActivityImportAdditions>
<!--onCreate adds code in GameActivity.java -->
<gameActivityOnCreateAdditions>
<insert>
MSDKPlatform.initialize(this);
</insert>
</gameActivityOnCreateAdditions>
<!-- onActivityResult adds code in GameActivity.java -->
<gameActivityOnActivityResultAdditions>
<insert>
MSDKPlatform.onActivityResult(requestCode,resultCode,data);
</insert>
</gameActivityOnActivityResultAdditions>
<!--OnNewIntent adds code in GameActivity.java -->
<gameActivityOnNewIntentAdditions>
<insert>
MSDKPlatform.onNewIntent(newIntent);
</insert>
</gameActivityOnNewIntentAdditions>
2.2 iOS
Add related configuration items in the following configuration file: "Project Settings - iOS - Extra Plist Data - Aditional Plist Data
Take WeChat as an example. WeChat needs to add the following content in Info.plist:
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>CFBundleURLSchemes</key>
<array>
<string>xxxxx</string>
</array>
</dict>
</array>
<key>LSApplicationQueriesSchemes</key>
<array>
<string>weixin</string>
<string>wechat</string>
</array>
Copy the 'plist' content of each channel to the location as shown in the following diagram.
III. Access Functions
3.1 Register MSDK initialization callback (PIX version must handle this)
1) Function description
Receive the callback after MSDK initialization is completed. The game needs to register a callback function for processing. The game needs to wait for the callback to complete before it can start invoking the functional interfaces of other MSDK modules.
2) Interface declaration
class MSDK_EXPORT MSDKInitObserver
{
public:
// MSDK initialization callback
virtual void OnInitCompleteNotify(const MSDKBaseRet &baseRet) {};
};
3) Demo code
MSDK::SetMSDKInitObserver(new MSDKDemoInitObserver());
class MSDKDemoInitObserver : public MSDKInitObserver
{
public:
//MSDK initialization completion callback
void OnInitCompleteNotify(const MSDKBaseRet &baseRet)
{
if (baseRet.retCode == MSDKError::SUCCESS)
{
MSDKPIX_LOG_ERROR("", "MSDK is initialized successfully. ");
//MSDK interfaces can be invoked at this time
}
else
{
MSDKPIX_LOG_ERROR("", "Failed to initialize MSDK.");
}
}
};
3.2 Function modules of MSDK
For the call of MSDK's functional modules, please refer to the call methods in Functional Modules documentation.
[info] Only Simulated Login is supported in the UnrealEngine Editor environment. If it is needed to access any other functional module, the module must be packaged into an APK or IPA file for debugging.
IV. Frequently Asked Questions (FAQ)
1.The game kills the process. Click QQ structured message or QQ Game Center to launch the game's (the account name is not real name) real name authentication page, and then click "Return to the Game", causing the game to black out.
- On UnrealEngine, when Android Dialog is used to pop up the test environment reminder, the game may black out during the program switching process. This problem does not occur after the test environment switches to the formal environment.
2.UnrealEngine Android is compressed. MSDKCore crashes after MSDK starts. The details are as follows:
/system/bin/tombstoned: received crash request for pid 17132
crash_dump32: performing dump of process 17132 (target tid = 17132)
*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
Build fingerprint: 'Xiaomi/chiron/chiron:8.0.0/OPR1.170623.027/V10.2.2.0.ODECNXM:user/release-keys'
Revision: '0'
ABI: 'arm'
pid: 17132, tid: 17132, name: om.tencent.xxxx >>> com.tencent.xxxx <<<
signal 7 (SIGBUS), code 1 (BUS_ADRALN), fault addr 0x6f732e
r0 00000020 r1 2f62696c r2 00000015 r3 2f6d7261
r4 5562696c r5 c4e0bcb8 r6 00000020 r7 732e3445
r8 c4da37bd r9 6c50006f sl d4c13124 fp 6e696775
ip c4dfe06c sp ffa62af8 lr c4bc63cf pc 006f732e cpsr 200e0010
backtrace:
#00 pc 006f732e <unknown>
#01 pc 000b63cb /data/app/com.tencent.xxxx-snxAMykZwlX4C7sfQvQjbw==/lib/arm/libMSDKCore.so (_ZNSt6__ndk112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6__initEPKcj+46)
- The cause of the problem is that the environment of UnrealEngine is not the same as that of Android C++. It is needed to guarantee the loading order of '.so' files, so that the internal functions can be executed normally.
- The solution is, behind the following line of code in MSDKCore/Source/MSDKCore/MSDKCore_UPL.xml file,
<log text="MSDK-UPL MSDK.so loaded after libUE4.so" />
add the following code. The problem can be solved by this way.
<loadLibrary name="MSDKCore" failmsg="MSDKCore libary not loaded! " />
All rights reserved.