[英]Keep Login State Account Kit
我成功登錄Account Kit,但是當我關閉應用程序並重新輸入時,我必須再次登錄,有沒有辦法幫助我保存我的登錄信息? 非常感謝。
我了解您沒有提供足夠的代碼讓我們提供幫助。 但這里有一些基本的提示供您解決:
在打開應用程序時,檢查 AuthCode 是否存在。 如果沒有,則需要調用 login 方法。
if (AccountKit.getCurrentAccessToken() != null) { startActivity(new Intent(this, YourDestinationActivity.class));} else {onLogin(LoginType.PHONE);}
如果用戶之前登錄過,它會啟動目標活動。 如果沒有,它會啟動 onLogin() 方法並使用電話號碼登錄。
您的 onLogin 可能如下所示:
private void onLogin(LoginType phone) {
final Intent intent = new Intent(this, AccountKitActivity.class);
AccountKitConfiguration.AccountKitConfigurationBuilder configurationBuilder = new AccountKitConfiguration.AccountKitConfigurationBuilder(LoginType.PHONE, AccountKitActivity.ResponseType.TOKEN);
uiManager = new SkinManager(SkinManager.Skin.CONTEMPORARY, Color.parseColor("#EC1D24"));
configurationBuilder.setUIManager(uiManager);
intent.putExtra(AccountKitActivity.ACCOUNT_KIT_ACTIVITY_CONFIGURATION, configurationBuilder.build());
startActivityForResult(intent, REQUEST_CODE);
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.