05/15/2024 15:19:45

Garena Channel Description

Before June 30, 2021, Garena version must be updated to Garena4.0.13, that is MSDKV5.16; otherwise, there may be a Google-related failure.

I. Developer Platform Configuration

I. Developer Platform Configuration

appid and other related information are uniformly given by Garena.
1. Because Garena iOS SDK 4.0.19 version (corresponding to the 5.31 version of MSDKGarena plugin) uses the iOS SDK 16+ library, it must be compiled with XCode 14.2 and above, otherwise the compilation may fail due to lack of related Swift libraries. The minimum iOS support version also needs to be changed to iOS 11, otherwise there may be a lack of relevant Swift libraries, resulting in compilation failure. At the same time, the Garena iOS version uses Swift's mixed programming capability. APP needs to perform Swift mixed programming adaptation for UnrealEngine based on UE4 supports Swift and Objective-C mixed compilation configuration on iOS platform.

2. Garena iOS SDK 4.0.6 version, compiled with targetVersion 30, since Android 11 no longer allows direct access to the SD card, uninstalling and reinstalling the game client can cause the loss of old guest accounts. It is recommended that the game side encourage players to bind their guest accounts to the platform accounts, and directly overwrite the installation to avoid the impact.

II. Android Project Configuration

II. Android Project Configuration

2.1 General Project Configuration

1)permission configuration

  • Garena 4.0.15 - 4.0.27 version, add the following permissions in AndroidManifest.xml
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.AUTHENTICATE_ACCOUNTS" />
<uses-permission android:name="android.permission.WRITE_SYNC_SETTINGS" />
<uses-permission android:name="android.permission.MANAGE_ACCOUNTS"/>
<uses-permission android:name="android.permission.USE_CREDENTIALS"/>
  • Garena 4.0.28 version, the permission is changed to
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.GET_ACCOUNTS" />
    <uses-permission android:name="android.permission.AUTHENTICATE_ACCOUNTS" />
    <uses-permission android:name="android.permission.WRITE_SYNC_SETTINGS" />
    <uses-permission android:name="android.permission.MANAGE_ACCOUNTS"/>
    <uses-permission android:name="android.permission.USE_CREDENTIALS"/>
    

[info] WRITE_EXTERNAL_STORAGE, GET_ACCOUNTS, RECORD_AUDIO is a sensitive permission

2)Configure Garena App id and key

Add the following settings in the project's assets/MSDKConfig.ini file

[Garena channel configuration]          
GARENA_APP_SDK_ASSIGN_ID = {YOUR_GARENA_APP_ID}         
GARENA_APP_SDK_KEY= {YOUR_APP_KEY}          
GARENA_LOGIN_TITLE = {YOUR_LOGIN_TITLE}

[info] Replace {YOUR_GARENA_APP_ID} with the Garena APP ID applied by the game, and replace {YOUR_APP_KEY} with the APP KEY applied by the game. {YOUR_LOGIN_TITLE} is used for Garena Web login. The user can set the user-defined title. If not set, the title will use the field's default value.

2.2 Configurations of Garena's sub-channels

1) Configuration of sub-channel Guest

1、Find the authenticator.xml file in the corresponding engine directory

  • The location of the authenticator.xml file in the Unity project

    Plugins\Android\gcloudsdk-msdk-garena\res\xml
    

    [info] Garena 4.0.28 and higher versions have been adjusted to this path.

  • The location of the authenticator.xml file in the UnrealEngine project

    MSDKGarena\Source\MSDKGarena\lib\Android\msdk-garena\res\xml
    

    [info] Garena 4.0.28 and higher versions have been adjusted to this path.

2、Replace {GARENA_APP_SDK_ASSIGN_ID} with the game's own Garena APPID.

<?xml version="1.0" encoding="utf-8"?>
<account-authenticator
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:accountType="com.garena.msdk{YOUR_GARENA_APP_ID}">
</account-authenticator>

