mirror of
https://github.com/logto-io/logto.git
synced 2025-03-31 22:51:25 -05:00
refactor: update android integration guides (#5222)
This commit is contained in:
parent
67be81e6df
commit
2f0e2a4400
2 changed files with 57 additions and 36 deletions
|
@ -12,11 +12,13 @@ import Step from '@/mdx-components/Step';
|
|||
|
||||
<InlineNotification>The minimum supported Android API is level 24</InlineNotification>
|
||||
|
||||
Add the `mavenCentral()` repository to your Gradle project build file:
|
||||
Before you add Logto Android SDK, ensure `mavenCentral()` is added to your repository configuration in the Gradle project build file:
|
||||
|
||||
```kotlin
|
||||
repositories {
|
||||
mavenCentral()
|
||||
dependencyResolutionManagement {
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
|
@ -24,10 +26,23 @@ Add Logto Android SDK to your dependencies:
|
|||
|
||||
```groovy
|
||||
dependencies {
|
||||
implementation 'io.logto.sdk:android:1.0.0'
|
||||
implementation 'io.logto.sdk:android:1.1.3'
|
||||
}
|
||||
```
|
||||
|
||||
Since the SDK needs internet access, you need to add the following permission to your `AndroidManifest.xml` file:
|
||||
|
||||
```xml
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
|
||||
<!-- other configurations... -->
|
||||
</manifest>
|
||||
```
|
||||
|
||||
</Step>
|
||||
|
||||
<Step
|
||||
|
@ -39,26 +54,19 @@ dependencies {
|
|||
<code className="language-java">
|
||||
{`import io.logto.sdk.android.LogtoClient;
|
||||
import io.logto.sdk.android.type.LogtoConfig;
|
||||
import io.logto.sdk.core.constant.PromptValue;
|
||||
|
||||
public class MainActivity extends AppCompatActivity {
|
||||
private LogtoClient logtoClient;
|
||||
// ...other codes
|
||||
LogtoConfig logtoConfig = new LogtoConfig(
|
||||
"${props.endpoint}",
|
||||
"${props.app.id}",
|
||||
null,
|
||||
null,
|
||||
true,
|
||||
PromptValue.CONSENT
|
||||
);
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_main);
|
||||
|
||||
LogtoConfig logtoConfig = new LogtoConfig(
|
||||
"${props.endpoint}",
|
||||
"${props.app.id}",
|
||||
null,
|
||||
null,
|
||||
true
|
||||
);
|
||||
|
||||
logtoClient = new LogtoClient(logtoConfig, getApplication());
|
||||
}
|
||||
}`}
|
||||
LogtoClient logtoClient = new LogtoClient(logtoConfig, getApplication());`}
|
||||
</code>
|
||||
</pre>
|
||||
|
||||
|
|
|
@ -12,11 +12,13 @@ import Step from '@/mdx-components/Step';
|
|||
|
||||
<InlineNotification>The minimum supported Android API is level 24</InlineNotification>
|
||||
|
||||
Add the `mavenCentral()` repository to your Gradle project build file:
|
||||
Before you add Logto Android SDK, ensure `mavenCentral()` is added to your repository configuration in the Gradle project build file:
|
||||
|
||||
```kotlin
|
||||
repositories {
|
||||
mavenCentral()
|
||||
dependencyResolutionManagement {
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
|
@ -24,10 +26,23 @@ Add Logto Android SDK to your dependencies:
|
|||
|
||||
```kotlin
|
||||
dependencies {
|
||||
implementation("io.logto.sdk:android:1.0.0")
|
||||
implementation("io.logto.sdk:android:1.1.3")
|
||||
}
|
||||
```
|
||||
|
||||
Since the SDK needs internet access, you need to add the following permission to your `AndroidManifest.xml` file:
|
||||
|
||||
```xml
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
|
||||
<!-- other configurations... -->
|
||||
</manifest>
|
||||
```
|
||||
|
||||
</Step>
|
||||
|
||||
<Step
|
||||
|
@ -40,17 +55,15 @@ dependencies {
|
|||
{`import io.logto.sdk.android.LogtoClient
|
||||
import io.logto.sdk.android.type.LogtoConfig
|
||||
|
||||
class MainActivity : AppCompatActivity() {
|
||||
val logtoConfig = LogtoConfig(
|
||||
endpoint = "${props.endpoint}",
|
||||
appId = "${props.app.id}",
|
||||
scopes = null,
|
||||
resources = null,
|
||||
usingPersistStorage = true,
|
||||
)
|
||||
val logtoConfig = LogtoConfig(
|
||||
endpoint = "${props.endpoint}",
|
||||
appId = "${props.app.id}",
|
||||
scopes = null,
|
||||
resources = null,
|
||||
usingPersistStorage = true,
|
||||
)
|
||||
|
||||
val logtoClient = LogtoClient(logtoConfig, application)
|
||||
}`}
|
||||
val logtoClient = LogtoClient(logtoConfig, application)`}
|
||||
</code>
|
||||
</pre>
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue