Project setup (Android)¶
The IDK consists of two parts: the runtime library (which contains the main logic), and the Gradle plugin (which applies user-defined theming to the IDK UI). Both parts reside in Digidentity's Maven repository.
Maven repository setup for the runtime library¶
Using the dependencyResolutionManagement
block in the settings.gradle¶
dependencyResolutionManagement {
repositories {
maven {
url 'https://jitpack.io'
}
maven {
url 'https://digidentity.mycloudrepo.io/repositories/digidentity'
credentials {
username = "username"
password = "password"
}
}
}
}
Using the allprojects
block in the build.gradle¶
allprojects {
repositories {
maven {
url 'https://jitpack.io'
}
maven {
url 'https://digidentity.mycloudrepo.io/repositories/digidentity'
credentials {
username = "username"
password = "password"
}
}
}
}
Note: JitPack is required for the IDK's transitive dependencies and must be explicitly specified.
Maven repository setup for the Gradle plugin¶
buildscript {
repositories {
maven {
url 'https://digidentity.mycloudrepo.io/repositories/digidentity'
credentials {
username = "username"
password = "password"
}
}
}
dependencies {
classpath "com.digidentity:idk-theme-plugin:0.6.0"
}
}
Java/Kotlin setup¶
The IDK requires at least Java 11. For that please add the following lines to the module-level build.gradle:
android {
compileOptions {
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
}
kotlinOptions {
jvmTarget = '11'
}
}
Runtime library dependency setup¶
dependencies {
implementation "com.digidentity:idk:{idk-version}"
implementation platform("com.google.firebase:firebase-bom:31.2.0")
implementation "com.google.firebase:firebase-dynamic-links"
implementation "com.google.firebase:firebase-messaging"
}
The IDK changelog can be found here.
Note: The IDK requires a set of Firebase libraries that must be explicitly specified. The example above contains a full list.
IDK theme Gradle plugin setup¶
Could be either:
plugins {
id 'com.digidentity.idk-theme'
}
...
IDKTheme {
sourceFile = "path-to-the-style-file.json"
}
or
apply plugin: 'com.digidentity.idk-theme'
...
IDKTheme {
sourceFile = "path-to-the-style-file.json"
}
depending on whether you use the Gradle Plugin DSL.
Push notifications setup¶
The IDK heavily relies on push notifications as a secondary communication channel, therefore they are an essential part of the setup.
Google Services Gradle plugin setup¶
Please include the following in the project-level build.config:
buildscript {
dependencies {
classpath 'com.google.gms:google-services:4.3.10'
}
}
And on the module level apply the plugin:
apply plugin: 'com.google.gms.google-services'
Please keep in mind that the google-services.json file must be placed in the proper location.
The last step is to link FCM token updates and messages to the IDK. In case of Kotlin that would be:
import com.digidentity.idk.DigidentityIDK
import com.google.firebase.messaging.FirebaseMessagingService
import com.google.firebase.messaging.RemoteMessage
class MessagingService : FirebaseMessagingService() {
override fun onMessageReceived(remoteMessage: RemoteMessage) {
DigidentityIDK.handleNotification(
this,
remoteMessage,
{
Log.i("MessagingService", "IDK handled remote message.")
},
{ error: DigidentityIDKError ->
Log.e("MessagingService", "IDK could not handle remote message.", error)
}
)
}
override fun onNewToken(newToken: String) {
DigidentityIDK.handleNewFirebaseToken(newToken)
}
}
In case of Java add the following class:
import androidx.annotation.NonNull;
import com.digidentity.idk.DigidentityIDK;
import com.google.firebase.messaging.FirebaseMessagingService;
import com.google.firebase.messaging.RemoteMessage;
public class MessagingService extends FirebaseMessagingService {
@Override
public void onMessageReceived(@NonNull RemoteMessage remoteMessage) {
DigidentityIDK.handleNotification(
this,
remoteMessage,
() -> {
Log.i("MessagingService", "IDK handled remote message.")
},
(DigidentityIDKError error) -> {
Log.e("MessagingService", "IDK could not handle remote message.", error)
},
);
}
@Override
public void onNewToken(@NonNull String newToken) {
DigidentityIDK.handleNewFirebaseToken(newToken);
}
}
After that add the declaration of that service to your manifest file:
<service android:name=".MessagingService">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
Minification setup¶
If using optimisers (ProGuard or R8), add the following lines to your rules:
-keep class com.digidentity.sdk.** { *; }
-keep class com.digidentity.idk.** { *; }
-keep class com.digidentity.bioldsdk.** { *; }
Apps built with AGP 7.1.x or 7.2.x use R8 versions 3.1.x and 3.2.x and they are known to cause runtime crashes in our 3D renderer when optimization is enabled. If using R8 with optimization enabled, please ensure that R8 is version 3.3.70 or higher:
buildscript {
dependencies {
// upgrade R8 as workaround for crash in Digidentity’s 3D rendering code
// (not needed if you are using AGP 7.3.0 or higher)
classpath 'com.android.tools:r8:3.3.75'
}
}
App check¶
To protect backend resources from abuse, the IDK relies on Firebase App Check, which in turn relies on Google Play Integrity. Please refer to the Google documentation to support this function in the mobile app.
Google Play configuration¶
Enable Play Integrity on Google Play Console
- Go to App Integrity, open the Integrity API tab
- Link your app project with Firebase
Firebase configuration¶
The rest of the preparations are done in App Check section of Firebase console
Register your apps to use App Check with the Play Integrity provider:
- Under App Check, open Apps and for each application using IDK do the following:
- Select app and press Play Integrity.
- In the expanded section, attach the SHA hash of your signing certificate.
- Set TTL to 30 minutes.
- Save the changes.
After configuration is completed, IDK will be able to perform App Check. No code changes required.