<!-- For Gareana 4.0.28 and higher versions, please replace the configuration with the following configuration -->
<account-authenticator
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:accountType="{your packageName}"
  android:icon="@drawable/android_icon"
  android:label="@string/app_name"
  android:smallIcon="@drawable/android_icon" />
  1. As Android 11 no longer allows direct access to SD cards, uninstalling and reinstalling the game client will result in the loss of old guest accounts. It is recommended that the game side encourage players to bind guest accounts to platform accounts and directly overwrite the installation to avoid the impact.
  2. {your packageName} is configured as the Android package name of the game. Be careful not to use the placeholder ${applicationId}.
  3. android:icon and android:smallIcon can be configured with any image resources, such as games' icons.
  4. Android: Configure the label as the game name.

2) Configuration of sub-channel Garena

Find and modify the following configuration in the AndroidManifest.xml file in the plugin directory:

<meta-data
  android:name="com.garena.sdk.applicationId"
  android:value="@integer/garena_app_id"/>

[info] Replace garena_app_id with Garena APP ID which the game applies for

<!-- Versions before Garena 4.0.28-->
<provider android:name="com.tencent.gcloud.msdk.common.GarenaFileProvider"
    android:authorities="com.garena.android.fileprovider{garena_app_sdk_assign_id}"
    android:exported="false"
    android:grantUriPermissions="true" >
    <meta-data
      android:name="android.support.FILE_PROVIDER_PATHS"
      android:resource="@xml/file_paths"/>
</provider>

<!-- For Garena 4.0.28 and higher versions, please remove the configuration of GarenaFileProvider above and replace it with the configuration below -->
<provider
    android:name="com.garena.android.share.GGFileProvider"
    android:authorities="com.garena.android.fileprovider{garena_app_sdk_assign_id}"
    android:exported="false"
    android:grantUriPermissions="true">
    <meta-data
      android:name="android.support.FILE_PROVIDER_PATHS"
      android:resource="@xml/file_paths"/>
</provider>

[info] {garena_app_sdk_assign_id} needs to be changed to Garena's APPID. Use it when sharing images otherwise sharing images will fail.

3) Configuration of sub-channel Facebook

Find and modify the following configuration in the AndroidManifest.xml file in the plugin directory:

<meta-data
  android:name="com.facebook.sdk.ApplicationId"
  android:value="@string/facebook_app_id"/>

<activity
  android:name="com.facebook.FacebookActivity"
  android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation"/>  

<provider
  android:authorities="com.facebook.app.FacebookContentProvider{facebook_app_id}"
  android:name="com.facebook.FacebookContentProvider"
  android:exported="true"/>

[info] Replace facebook_app_id with Facebook's AppID which the game applies for

4) Configuration of sub-channel Google

Find and modify the following configuration in the AndroidManifest.xml file in the plugin directory:

<meta-data
  android:name="com.garena.sdk.google_client_id"
  android:value="{YOUR_Google_Client_ID}"/>

[info] {YOUR_Google_Client_ID} needs to be changed to the Web-type client ID of Google.

5) Configuration of sub-channel Email

<activity
  android:name="com.beetalk.sdk.EmailAuthActivity"
  android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation"/>

[info] For Email login, it is required to contact Garena for backend configuration

6) How to adapt targetVersion 29

1.Set the targetVersion of the gradle file to 29 2.Add the requestLegacyExternalStorage attribute under the Application node in AndroidManifest.xml:

<application
  android:requestLegacyExternalStorage="true"
  ...
  >
<application/>

7) Garena platform log switch configuration

MSDKConfig.ini by default enables Garena platform log switch; enable: 1, disable: 0

GARENA_DEBUG_LOG_ENABLE = 1

2.3 Solutions to compilation problems arising from MSDK V5.31 upgrading

2.3.1 Unity engine

1、The game side adds the kotlin plugin configuration and AwemeOpenSDK maven warehouse address to the baseProjectTemplate.gradle file:

buildscript {
  repositories {
    ` ` `
    maven { url "https://artifact.bytedance.com/repository/AwemeOpenSDK" }
  }
  dependencies {
    ` ` `
    classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.21'
  }
}

Warning: Due to Garena SDK's strong dependency on Tiktok SDK, it is necessary to add AwemeOpenSDK Maven warehouse address

2、Requirements on the versions of Gradle and Gradle plugin -Gradle's minimum version: 3.6.4 -Gradle plugin's minimum version: 6.7.1

