Android integration

This guide will walk you through integrating the Mobile Wallet SDK into your Android app.

This guide will walk you through integrating the Mobile Wallet SDK into your Android app.

Step 1: Adding Mobile Wallet SDK to your project

To begin integrating the Saakuru Mobile SDK into your Android application, you need to add the SDK package as a dependency in your project. The SDK package is hosted on Maven Central, making it easy to include in your app using Gradle:

Add the following config to your local properties file:

walletsdk.maven.url=given-by-saakuru  
walletsdk.maven.username=given-by-saakuru  
walletsdk.maven.password=given-by-saakuru\`

sdk.environment=test (test(testnet), stage(mainnet), prod(mainnet))
sdk.mainnet=depending-on-set-environment (false/true)

sdk.api.client.reference=given-by-saakuru
sdk.config.url=your-personal-SDK-configuration-url
sdk.key=given-by-saakuru
sdk.realm=given-by-saakuru
sdk.api.key.phrase=given-by-saakuru

Add the following code to your build.gradle file:

allprojects {  
  repositories {  
    google()  
    jcenter()  
    mavenCentral()  
    maven { url '<https://www.jitpack.io'> }  
    maven {  
      Properties properties = new Properties()  
      try {  
        properties.load(new FileInputStream(rootProject.file('local.properties')))  
      } catch (Exception e) {  
        println("Failed to load local.properties file.")  
      }  
      url properties.getProperty('walletsdk.maven.url')  
      credentials {  
        username = properties.getProperty('walletsdk.maven.username')  
        password = properties.getProperty('walletsdk.maven.password')  
      }  
    }  
  }  
}

Add the following code to your app/build.gradle file

implementation 'io.github.aag-ventures:MetaOneSDK:{version}' (latest ver. 1.8.2)

Add mapping to local.properties key values to your app/build.gradle file:

defaultConfig {  
        Properties properties = new Properties()  
        properties.load(project.rootProject.file('local.properties').newDataInputStream())  
        // M1 SDK auth realm  
        buildConfigField("String", "SDK_REALM", "\"${properties["sdk.realm"]}\"")  
        // M1 SDK environment (dev, test, stage, prod)  
        buildConfigField("String", "SDK_ENVIRONMENT", "\"${properties["sdk.environment"]}\"")  
        // Wallet SDK Key (provided by AAG)  
        buildConfigField("String", "SDK_KEY", "\"${properties["sdk.key"]}\"")  
        // Client config url  
        buildConfigField("String", "SDK_CONFIG_URL", "\"${properties["sdk.config.url"]}\"")  
        // Client reference for API (provided by AAG)  
        buildConfigField("String", "SDK_API_CLIENT_REFERENCE", "\"${properties["sdk.api.client.reference"]}\"")  
        // Client Key Phrase for API  
        buildConfigField("String", "SDK_API_KEY_PHRASE", "\"${properties["sdk.api.key.phrase"]}\"")  
}

Step 2: Initializing SDK

Initialize MetaOneSDKManager instance: metaOneSDKManager = new MetaOneSDKManager(this);

Map your BuildConfig values to sdkConfig object:

SDKConfig sdkConfig = new SDKConfig(BuildConfig.SDK_REALM, BuildConfig.SDK_ENVIRONMENT, BuildConfig.SDK_KEY, BuildConfig.SDK_CONFIG_URL, BuildConfig.SDK_API_CLIENT_REFERENCE, VERSION);

Initialize MetaOne SDK:

metaOneSDKManager.initialize(sdkConfig)

Step 3: Creating a User Session

To successfully initialize a user session, your back-end integration has to be ready first. Your backend should receive an Authorization token during the initialization request.

Initialize the session by calling:

metaOneSDKManager.login(token, this, callback)

Your session is initialized. You can now use all other functions that require Authorization

Call metaOneSDKManager.setupUserData() to initialize user profile data

Demo app project https://github.com/AAG-Ventures/android-sdk-demo

Last updated