一键登录Android应用

The new One Tap sign-in and sign-up on Android helps you optimize the flow for authenticating users in your app. For many Android apps, user accounts are an important part of the conversion funnel and a common source of user drop-off. Users (and developers alike!) often forget which account they signed in with or what password they used for your service. By optimizing the process, you can improve conversion rates and reduce drop-off.

Android上新的“ 一键式”登录和注册可帮助您优化流程,以对应用程序中的用户进行身份验证。 对于许多Android应用而言,用户帐户是转化渠道的重要组成部分,也是用户流失的常见来源。 用户(以及开发人员!)经常忘记使用其登录的帐户或用于服务的密码。 通过优化流程,可以提高转化率并减少流失。

Gif: Animated demo. One Tap to sign in and sign up. Reduce friction and improve conversion. Google Sign-In and Smart Lock.
Showing One Tap for assisted sign in and sign up on Android
显示一键协助登录并在Android上注册

One Tap creates assisted sign in and sign up UIs which will augment your existing flows with a popup that lets your users authenticate frictionlessly. It does not replace your existing sign in or sign up flows, but helps you optimize the experience for users that choose to use the One Tap overlay.

一键式创建辅助登录和注册用户界面,这将通过弹出窗口扩展您的现有流程,让您的用户轻松进行身份验证。 它不会替代您现有的登录或注册流程,但可以帮助您为选择使用“一键式”重叠式广告的用户优化体验。

One Tap augments your existing sign in or sign up flows

一键式扩展您现有的登录或注册流程

One Tap supports

一键支持

  • Signing in to an existing account with your service using their Google account or saved passwords

    使用服务使用他们的Google帐户或保存的密码登录到现有帐户

  • Signing up for a new account with your service using their Google account (federated login)

    使用其服务的Google帐户注册一个新帐户(联合登录)

It ships with com.google.android.gms:play-services-auth version 18.0.0.

随附com.google.android.gms:play-services-auth版本18.0.0

一键式和Google身份服务 (One Tap and Google Identity Services)

One Tap is part of a new suite of libraries currently in development called Google Identity Services. Google Identity Services will eventually incorporate the full feature set of the Smart Lock for Passwords and Google Sign-In libraries, as well as introduce new features. The Google Sign-In library lets you sign in with Google accounts (just like One Tap) as well as offering additional features such as the Google Sign-In button and the ability to request additional permissions. However, this is a work in progress and the first version does not yet implement the full feature set of these libraries.

一键式开发是目前正在开发的一套新库的一部分,该库名为Google Identity Services。 Google Identity Services最终将结合Smart Lock for PasswordsGoogle Sign-In库的完整功能集,并引入新功能。 Google登录库可让您使用Google帐户登录(就像“一键通”一样),并提供其他功能,例如Google登录按钮和请求其他权限的功能。 但是,这是一项正在进行的工作,第一个版本尚未实现这些库的全部功能集。

Google Identity Services will eventually unify both the Google Sign-In and Smart Lock for Passwords for Android developers

Google身份服务最终将为Android开发人员统一Google登录和Smart Lock for Passwords

One Tap is the first feature of Google Identity Service that we’re launching and it’s ready for use in applications today to optimize sign in and sign up flows. We’ll be working on adding the other features provided by the Google Sign-In and Smart Lock for Passwords libraries. These features include the ability to save passwords, sign in with the Google Sign-In button, request permissions to access user data such as drive content, perform auto and silent sign in using Google Sign-In, save idp credentials, and lookup phone numbers for autofill flows. We hope to launch many of these features in Google Identity Services later this year.

“一键通”是我们正在启动的Google身份服务的第一个功能,现已可以在当今的应用程序中使用,以优化登录和注册流程。 我们将努力添加Google登录和Smart Lock for Passwords库提供的其他功能。 这些功能包括以下功能:保存密码,使用Google登录按钮登录,请求访问权限以访问用户数据(例如驱动器内容),使用Google登录执行自动和静默登录,保存IDP凭据以及查找电话号码自动填充流程。 我们希望今年晚些时候在Google身份服务中启动其中许多功能。