2.3.2 UE engine

  1. Add the following configuration to the buildscriptGadleAdditions node of the MSDK_Garena_UPL.xml file:

    <buildscriptGadleAdditions>
    <insert>
     <![<![CDATA[
       dependencies {
         classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.21'
       }
     ]]>]
    </insert>
    </buildscriptGadleAdditions>
    
  2. Add the following configuration to the baseBuildGradleAdditions node of the MSDK_Garena_UPL.xml file:

    <baseBuildGradleAdditions>
    <insert>
     <![<![CDATA[
       {GRADLE_ADDITIONS}
     ]]>]
    </insert>
    </baseBuildGradleAdditions>
    

2.3.3 Interface adjustment

Since Garena Android 4.0.28, Garena no longer supports the silent sharing type 'kMSDKFriendReqTypeTextSilent'.

III. iOS Project Configuration

III. iOS Project Configuration

3.1 Xcode project configuration file info.plist

Find or create the following nodes:

<key>CFBundleURLTypes</key>
    <array>
    <dict>
        <key>CFBundleTypeRole</key>
        <string>Editor</string>
        <key>CFBundleURLName</key>
        <string>Garena</string>
        <key>CFBundleURLSchemes</key>
        <array>
            <string>fb{YOUR_FACEBOOK_APP_ID}</string>
        </array>
    </dict>
    <dict>
        <key>CFBundleTypeRole</key>
        <string>Editor</string>
        <key>CFBundleURLName</key>
        <string>Garena</string>
        <key>CFBundleURLSchemes</key>
        <array>
            <string>gop{YOUR_GARENA_APP_ID}</string>
        </array>
    </dict>
    <dict>
        <key>CFBundleTypeRole</key>
        <string>Editor</string>
        <key>CFBundleURLName</key>
        <string>Google</string>
        <key>CFBundleURLSchemes</key>
        <array>
            <string>{YOUR_GOOGLE_URL_SCHEME}</string>
        </array>
    </dict>
    <dict>
              <key>CFBundleTypeRole</key>
              <string>Editor</string>
              <key>CFBundleURLName</key>
              <string>twitter</string>
              <key>CFBundleURLSchemes</key>
              <array>
                   <string>twitterkit-{YOUR_TWITTER_KEY}</string>
              </array>
        </dict>
</array>
<key>LSApplicationQueriesSchemes</key>
<array>
    <string>twitter</string>
        <string>twitterauth</string>
    <string>fb-messenger-api</string>
    <string>fbshareextension</string>
    <string>fbauth2</string>
    <string>fb-messenger-share-api</string>
    <string>fbapi</string>
    <string>garenagc</string>
    <string>beetalk</string>
    <string>line</string>
    <string>gop{YOUR_GARENA_APP_ID}</string>
</array>
<key>NSAppTransportSecurity</key>
    <dict>
    <key>NSAllowsArbitraryLoads</key>
    <true/>
</dict>
<key>FacebookAppID</key>
    <string>{YOUR_FACEBOOK_APP_ID}</string>
<key>GOPAppID</key>
    <string>{YOUR_GARENA_APP_ID}</string>
<key>GoogleClientID</key>
    <string>{YOUR_GOOGLE_CLIENT_ID}</string>
<key>TwitterSecret</key>
      <string>{YOUR_TWITTER_SECRET}</string>
<key>TwitterKey</key>
    <string>{YOUR_TWITTER_KEY}</string>

Among them, {YOUR_FACEBOOK_APP_ID} needs to be modified to the Facebook AppID applied by the game, {YOUR_GARENA_APP_ID} needs to be modified to the Garena AppID applied by the game, {YOUR_GOOGLE_CLIENT_ID} needs to be modified to the Google ClientID applied by the game, and {YOUR_GOOGLE_URL_SCHEMES} needs to be modified to the Google UrlSchemes applied by the game.
Generally, the value of the applied Google URLSchemes is the inversed value of Google ClientID. For example, the Google ClientID applied at Google is 123456789-xxxxxxxxx.apps.googleusercontent.com, and the value of Google URLSchemes is com.googleusercontent.apps.123456789- xxxxxxxxx.
[info] If the game does not need to implement Twitter sub-channel-related functions, the two configuration items, that is, TwitterSecret and TwitterKey, also need to be configured. The parameters can be filled in at will. If they are not configured, this may cause crash.

