如果一鍵登錄滿足您的需求,請考慮改用它。一鍵式更新了用戶體驗,並進行了其他改進。

通過將Smart Lock for Passwords集成到您的Android應用中,您可以使用用戶保存的憑據自動登錄您的應用。用戶可以同時保存用戶名密碼憑據和聯合身份提供者憑據。

通過使用憑據API檢索登錄時保存的憑據,將Smart Lock for Passwords集成到您的應用程序中。使用成功檢索到的憑據登錄用戶,或使用憑據API通過部分完成應用程序的登錄或註冊表單來快速吸引新用戶。登錄或註冊後提示用戶存儲其憑據,以供將來進行自動身份驗證。

查看成功的Smart Lock for Passwords集成的一些案例研究

// Store user credentials with Auth.CredentialsApi.save()

Auth.CredentialsApi.save(mCredentialsClient, credential).setResultCallback(
    new ResultCallback() {
        @Override
        public void onResult(Status status) {
            if (status.isSuccess()) {
                // Credentials were saved
            } else {
                if (status.hasResolution()) {
                    // Try to resolve the save request. This will prompt the user if
                    // the credential is new.
                    try {
                        status.startResolutionForResult(this, RC_SAVE);
                    } catch (IntentSender.SendIntentException e) {
                        // Could not resolve the request
                    }
                }
            }
        }
    });
// Retrieve stored credentials with Auth.CredentialsApi.request()

Auth.CredentialsApi.request(mCredentialsClient, mCredentialRequest).setResultCallback(
    new ResultCallback() {
        @Override
        public void onResult(CredentialRequestResult credentialRequestResult) {
            if (credentialRequestResult.getStatus().isSuccess()) {
                // Handle successful credential requests
            } else {
                // Handle unsuccessful and incomplete credential requests
            }
        }
    });
準備將Smart Lock for Passwords集成到您的Android應用中了嗎?