1. Quick access
Question 1001: How to quickly access games?
- QuickStart-Android Demo for quick access, reusing SudMGPWrapper;
- QuickStart-iOS Demo for quick access, reusing SudMGPWrapper;
- QuickStart-Flutter Demo;
- hello-sud-java Server Demo for Quick Access (if unable to access the code repository, please contact SUD to add a GitHub account).
Question 1002: How to quickly locate and resolve issues encountered during the access process?
- Please check whether the input parameters of the interface are correct (mgId is a 64-bit type);
- Please check the error code fields in Android Studio or XCode console logs, such as result_code, sdk_error_code, and retCode;
- Please send the problem description, video, screenshots, console logs (files), and other information to our technical support team to assist you in analyzing and answering.
Quick reference list of error codes
Question 1003: Can my app integrate with SudMGP SDK?
As long as the native view can be embedded in the UI framework of your app, your app can directly integrate with SudMGP SDK.
Question 1004: There are lite version SudMGP-lite SDK and standard version SudMGP SDK, which one should we use?
Lite version supports some games, standard version supports all games. Select the SudMGP SDK based on the App integrated game: List of game support for each SDK on different platforms
Question 1005: Scan to download HelloSudPlus experience demo (demonstrating multiple business scenarios)
Question 1006: Android SDK for Google Play Listing
You need to replace it with an SDK that complies with Google Play policies. The interface remains unchanged, only the SDK dependency is replaced. Please visit: SudMGP-Android
2. SudMGP Interface
Question 2001: Can the APP call the SudMGP SDK interface on a non-UI/Main thread? On which thread does SudMGP callback the APP?
- Any call to the SudMGP SDK by the APP must be initiated on the UI/Main thread;
- SudMGP callbacks to the APP are all on the UI/Main thread;
- SudMGP is responsible for thread switching to simplify the APP access logic.
Question 2002: Regarding the listener callback when the APP calls the notifyStateChange interface, what is its function?
- notifyStateChange is used to notify the game of the APP state;
- The ISudListenerNotifyStateChange callback only indicates that the APP state has been notified to the game, and does not indicate the logic code for completing the state notification in the game business logic (such as network requests). For troubleshooting connectivity during access, null can be passed;
- Do not write logic inside the callback;
- If you want to know whether the call result fails, you can use the App general state operation result error code, mg_common_app_common_self_x_resp.
Question 2003: Regarding the handle parameter in the game callback to the APP with ISudFSMStateHandle handle?
- Where ISudFSMStateHandle handle is used, the APP must call handle.success, otherwise it will cause memory leaks in the C++ layer callback object;
- If the game needs to get xx information from the App, the APP needs to call handle.success with specific parameters;
void onGetGameViewInfo(ISudFSMStateHandle handle, String dataJson); void onGetGameCfg(ISudFSMStateHandle handle, String dataJson);
- If the game needs to notify the App of state information, the APP only needs to call handle.success("{}");
void onExpireCode(ISudFSMStateHandle handle, String dataJson); void onGameStateChange(ISudFSMStateHandle handle, String state, String dataJson); void onPlayerStateChange(ISudFSMStateHandle handle, String userId, String state, String dataJson);
Question 2004: Does SudMGP support running two game instances at the same time?
- SudMGP does not support running two game instances at the same time;
- SudMGP's loadMG and destroyMG must be used in pairs;
- SudMGP is responsible for thread switching to simplify the APP access logic.
3. Function Implementation
Question 3001: How to hide the game background and display the APP custom background?
- Hide the game background during loading: Before calling SudMGP.loadMG, the APP sets SudMGP.getCfg().setShowLoadingGameBg(false);
- Hide the background of the game scene (game lobby): In the ISudFSMMG.onGetGameCfg callback, set ui.game_bg.hide=true;
- SudMGP SDK minimum version v1.1.46.xx
Download SudMGP-Android
Download SudMGP-iOS
Question 3002: How to hide the orange game loading progress bar and use the APP custom loading progress bar?
- Before calling SudMGP.loadMG, the APP sets SudMGP.getCfg().setShowCustomLoading(true);
- Notify the loading progress through ISudFSMMG::onGameLoadingProgress(int stage, int retCode, int progress);
- If the loading fails, the APP calls the retry interface ISudFSTAPP::reloadMG();
- SudMGP SDK minimum version v1.1.52.xx
Download SudMGP-Android
Download SudMGP-iOS
Question 3003: What is the relationship between the game view and the APP UI layer, and what is the game safe area (interactive operation)?
- The game view is treated as a native view in Android and iOS;
- The game view can be full screen or fixed size;
- The game view size fills the parent view (GameViewContainer) provided by the APP;
- The game obtains the game safe area (interactive operation) through the ISudFSMMGonGetGameViewInfo callback.
Question 3004: Does the game UI elements support hiding? Does the button click event support interception?
- The game UI elements support hiding.
For specific configuration, please refer to onGetGameCfg. - The button click event supports interception.
For specific configuration, please refer to onGetGameCfg.
Question 3005: Does the game support APP custom implementation of logic functions such as joining the game and starting the game?
- Yes, it supports.
- It supports hiding the game UI elements, and the APP can implement corresponding buttons.
For specific configuration, please refer to onGetGameCfg. - It supports intercepting button click events.
For specific configuration, please refer to onGetGameCfg. - The APP can implement logical functions such as joining the game and starting the game through the ISudFSTAPP.notifyStateChange interface.
Specific example: Start game button
Step 1: onGetGameCfg(IFSMStateHandle handle, String dataJson)
data = {
"gameMode":1, // The default game mode is 1 and if it is not specified, the game will use mode 1 by default.
"ui":{
"start_btn": { // Start game button
"custom": true,
"hide": false
}
}
}
handle.success(data);
Step 2: Receive onGameStateChange mg_common_self_click_start_btn status callback.
Step 3: The APP checks if the game can start, and if it can, it calls the ISudFSTAPP.notifyStateChange interface to send the app_common_self_playing status.
Question 3006: Does the game support localization for multiple languages? If a language is not supported, can translations be added?
- Yes, the game supports localization for multiple languages.
- Yes, translations can be added by contacting Sud Business.
- The SudMGP.loadMG method has a language parameter that can be used to specify the language. For example: zh-CN, en-US.
Question 3007: When can the APP call the game's ISudFSTAPP.notifyStateChange interface?
- The APP can call the ISudFSTAPP.notifyStateChange interface after receiving the ISudFSMMG.onGameStarted callback.
- onGameStarted indicates that the game has started (the game's long connection has been established). onGameStarted
- The user's role status in the game can only be changed from the "current status" to the "adjacent status".
Question 3008: How can the APP pass custom parameters and custom query keys for each game session?
- The APP calls ISudFSTAPP.notifyStateChange(state, dataJson).
state=app_common_self_playing and dataJson.isPlaying=true.
{ "isPlaying": true, // true to start the game, false to end the game "reportGameInfoExtras": "Custom parameters", // string type, maximum length of 1024 bytes, truncated if exceeded (as of 2022-01-21) "reportGameInfoKey": "Custom query key" // string type, maximum length of 64 bytes, used by the server to query data for a game session. }
4. Compatibility Solutions
Question 4001: How to solve the issue of the Android soft keyboard causing the game view to move up when it pops up?
- In AndroidManifest.xml, set android:windowSoftInputMode="adjustResize".
- Call setSoftInputMode in the ISudFSMMG.onGameStarted callback to set the soft input mode.
public void onGameStarted() { getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE | WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); }
Question 4002: When exiting a game room on iOS, sometimes there may be incompatibility issues between RTC and OpenAL, and symbols for AURemoteIO and OpenAL may appear in the stack.
Some small games use OpenAL to play sound effects and encapsulate AudioUnit mixing at the bottom layer. If the RTC's destroy method asynchronously calls the [AVAudioSession setCategory:error:] method, the AudioUnit thread will copy invalid audio buffers, causing incompatibility issues between RTC and the game's OpenAL-based sound effects. After calling the RTC's destroy method, synchronously call [AVAudioSession setCategory:error:] to solve this problem. The recommended category to pass is the system default SoloAmbient.
Question 4003: OkHttp Version Requirements for Android SDK
For version 1.4.1.1195 and above, the minimum required version of the OkHttp library is 3.11.0.
For versions from 1.3.2.1154 to 1.4.0.1191, the minimum required version of the OkHttp library is 3.14.0.
For versions below 1.3.2.1154, the minimum required version of the OkHttp library is 3.11.0.
Question 4004: When integrating Android SDK using Maven, you may occasionally encounter the error "Could not find SudMGP-x.x.x.x.jar"
Android SDK is available in AAR format. To resolve this issue, you can try two solutions:
- Disable the mirror Maven repository
- Specify the AAR format explicitly: Append "@aar" to the end of the dependency declaration. For example: implementation 'tech.sud.mgp:SudMGP:x.x.x.x@aar'
5. Game Personalization Status
Question 5001: How can Werewolf, the game, implement a voice version (with "Close your eyes, player X, speak up")?
I. The app will blindly turn on and off the RTC's push and pull streams based on the following two statuses (if not executed this way, cheating may occur):
- mg_common_self_microphone, "isOn": true // Microphone switch status: true means on (the app turns on RTC push stream); false means off (the app turns off RTC push stream).
- mg_common_self_headphone "isOn": true // Earphone (receiver, speaker) switch status: true means on (the app turns on RTC pull stream); false means off (the app turns off RTC pull stream).
II. Determine whether the app's microphone can be clicked. It is recommended to click only if both conditions 1 and 2 are true. If it cannot be clicked, give a toast prompt:
Condition 1: mg_common_game_state gameState=2 Condition 2: mg_common_self_microphone isOn=true (the player has spoken, but they can choose to mute themselves)
Microphone and earphone switch documentation
Question 5002: In the game "Draw Something," how can we distinguish who is drawing and who is answering?
- Status during word selection.
- Status during drawing.
- Status for displaying incorrect answers.
- Status for displaying the total score.
- Status for displaying the score for the current round.
6. BGM Issues and Solutions for iOS Games
Question 6001: No sound after the game starts?
The SDK will activate AVAudioSession and modify AVAudioSessionCategory by default. If you do not need the SDK to control it, call the SDK interface:
/// Earlier than v1.3.6 [SudMGP autoSetAudioSession:NO]; /// After v1.3.6, split two interfaces independent control, according to the requirements of their own combined use /// Close the SDK to control the active state of session [[SudMGP getCfg]setEnableAudioSessionActive:NO]; /// Close the SDK to control the category of session [[SudMGP getCfg]setEnableAudioSessionCategory:NO];
This will disable the SDK activation. Note that after the SDK loads the game, it is strictly forbidden to set AVAudioSession to an inactive state, as this will cause abnormal game sound playback.
Ensure that third-party SDKs, such as RTC vendor SDKs, do not modify AVAudioSession to an inactive state when switching on/off the microphone or exiting the voice engine. A common control switch for RTC vendors to modify the AVAudioSession state is as follows:
Zego:
When configuring setEngineconfig, add the configuration audio_session_do_nothing:true to disable the sound interruption caused by exiting the RTC room.
/// add the configuration audio_session_do_nothing:true to disable the sound interruption caused by exiting the RTC room engineConfig.advancedConfig = @{@"audio_session_do_nothing": @"true"}; [ZegoExpressEngine setEngineConfig:engineConfig];
Agora:
When initializing the engine, configure the AgoraRtcEngineKit method to set the parameter AgoraAudioSessionOperationRestrictionDeactivateSession:
/// When initializing the engine, configure the AgoraRtcEngineKit method to set the parameter AgoraAudioSessionOperationRestrictionDeactivateSession. - (void)setAudioSessionOperationRestriction:(AgoraAudioSessionOperationRestriction)restriction;
NERTC
When initializing the engine, configure the NERtcEngine method to set the parameter kNERtcAudioSessionOperationRestrictionDeactivateSession:
/// When initializing the engine, configure the NERtcEngine method to set the parameter kNERtcAudioSessionOperationRestrictionDeactivateSession. - (int) setAudioSessionOperationRestriction:(NERtcAudioSessionOperationRestriction)restriction;
AliRtc
configure the AliRtcEngine method to set the parameter AliRtcAudioSessionOperationRestrictionDeactivateSession:
/// configure the AliRtcEngine method to set the parameter AliRtcAudioSessionOperationRestrictionDeactivateSession. - (int)setAudioSessionOperationRestriction:(AliRtcAudioSessionOperationRestriction)restriction;
Other RTC vendors:
If there is a situation where AVAudioSession is prohibited during the period, please consult the RTC vendor for a solution.
Question 6002: No game sound after the mute button is turned off?
- The game SDK will set the category of AVAudioSession to AVAudioSessionCategoryAmbient mode by default, which is controlled by the mute button. If you need sound even when the mute button is on, you need to change the category to AVAudioSessionCategoryPlayback after the game loaded, for example,in onGameStarted.
Question 6003: After the application enters the background, there is no sound in the subsequent RTC
When the game enters the background, it will attempt to pause the session. In the RTC scenario, there may be two situations:
- If there is sound playing in the RTC before entering the background, when the game pauses the session, it may fail and the game sound stops, while the RTC sound continues to play. Some RTC services, such as Agora, may output sound from the earpiece, depending on the RTC or the application's external configuration for directing sound output channels. The game itself does not direct the sound channel in any way.
- If there is no sound playing in the RTC before entering the background, when the game pauses the session, it will succeed and trigger a system notification. The game sound stops, and the subsequent RTC sound playback will be silent. In this case, if the RTC needs to play sound again when there is a stream, the session needs to be reactivated.
7. Using Embedded Game Resource Packages
Question 7001: How to use the embedded package in the project?
Step 1. Add the resource package xxxx.sp into the assets directory of the project
Android: Put the resource package into the assets directory
iOS: Create the assets directory under the project directory,place the resource package under the assets directory, and add the assets directory or the resource package to the XCode project
Step 2.Call the addEmbeddedMGPkg, add the embedded game resource package
/// iOS
[[SudMGP getCfg] addEmbeddedMGPkg:1583284410804244481 mgPath:@"xxxx.1.0.0.1.sp"];
/// Android
SudMGP.getCfg().addEmbeddedMGPkg(1583284410804244481, "xxxx.1.0.0.1.sp");
Note:
- The above method call can be made before loadMG.
- The successful embedding phenomenon: When the game is loaded for the first time, the progress goes from 40% to 80% directly.
- The embedded package file name must contain the version number. The embedded package provided by Sud will contain the version number. If it is an embedded package prepared by the integration, please contact Sud to get the current version number of the configured game and add the version number to the embedded package file name.
8. About the Issue of Game Loading Failure Caused by iOS Enterprise Signing
Question 8001: What should I do if the iOS enterprise-signed IPA package reports an error when running the game and cannot be loaded?
The SudMGP internal download resource defaults to the background download mode. In this mode, if the application-identifier in the embedded.mobileprovision signature file of the enterprise-signed IPA package does not match the application's bundle identifier, the application does not have permission to access the downloaded resource path, which causes the game to fail to load.
Choose one of the following methods to handle it:
- Ensure that the application-identifier matches the application's bundle identifier during signing.
- Turn off the background download mode:
[[SudMGP getCfg] setBackgroundMode:NO];
9. Android release package cannot load the game
Question 9001: The Android debug package can load the game, but the release package cannot load the game. What could be the issue?
Android demo download link:HelloSud
In the case where the same code can load the game in the debug package but not in the release package, please follow these steps to check the obfuscation configuration
1.Code obfuscation:
The obfuscation configuration is already defined in the Demo: project/SudMGPWrapper/consumer-rules.pro file.
-keep class tech.sud.mgp.SudMGPWrapper.** {*;}
When integrating the SudMGPWrapper module, this configuration will be automatically applied to the project, requiring no additional work
If you have modified the package name of the code inside the SudMGPWrapper module in the project, please use the following directive to preserve the new package name: -keep class xx.xx.xx.** {*;}
What is the reason? For example: tech.sud.mgp.SudMGPWrapper.model.GameViewInfoModel
In the demo, the Gson library is used to serialize this class and send the safe area status to the game. If this class is obfuscated, the JSON data fields will not match, and the game will not be able to parse it
2.Resource obfuscation:
If the project is using resource obfuscation: AndroResGuard
Please add the corresponding whitelist configuration. Here is the documentation link:QuickStart
Search for 'whitelist' within the document to locate the relevant information
10. SDK log storage path
1.Android log storage path:
/externalStorage/Android/data/[application package name]/files/SudMGPLogs
You can use the 'File Manager' on your phone to navigate to the 'Android/data/[application package name]/files/SudMGPLogs' directory in the internal storage. From there, you can share the files in that directory through social media apps or email.
2.iOS log storage path:
/Library/Caches/SudMGPLogs