3.2 Configure MSDKConfig.ini file

After adding the iOS plugins of MSDKGarena, find the MSDKAppSetting.bundle/MSDKConfig.ini file in the Xcode project and add or modify the following settings:

[Garena channel configuration]          
GARENA_APP_SDK_ASSIGN_ID = {YOUR_GARENA_APP_ID}         
GARENA_APP_SDK_KEY= {YOUR_APP_KEY}          
GARENA_LOGIN_TITLE = {YOUR_LOGIN_TITLE}

[info] Replace {YOUR_GARENA_APP_ID} with the APP ID applied by the game, and replace {YOUR_APP_KEY} with the APP KEY applied by the game. {YOUR_LOGIN_TITLE} is used for Garena Web login. The user can set the user-defined title. If not set, the title will use the field's default value.

3.3 Configuration of xx.projmods file of Unity XUPoter

When exporting a XCode project from Unity, you need to configure the xx.projmods file so that the exported XCode project can get the configuration shown in 3.1

{           
    "group": "MSDKGarena",          
    "libs": [],         
    "frameworks": [],           
    "files": [],            
    "folders": [],          
    "excludes": [],         
    "headerpaths":[],           
    "build_settings": {},           
    "system_capabilities": {},          
    "Info.plist":{          
        "LSApplicationQueriesSchemes":          
        [           
            "fb-messenger-api",         
            "fbshareextension",         
            "fbauth2",          
            "fb-messenger-share-api",           
            "fbapi",            
            "garenagc",         
            "beetalk",          
            "line",         
            "gop{YOUR_GARENA_APP_ID}"           
        ],          
        "CFBundleURLTypes" :            
        [           
            {           
                "CFBundleTypeRole":"Editor",            
                "CFBundleURLName":"Garena",         
                "CFBundleURLSchemes":["gop{YOUR_GARENA_APP_ID}"]            
            },          
            {           
                "CFBundleTypeRole":"Editor",            
                "CFBundleURLName":"Garena",         
                "CFBundleURLSchemes":["fb{YOUR_FACEBOOK_APP_ID}"]           
            },          
            {           
                "CFBundleTypeRole":"Editor",            
                "CFBundleURLName":"Google",         
                "CFBundleURLSchemes":["{YOUR_GOOGLE_URL_SCHEME}"]           
            }           
        ],          
        "GOPAppID":"{YOUR_GARENA_APP_ID}",          
        "FacebookAppID":"{YOUR_FACEBOOK_APP_ID}",           
        "GoogleClientID":"{YOUR_GOOGLE_CLIENT_ID}"          
    }           
}

Among them, {YOUR_FACEBOOK_APP_ID} needs to be modified to the Facebook AppID applied by the game, {YOUR_GARENA_APP_ID} needs to be modified to the Garena AppID applied by the game, {YOUR_GOOGLE_CLIENT_ID} needs to be modified to the Google ClientID applied by the game, and {YOUR_GOOGLE_URL_SCHEMES} needs to be modified to the Google UrlSchemes applied by the game.

Generally, the value of the applied Google URLSchemes is the inversed value of Google ClientID. For example, the Google ClientID applied at Google is 123456789-xxxxxxxxx.apps.googleusercontent.com, and the value of Google URLSchemes is com.googleusercontent.apps.123456789- xxxxxxxxx.
[info] If the game does not need to implement Twitter sub-channel-related functions, the two configuration items, that is, TwitterSecret and TwitterKey, also need to be configured. The parameters can be filled in at will. If they are not configured, this may cause crash.

3.4 iOS dependency frameworks list

After adding the iOS plugins of MSDKGarena, find the BuildPhrases configuration of the project in the Xcode project, and add or modify the following configuration:

Social.framework
CoreServices.framework
Accelerate.framework
CoreLocation.framework
CoreMedia.framework
MapKit.framework
AdSupport.framework
AuthenticationServices.framework
LocalAuthentication.framework
SafariServices.framework

