Skip to content
This repository was archived by the owner on Apr 2, 2025. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 64 additions & 1 deletion docs/pages/sdk/unity/recovering-sessions.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,69 @@ On Windows PCs, we leverage the [Crypto: Next Generation - Data Protection API (

On Web builds, we leverage [IndexedDB](https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API) via [PlayerPrefs](https://docs.unity3d.com/ScriptReference/PlayerPrefs.html).

## Android

On Android builds, we leverage the [Android Keystore](https://developer.android.com/privacy-and-security/keystore).

Our Keystore plugin for Unity (included in the SDK) requires a Custom Main Gradle Template. Please navigate to your Project Settings, then under `Player > Publishing Settings` enable `Custom Main Gradle Template`. This will create a file `Assets/Plugins/Android/mainTemplate.gradle` (or similar, the editor will show you the path) if you don't have one already. Here is an example `mainTemplate.gradle` file; please copy/paste this (or incorporate into your existing file).

```
apply plugin: 'com.android.library'
**APPLY_PLUGINS**

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.security:security-crypto:1.1.0-alpha03'

**DEPS**}

android {
compileSdkVersion **APIVERSION**
buildToolsVersion '**BUILDTOOLS**'

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

defaultConfig {
minSdkVersion **MINSDKVERSION**
targetSdkVersion **TARGETSDKVERSION**
ndk {
abiFilters **ABIFILTERS**
}
versionCode **VERSIONCODE**
versionName '**VERSIONNAME**'
consumerProguardFiles 'proguard-unity.txt'**USER_PROGUARD**
}

lintOptions {
abortOnError false
}

aaptOptions {
noCompress = **BUILTIN_NOCOMPRESS** + unityStreamingAssets.tokenize(', ')
ignoreAssetsPattern = "!.svn:!.git:!.ds_store:!*.scc:.*:!CVS:!thumbs.db:!picasa.ini:!*~"
}**PACKAGING_OPTIONS**
}**REPOSITORIES**
**IL_CPP_BUILD_SETUP**
**SOURCE_BUILD_SETUP**
**EXTERNAL_SOURCES**
```

Our Keystore plugin also requires a Custom Gradle Properties Template. Again, navigate to your Project Settings, then under `Player > Publishing Settings` enable `Custom Gradle Properties Template`. This will create a file `Assets/Plugins/Android/gradleTemplate.properties` (or similar, the editor will show you the path) if you don't have one already. Here is an example `gradleTemplate.properties` file; please copy/paste this (or incorporate into your existing file).

```
org.gradle.jvmargs=-Xmx**JVM_HEAP_SIZE**M
org.gradle.parallel=true
android.enableJetifier=true
android.useAndroidX=true
unityStreamingAssets=**STREAMING_ASSETS**
**ADDITIONAL_PROPERTIES**

android.enableR8=**MINIFY_WITH_R_EIGHT**
```

## Editor

In the editor, we leverage the MacOS and PC secure storage solutions depending on which version of the editor you are using. You will also need to enable 'EditorStoreSessionPrivateKeyInSecureStorage' in SequenceConfig in order to use secure storage and recover sessions from within the editor. This separate flag makes it easier for you to test both flows without modifying the behaviour of your builds.
In the editor, we use PlayerPrefs for private key storage. You will also need to enable 'EditorStoreSessionPrivateKeyInSecureStorage' in SequenceConfig in order to use secure storage and recover sessions from within the editor. This separate flag makes it easier for you to test both flows without modifying the behaviour of your builds. Secure storage in the editor is for development purposes only and should not be considered secure for long-term storage.