Compared to the existing Google Sign-In and Smart Lock for Passwords UIs, we have found that users are more likely to successfully sign in with the One Tap UI. Also, they’re more likely to choose the correct account when logging back in — which helps them get into your app, avoids creating duplicate accounts, and cuts down on support requests. The web version of this UI, which launched previously, has led to a 2x increase in conversions for some websites.

与现有的Google登录和Smart Lock for Passwords UI相比,我们发现用户更有可能通过One Tap UI成功登录。 此外,他们更有可能在重新登录时选择正确的帐户-这有助于他们进入您的应用程序,避免创建重复的帐户,并减少了支持请求。 先前启动的该用户界面网络版本使某些网站的转化次数增加了2倍。

For existing apps, our recommendation is to evaluate adding One Tap to augment your existing sign in and sign up flows when it makes sense for your application and team (you don’t need to do it right away).

对于现有应用程序 ,我们的建议是评估添加“一键式”以增加您现有的登录量,并在对您的应用程序和团队有意义的情况下注册流程(您无需立即进行操作)。

Applications that need features of Google Sign-In or Smart Lock for Passwords that are not yet available can use both libraries today to add One Tap on top of existing flows, or wait for support to be added later this year.

需要尚未使用Google登录或Smart Lock for Passwords功能的应用程序今天可以使用这两个库在现有流的顶部添加“一键式”,或者等待今年晚些时候添加支持。

For new applications, we recommend using One Tap to create optimized sign in and sign up experiences.

对于新应用程序 ,我们建议使用One Tap创建优化的登录和注册体验。

One Tap does not replace the Google Sign-In button, but augments your app’s existing sign in and sign up flows. You can use One Tap in an application that has a Google Sign-In button to create an assisted sign in or sign up flow in addition to your existing button.

一键式操作不会取代 Google登录 按钮,而是会扩展您应用程序现有的登录和注册流程。 您可以在具有Google登录按钮的应用程序中使用“一键式”创建除现有按钮之外的辅助登录或注册流程。

一键辅助登录 (Assisted sign in with One Tap)

Example screenshot of one tap dialog, text “Sign back in to Demo App with Google”

Assisted sign in with One Tap shows an overlay to the user prompting them to re-sign in with a previously authorized account. The user must have signed in previously in order for it to be presented as a “sign in” option.

“一键式”辅助登录会向用户显示一个叠加图,提示他们使用先前授权的帐户重新登录。 用户必须事先登录才能将其显示为“登录”选项。

Warning: You must implement sign up with One Tap to cover a case when a user doesn’t have a previously authorized account. If you only implement sign in you’ll not show an overlay to users who haven’t used your app or service before.

警告: 您必须实施“一键注册”以解决用户没有先前授权帐户的情况。 如果您仅实施登录,则不会向未曾使用过您的应用或服务的用户显示覆盖图。

One Tap sign in is triggered by your code. Depending on your app, this may be triggered when the app first launches, or later when the user attempts to perform a guarded action.

一键登录由您的代码触发。 根据您的应用程序,这可能在应用程序首次启动时触发,或者在用户尝试执行受保护的操作时触发。

Once you’ve decided to start the sign in process, you can query to see if any accounts are available for sign in by calling beginSignIn on a SignInClient. For sign in flows, it’s important that you configure the sign in with setFilterByAuthorizedAccounts(true) to only return previously authorized (or signed in) accounts. You can read more in the docs.

一旦你决定开始在过程中的符号,你可以查询,看是否有账户可用于登录通过调用beginSignInSignInClient 。 对于登录流程,使用setFilterByAuthorizedAccounts(true)配置登录以仅返回以前授权(或登录)的帐户很重要。 您可以在docs中阅读更多内容。

The callback from beginSignIn will pass a PendingIntent that displays the overlay when launched. Then you call startIntentSenderForResult with the provided PendingIntent to display the modal login popup over the current activity.