[info] Note: You also need to add TwitterKitResources.bundle file in Copy Bundle Resources configuration in XCode, otherwise a crash may occur when the app starts.

3.5 MSDKGarena V5.17 and later versions need to deal with UnrealEngine's Swift and Objective-C mixed compilation issues

For details, please refer to UnrealEngine supports Swift and Objective-C mixed compilation configuration on iOS platform

3.6 Unity engine adapts to Garena iOS SDK's Swift and Objective-C mixed compilation issue

Find the XCodePostProcess file in Unity

Delete the comment and open the macro definition

image-20200818153409391

3.7 Risk warning

Garena iOS SDK 4.0.6 version (corresponding to MSDKGarena 5.17 version) starts to add the AdSupport.framework library. Confirmed by the Garena side, this library is used for Facebook reporting events to obtain IDFA. Game developers need to use the ATT framework pop-up window to declare permissions and enter the reason for requesting IDFA data in the info.plist; otherwise, there is a risk of review.

IV. Function Description

IV. Function Description

4.1 Configure login and binding callbacks

1)Functional description

In order to receive the callback from MSDK's Login module, games need to register the callback function for processing it. It is strongly recommended that the games register it in the application launch function. At the same time, it is recommended to call the guest resetting interface to reset the guest data after receiving a callback that other channels are successfully bound to the guest account, so that the player can directly use the account bound to other sub-channels to log in the game next time. If the guest resetting interface is not called after the guest account is bound to other subchannels successfully, using the guest login mode again will return an error code such as 2203(iOS) or 2019(Android), causing the guest login to fail. So when your guest login returns an error code such as 2203(iOS) or 2019(Android), it is recommended that you call the guest resetting interface to reset the guest data and then log in the game again.
At the same time, because the guest resetting interface is called back to the game through OnExtendRetEvent(C#) or MSDKExtendObserver(C++), the game needs to implement these two callback functions. For details, please refer to the following examples.

Warning: Garena SDK supports the function of defining permissions by users in Android 4.0.20 and iOS 4.0.12 and above. The default permission is: "public_profile, user_friends, email". If you want to adjust it, you can define it by yourself and transfer it through the permissions field during login

2)Interface declaration

C#
C++
// Logout callback, app wakeup callback         
            
public static event OnMSDKRetEventHandler<MSDKBaseRet> LoginBaseRetEvent;           
            
// Login callback, including login, bind, autologin, switchuser, etc.           
            
public static event OnMSDKRetEventHandler<MSDKLoginRet> LoginRetEvent;
class MSDKLoginObserver         
{           
public:         
            
    // Login callback, including login, bind, autologin, switchuser, etc.           
    virtual void OnLoginRetNotify(const MSDKLoginRet &loginRet) {};         
            
    // Logout callback, app wakeup callback         
    virtual void OnBaseRetNotify(const MSDKBaseRet &baseRet) {};            
};

3)Demo code

C#
C++
MSDKLogin.LoginRetEvent += OnLoginRetEvent;         
MSDKLogin.LoginBaseRetEvent += OnLoginBaseRetEvent;         
MSDKExtend.ExtendRetEvent += mExtendCallBack.OnExtendRetEvent;          
            
public void OnLoginRetEvent(MSDKLoginRet loginRet)          
{           
    Debug.Log("OnLoginRetNotify in Ligin");         
    string methodTag = "";          
    if (loginRet.MethodNameId == (int)MSDKMethodNameID.MSDK_LOGIN_LOGIN)            
    {           
        methodTag = "Login";            
    }           
    else if (loginRet.MethodNameId == (int)MSDKMethodNameID.MSDK_LOGIN_BIND)            
    {           
        methodTag = "Bind";         
        // Make judgment based on the login callback. When the current callback is the binding interface's callback, the currently bound main channel is Garena and the login callback code is 'Success', please call the guest resetting interface directly.           
        if(loginRet.Channel.Equals("Garena") && loginRet.RetCode == MSDKError.SUCCESS)          
        {           
            MSDKExtend.Invoke ("Garena", "resetGuest", "");         
        }           
    }           
}           
public void OnExtendRetEvent (MSDKExtendRet extendRet)          
{           
    string methodTag = extendRet.ExtendMethodName;          
            
    mCurrentTestMgr.ShowLogInNewLine (methodTag + Tools.Instance.GetRetString(extendRet));          
}
MSDKLogin::SetLoginObserver(new MSDKDemoBaseLoginObserver());           
            
