-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add auto login & fix update custom data API
- Loading branch information
Showing
18 changed files
with
539 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,62 @@ | ||
# 建设中 | ||
# 集成支付宝步骤 | ||
|
||
1. 在这个页面下载 [支付宝 Android SDK](https://opendocs.alipay.com/open/54/104509) | ||
|
||
>支付宝将 Android、iOS 的 SDK 和 Demo 打包到一个 zip 包里面,找到里面的安卓 SDK,拷贝到 app 的 libs 目录 | ||
2. 设置依赖: | ||
```groovy | ||
implementation 'cn.authing:guard:+' | ||
implementation files('libs/alipaysdk.aar') | ||
``` | ||
|
||
>Guard 只是 compileOnly 依赖微信,这样可以让 App 按需引入,防止 Guard aar 包随着支持的第三方登录增加而越来越大。所以每增加一个第三方身份源,都需要 App 手动加上该身份源的依赖 | ||
3. 在应用启动的时候设置支付宝 AppID: | ||
```java | ||
Alipay.appId = "2021002192647456"; | ||
``` | ||
|
||
4. 在应用启动的时候初始化 Authing: | ||
```java | ||
// appId 是 authing 的应用 id,可以在 authing 控制台里面获取 | ||
Authing.init(context, appId); | ||
``` | ||
|
||
接下来,如果使用我们提供的支付宝登录按钮,则在布局文件里面加上(当然也可以用代码初始化): | ||
|
||
```xml | ||
<cn.authing.guard.AlipayLoginButton | ||
android:id="@+id/btn_alipay_login" | ||
android:layout_width="44dp" | ||
android:layout_height="44dp" | ||
app:layout_constraintLeft_toLeftOf="parent" | ||
app:layout_constraintRight_toRightOf="parent"/> | ||
``` | ||
|
||
然后在 java 代码里面处理事件: | ||
|
||
```java | ||
AlipayLoginButton button = findViewById(R.id.btn_alipay_login); | ||
button.setOnLoginListener((ok, data) -> { | ||
if (ok) { | ||
// 登录成功,data 是用户信息 | ||
} else { | ||
// 登录失败 | ||
} | ||
}); | ||
``` | ||
|
||
<br> | ||
|
||
如果不想使用我们内置的按钮,则可以在自己按钮的点击事件里面调用: | ||
|
||
```java | ||
Alipay.login(appContext, ((ok, data) -> { | ||
if (ok) { | ||
// 登录成功,data 是用户信息 | ||
} else { | ||
// 登录失败 | ||
} | ||
})); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
GROUP=cn.authing | ||
POM_ARTIFACT_ID=guard | ||
VERSION_NAME=1.1.1 | ||
VERSION_NAME=1.1.2 | ||
|
||
POM_NAME=guard | ||
POM_PACKAGING=aar | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.