来自beginSignIn的回调将传递一个PendingIntent ,该PendingIntent在启动时显示覆盖。 然后,使用提供的PendingIntent调用startIntentSenderForResult ,以显示当前活动上方的模式登录弹出窗口。

Flow chart: beginSignIn points to startIntentSenderForResult which shows overlay.
Use the PendingIntent provided by the SignInClient to overlay the current Activity with a One Tap login dialog.
使用 SignInClient 提供的PendingIntent 将当前 Activity 与“一键式”登录对话框 重叠

One Tap can overlay on top of any Activity in your application

一键式可以覆盖应用程序中任何活动的顶部

The One Tap dialog can be displayed anywhere in your application. So, you can let the user get started using your app before asking them to sign in. This lets you build an optimized login flow for your application. Wherever you call startIntentSenderForResult, One Tap will overlay on top of that Activity.

“一键式”对话框可以显示在应用程序中的任何位置。 因此,您可以让用户在要求他们登录之前开始使用您的应用程序。这可以为您的应用程序构建优化的登录流程。 无论您在哪里调用startIntentSenderForResult ,“一键式”都将叠加在该Activity顶部。

Flow chart: Dialog result is sent to onActivityResult
The result of the prompt is returned using onActivityResult
使用onActivityResult返回提示的结果

The user then signs in using One Tap, or cancels the prompt. Either way, the result is sent to onActivityResult. You use the same client to parse the result and either get a federated login (Google Sign-In), or a password. Then continue the login process as you normally would with your backend.

然后,用户使用“一键式”登录,或取消提示。 无论哪种方式,结果都将发送到onActivityResult 。 您使用相同的客户端来解析结果,并获得联合登录名(Google登录)或密码。 然后像平常使用后端一样继续登录过程。

一键协助注册 (Assisted sign up with One Tap)

Example screenshot of one tap dialog, text “Sign up or sign in to the Demo App”

If One Tap doesn’t find any authorized accounts for sign in, beginSignIn will call the failure listener instead of passing your application a PendingIntent. When this happens, you should repeat the query but this time look for accounts that can be used to sign up.

如果One Tap找不到用于登录的任何授权帐户,则beginSignIn将调用失败侦听器,而不是将您的应用程序传递为PendingIntent 。 发生这种情况时,您应该重复查询,但是这次查找可用于注册的帐户。

This time configure One Tap with setFilterByAuthorizedAccounts(false) and it will query for any valid accounts that could be used to sign up, as well as any accounts that were previously authorized. If any are found, you’ll get back a PendingIntent that you can use to show a sign up overlay. When prompted to sign up the user will be asked to give consent for sharing email and profile permissions.

这次使用setFilterByAuthorizedAccounts(false)配置One Tap,它将查询可用于注册的任何有效帐户以及以前已授权的所有帐户。 如果找到任何内容,您将返回一个PendingIntent ,可用于显示注册叠加层。 当提示您签名时,将要求用户同意共享电子邮件和配置文件的权限。

To recap, here’s the overall flow for a One Tap overlay.

回顾一下,这是“一键式”叠加的总体流程。

Flow chart showing to use setFilterByAuthorizedAccounts true, followed by false, then falling through to regular sign up
Flow chart showing the one tap flow using setFilterByAuthorizedAccounts 流程图显示使用setFilterByAuthorizedAccounts的一键式流程

And, that’s really it. There’s a bit more to the API to support passwords — but to support federated auth login that’s all you need.

而且,确实如此。 该API还有更多功能来支持密码-但仅需支持联合身份验证登录即可。

如何实现密码流程? (How do I implement my password flow?)

You can think of a password login using One Tap as a password manager — the credentials will be stored and shared with your application just as if the user has typed them.

您可以将One Tap用作密码管理器来进行密码登录-凭据将被存储并与您的应用程序共享,就像用户键入了凭据一样。

One Tap uses the same password store as Autofill and Smart Lock for Passwords. So, if the user has ever saved a password using either of these for your app, it will be shown to the user as an account option on the One Tap prompt.