class  MSDKDemoBaseLoginObserver: public GCloud::MSDK::MSDKLoginObserver {          
    // Login callback, including login, bind, autologin, switchuser, etc.           
public:         
    virtual void OnLoginRetNotify(const GCloud::MSDK::MSDKLoginRet &loginRet) {         
            
        // Make judgment based on the login callback. When the current callback is the binding interface's callback, the currently bound main channel is Garena and the login callback code is 'Success', please call the guest resetting interface directly.           
        if (loginRet.methodNameID == kMethodNameBind && loginRet.retCode == MSDKError::SUCCESS && loginRet.channel == "Garena") {           
            notifyToResetGuest(loginRet);           
        }           
        String ret = MSDKUtils::FormatJson(MSDKJsonManager::ToJson(loginRet));          
        UMSDKDemoBase::showNormalAlert(ret);            
    };          
    // Get the callback after the account is bound successfully, and reset the guest account            
    void notifyToResetGuest(const MSDKLoginRet &loginRet) {         
        String result =MSDKExtend::Invoke(loginRet.channel.c_str(), "resetGuest", "");          
        LOG_DEBUG("extend invoke result: %s,channel:%s,methodName:%s,json:%s", result.c_str(),loginRet.channel.c_str(),"resetGuest","");            
    }           
};          
            
class MyExtendObserver : public GCloud::MSDK::MSDKExtendObserver {          
public:         
    void OnExtendNotify(const MSDKExtendRet &extendRet) {           
        handleCallback(extendRet, extendRet.methodNameID);          
    };          
};

4.2 Login Function

Garena can log in without installing APP, or and it can also log in through multiple login sub-channels of Garena (Garena, Facebook, Google, Guest, Apple and Email).

[info] Note: The minimum Garena SDK versions supported by Email login: Android (4.0.20+), iOS (v4.0.12)

C#
C++
public static void Login(string channel, string permissions = "", string subChannel = "", string extraJson = "")
static void  Login(const String &channel, const String &permissions = "",           
                      const String &subChannel = "", const String &extraJson = "");

  • If iOS has installed Garena APP, it will launch the APP to log in the game; otherwise, it will launch the Web UI to log in the game.
  • The name of the login sub-channel is returned to the game in the extraJson field of LoginRet, such as "extraJson":"{"subChannel":"Facebook"}".

4.3 Binding Function

Garena channel has multiple login sub-channels, including Garena, Facebook, Google, Guest, Apple and Email. After Garena logs in as a sub-channel Guest, it can bind other sub-channels to facilitate account retrieval and other functions.

When the bound interface is called, the APP of the corresponding sub-channel will be launched (or the web login page of the corresponding channel will be opened) for authorized login operation. After completing the authorization and returning the game, MSDK will bind the channel account to the previously logged-in guest account .

C#
C++
public static void Bind(string channel, string permissions = "", string subChannel = "", string extraJson = "")
static void Bind(const String &channel, const String &permissions = "",         
                                const String &subChannel = "", const String &extraJson = "");

Note: It is recommended that the game call Garena's Guest login once after binding the Garena channel fails.

Remarks: After Garena SDK calls the binding operation, no matter whether the binding result is success or failure, the session of Garena SDK will be set to the newly bound channel (in fact, it is still in the Guest login status). Binding will fail at this time due to the session check failure. Therefore, it is recommended that the game call Garena's Guest login once after binding the Garena channel fails, so as to return to the normal Guest login status.

4.4 Friends Function

Garena channel is a complex channel. The friend sharing function needs to be implemented through sub-channels. Currently, there are three types of sharing sub-channels supported by it: Garena, Facebook and Line. The calling interfaces and examples are as follows (take the Facebook sub-channel for example).

1) Interface Declaration

