Google登录
前置条件
- Android
- iOS
在 Google Cloud Console 中创建一个 Android 凭证,并获取 Client ID。

在 Google Cloud Console 中创建一个 Web 凭证,并获取 Client ID/Client secret。

将上述获取的 client id 和 client secret 配置到 Garena Open Platform 控制台。

添加依赖
- Android
- iOS
在应用级别的 build.gradle 中添加以下代码,并将 $msdk_version 替换为实际的 MSDK 版本。
dependencies {
implementation "com.garena.sdk.android:login-google:$msdk_version"
}
配置
- Android
- iOS
- Unity
- Unreal
配置 AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
...
<application ...>
<meta-data
android:name="com.garena.sdk.google_client_id"
android:value="[google_client_id]" />
....
</application>
</manifest>
配置 Info.plist
<key>GIDClientID</key>
<string>YOUR_IOS_CLIENT_ID</string>
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLSchemes</key>
<array>
<string>YOUR_DOT_REVERSED_IOS_CLIENT_ID</string>
</array>
</dict>
</array>
在 Window -> GMSDK Settings 中配置 Google -> Android Client Id(Web) 和 Google -> iOS Client Id
在 Edit -> Project Settings -> Plugins -> Garena MSDK 中配置 GoogleClientIdAndroid、GoogleClientIdIOS、GoogleReversedClientIdIOS
使用方法
- Android
- iOS
- Unity
- Unreal
AccountManager accountManager = new AccountManager(activity);
accountManager.login(PlatformType.GOOGLE, onLoginListener);
[MSDKLoginManager loginWithPlatform:MSDKePlatformGoogle completion:^(MSDKLoginRet *loginRet) {
// handle login result
}];
GMSDKHandler.LoginClient.Login(AccountPlatform.Google, OnLoginCallback);
UMsdkLogin::Login(Google);