跳到主要内容

聚合登录UI

概览

该功能提供一个开箱即用的登录UI,会展示在 SGS App Data Center 中为你的游戏应用配置的支持登录平台。

UI同时支持浅色模式和深色模式。

aggregated_login_ui aggregated_login_ui_dark

添加依赖

在应用级别的 build.gradle 中添加以下代码,并将 $msdk_version 替换为实际的 MSDK 版本。

dependencies {
implementation "com.garena.sdk.android:login-ui:$msdk_version"
// implementation other login platform modules
}

使用方法

展示聚合登录UI

AggregatedLoginManager aggregatedLoginManager = new AggregatedLoginManager(activity);
aggregatedLoginManager.setOnLoginListener(/*listener instance*/this);
aggregatedLoginManager.showDialog(ThemeType.Light, new AggregatedLoginParams(
List.of(
new GarenaLoginParams(...), // // You can pass in the platform-specific login parameters here.
),
));

自定义按钮顺序

aggregatedLoginManager.showDialog(ThemeType.Light, new AggregatedLoginParams(
List.of(
new GarenaLoginParams(...), // // You can pass in the platform-specific login parameters here.
),
List.of(
LoginPlatform.GOOGLE, LoginPlatform.FACEBOOK, LoginPlatform.GUEST
)
));

通过获取可用平台列表来自定义你自己的登录UI

AccountManager accountManager = new AccountManager(activity);
accountManager.getAvailableLoginPlatforms(result->{
if(result.isSuccess()) {
List<Integer> platforms = result.unwrap();
// render your login UI
} else {
MSDKError error = result.getErrorInfo();
// request failed, maybe you should ask the user to try again?
}
});