C#
C++
// Send messages to friends (Send) 
public static void SendMessage(MSDKFriendReqInfo info, string channel = "")

// Share messages to the platform (Share) 
public static void Share(MSDKFriendReqInfo info, string channel = "")
// Send messages to friends (Send) 
public static void SendMessage(const MSDKFriendReqInfo &reqInfo, const string &channel = "");

// Share messages to the platform (Share) 
public static void Share(const MSDKFriendReqInfo &reqInfo, const string &channel = "");

2) Demo code

C#
C++
var reqInfo = new MSDKFriendReqInfo
{
// Take Garena-Facebook's image-sharing function for example
    Type = FriendReqType.Friend_REQ_IMG,
    ImagePath = "http://mat1.gtimg.com/www/qq2018/imgs/qq_logo_2018x2.png";
  ExtraJson = "{"mediaTagName":"me","subChannel":"Facebook","caption":"caption"}";
};
MSDKFriend.Share (reqInfo, "Garena");
MSDKFriendReqInfo info;
info.type = kMSDKFriendReqTypeIMG;
info.imagePath = "http://mat1.gtimg.com/www/qq2018/imgs/qq_logo_2018x2.png";
info.extraJson = "{"mediaTagName":"me","subChannel":"Facebook","caption":"caption"}";
MSDKFriend::Share(info, "Garena");

3)List of supported types (Garena)

Sharing type
MSDK interface Required fields
Required APP and login status
Corresponding Garena method
Link (Friend_REQ_LINK) SendMessage scene、mediaTagName、link、title、caption、desc、thumbPath Garena login status is required GGSendLinkToSession
Image (Friend_REQ_IMG) SendMessage scene、imagePath、mediaTagName Garena login status is required GGSendMediaToSession
Text and game icons (Friend_REQ_TEXT) SendMessage title、desc、mediaTagName、thumbPath Garena login status is required GGSendGameToSession

4)List of supported types (Facebook)

Sharing type
MSDK interface Required fields
Required APP and login status
Corresponding Garena method
Invitation (Friend_REQ_INVITE) SendMessage title、desc - GGSendRequestInvitationToFacebook
Link (Friend_REQ_LINK) Share title、desc、link、thumbPath、caption - GGSendLinkToFacebook
Image (Friend_REQ_IMG) Share scene、mediaTagName、imagePath、caption - GGSendMediaToFacebook

Note: For the sake of optimization, Facebook no longer recommends sharing messages to Facebook (Messenger APP) through SDK, so Garena iOS SDK has removed the packaging of related interfaces since version 3.1.3, and MSDK has also removed the two interfaces for sending link and image messages to Facebook (Messenger APP) since version 3.3.7 (packaging Garena 3.1.3).

Warning: Garena SDK Android 4.0.21 also marks the function of sending images to Facebook (Messenger APP) as expired and no longer supports it.

5)List of supported types (Line)

Sharing type
MSDK interface Required fields
Required APP and login status
Corresponding Garena method
Image (Friend_REQ_IMG) SendMessage imagePath It is needed to install Line APP GGShareImageToLine
Link (Friend_REQ_LINK) SendMessage desc、link It is needed to install Line APP GGShareLinkToLine

Warning: Line image sharing type; the imagePath field needs to transmit the local absolute path.

6)Parameter description table

No. Parameter name Uses
1 title Title
2 desc Overview, a brief description of the shared content
3 link Share link, which can be an image link, a music link, a video link or a hoplink, etc.
4 imagePath Local image address or network image URL (iOS only supports network images)
5 thumbPath Thumbnail, which is usually the icon of the game and can be the local address of the icon or the icon URL (iOS only supports network images)
6 mediaPath Multimedia address (music or video source)
7 user The parameter can be id or openid; for example, it is needed to specify the user to who the message is shared when the message is shared via the Silence mode
8 mediaTagName The parameter can pass in extra parameters or any empty string according to the game's needs
9 fbObjectId openid of the target friend to whom the game friend (Facebook) sends messages via the Silence mode

7)Advanced usage of the Friends function (MSDK 5.7 version begins to support it)