一键式使用与“ 自动填充”“密码智能锁定 ”相同的密码存储。 因此,如果用户曾经使用过这两种密码为您的应用程序保存了密码,它将在“一键式”提示下以帐户选项的形式显示给用户。

One Tap uses the same password store as Autofill and Smart Lock for Passwords

一键式使用与自动填充和密码智能锁定相同的密码存储

There are three basic password flows: retrieving saved credentials, inputting new credentials, and saving new credentials.

共有三个基本密码流:检索保存的凭证,输入新凭证和保存新凭证。

检索保存的密码凭证 (Retrieve saved password credentials)

In the initial One Tap sign up flow, configure the beginSignInRequest to support passwords. Then, the user will be presented with any saved passwords as an option in the One Tap UI.

在初始的“一键式”注册流程中,将beginSignInRequest配置为支持密码。 然后,将在One Tap UI中向用户显示所有保存的密码作为选项。

.setPasswordRequestOptions(PasswordRequestOptions.builder()    .setSupported(true)    .build())

使用密码登录用户 (Sign a user in with a password)

If a user chooses a saved password from the One Tap UI, it’ll be provided to your app using onActivityResult. You should then login to your backend like you normally would as if the user had entered the password.

如果用户从“一键式” UI中选择一个保存的密码,则将使用onActivityResult将其提供给您的应用。 然后,您应该像通常输入用户密码一样登录到后端。

If the user doesn’t select an account with One Tap, you can show a regular username/password screen. One Tap doesn’t have a UI for password entry, so you’ll have to build this screen and implement login yourself.

如果用户未通过“一键式”选择帐户,则可以显示常规的用户名/密码屏幕。 一键式没有用于输入密码的用户界面,因此您必须构建此屏幕并自行实现登录。

One Tap doesn’t provide a UI for entering passwords, you have to build that to support entering new passwords

一键式不提供用于输入密码的用户界面,您必须构建该界面以支持输入新密码

登录后保存密码 (Save a password after login)

After the user enters a password, prompt the user to save it using Autofill. The next time the user returns to your application the saved password will be available as an option in the One Tap sign in prompt.

用户输入密码后,提示用户使用Autofill进行保存。 下次用户返回到您的应用程序时,“一键登录”提示中将提供保存的密码作为选项。

Make sure you have optimized your app for Autofill to ensure that Autofill is able to successfully save your user credentials! To test saving credentials in Autofill on a device, install the test Autofill service linked from the docs — this lets you ensure that your Autofill implementation will work with all Autofill services. To learn more about optimizing your app for Autofill check out the codelab.

确保已针对自动填充优化了应用程序,以确保自动填充能够成功保存用户凭据! 要在设备上的自动填充中测试保存的凭据,请安装从文档链接的测试自动填充服务-这样可以确保自动填充实施可与所有自动填充服务一起使用。 要了解有关针对自动填充优化应用程序的更多信息,请查看代码实验室

After you optimize your app for Autofill, you can also consider integrating Smart Lock for Passwords which gives you even more control over password saving.

在针对自动填充优化应用程序之后,您还可以考虑集成Smart Lock for Passwords ,从而使您可以更好地控制密码保存。

学到更多 (Learn more)

This blog post aimed to give you an overview of what One Tap offers your app, and an idea about how you would integrate it. One Tap offers the ability to assist users through sign in and sign up for Android — improving conversions and avoid drop-off. With a fairly small API it’s easy to augment your existing authorization flows with One Tap.

该博客文章旨在为您概述One Tap为您的应用程序提供了什么,以及有关如何集成它的想法。 一键式提供了协助用户登录和注册Android的功能-改善了转换并避免了流失。 使用相当小的API,使用One Tap即可轻松扩展现有授权流程。

Check out the One Tap documentation to learn more about integrating it into your app!

查看One Tap文档,以了解有关将其集成到您的应用程序中的更多信息!

翻译自: https://medium.com/androiddevelopers/one-tap-sign-in-for-android-apps-2259ce15bc2c

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值