Many games often have the function that the player can send an invitation message to friends and the friends can directly enter the game room (or team) after clicking the message. MSDK supports to pass the room number and other information in the mediaTagName parameter when sending a message and to share them to Garena's Chat UI. This way, when a friend receives the message and clicks the message to launch the game, the information in mediaTagName will be transparently transmitted to the game client and returned to the game through the game_data field in wakeupRet.extraJson in onWakeupNotify. The struct returned in onWakeupNotify is shown as follows:

{           
    "ret":-1,           
    "msg":"",           
    "methodNameID":119,         
    "retCode":0,            
    "retMsg":"Success",         
    "extraJson":"{\"params\":\"{\\\"platform\\\":\\\"1\\\",\\\"from_open_id\\\":\\\"f9aed405b81abfbdfeb305c431335ca3\\\",\\\"open_id\\\":\\\"9317b7044e2feaeff33d1feac2de33b4\\\"}\",\"game_data\":\"33\"}"         
}

When the current login account of the game is different from the login account of Garena APP or there is currently no login account, launching the account from the message body will trigger account inconsistency. As for the description of account inconsistency, please refer to Switch Game Account

[info] Precautions

  1. The images shared and sent in iOS can only be network images, and network images cannot be saved locally.
  2. Sending link and image-type messages to Facebook interfaces depends on Messenger APP. If Messenger APP is not installed, an error message (iOS device) like "eFlag_BT_NotSupportApi" will be returned. If Android device is not installed with Messenger APP, the "Need install APP" error message will be returned.
  3. In the above case, the reason for the different returns from the two ends is that Garena SDK provides Android an interface for determining whether Messenger APP is installed, but does not provide the corresponding interface to iOS.
  4. If Facebook channel is used to log into a game, it can no longer be able to log in the game as the sub-channel Facebook of Garena. Otherwise, an error code, "1013", will be returned.
  5. Once a Garena account is bound, it can no longer be bound.
  6. In any case of sub-channel login (including no login status), you can launch Line APP to send messages. Similarly, if Line APP is not installed in your computer, you cannot send messages to Line.

4.5 Report events to Facebook sub-channel (MSDK 5.8 begins to support this function)

1)Function description

Since MSDK version 5.8, Garena SDK provides an interface for reporting events to Facebook. MSDK correspondingly encapsulates it to solve the problem that the game cannot call Facebook SDK interfaces to report events to the Facebook console while accessing Garena's complex channel.

2)Interface description

C#
C++
public string Invoke (string channel, string extendMethodName, string paramsJson)
String MSDKExtend::Invoke(const String& channel, const String& extendMethodName, const String& paramsJson)

3)Description of input parameters

No. Parameter name Uses
1 channel The current login channel. It is needed to fixedly pass in Garena when calling this interface
2 extendMethodName Name of the function calling the Extension module. It is needed to fixedly pass in FacebookReportEvent when calling this interface
3 paramsJson Event-reporting parameter, which needs to be passed in as a JSON string. eventName is a required field and is the name of the reported event; each key-value pair in the params parameter is passed in as a JSON Object. An example is as follows: {"eventName":"ReportEventName","params":"{"param1":"value1","param2":"value2"}"}

4)View reporting results

The reporting result can be viewed on Facebook Developer, in the corresponding application console-> View Application Analysis

In the application analysis UI, you can click the corresponding reported event to view the data according to the name of the reported event

[info] Precautions

  1. Call the event reporting interface. The reported event will be delayed to some extent (related to factors such as the network environment, Facebook-side network fluctuations, etc.), so it often happens that there is a reported event name but there is no detailed data about the event. This is normal phenomenon. it is generally recommended to view the event about half an hour after receiving the callback that reporting is successful
  2. The time used by Facebook to count reported events is not China Standard Time (UTC+8). If you can't find the corresponding reporting when viewing the events on the day, on the console you can find the date changed to "yesterday" or "last 7 days" and then view the result of event reporting again
  3. The callback of event reporting will be called back to the game via OnExtendRetEvent(C#) or MSDKExtendObserver(C++). It is recommended to register the corresponding callback by referring to the above guest resetting logic.



Copyright © 2024 MSDK.
All rights reserved.

results matching ""

    No results matching ""