Skip to content

Latest commit

 

History

History
185 lines (134 loc) · 5.13 KB

getting-started.adoc

File metadata and controls

185 lines (134 loc) · 5.13 KB

Getting Started with Aerobase Services Android SDK

Following guide provides general information for starting with Aerobase Services SDK.

Prerequisites

You will need the following installed on your system

  • Android SDK or Android Studio from Google

It is recommended you have the following installed

Using a Published SDK

jcenter()

To use a published version of the SDK you have to add jcenter to the build.grade file in your project’s root directory

allprojects {
    repositories {
        jcenter() // <-- Add This line
        google()
    }
}

Reference the Dependencies

In the build.gradle file of your app you can begin adding dependencies provided by the SDK.

dependencies {
    ...
    implementation 'org.aerobase:android-core:0.1.0-RELEASE'
    implementation 'org.aerobase:android-auth:0.1.0-RELEASE' // <- adjust to suit release version
}

A full list of releases can be viewed here

Installing Local Build of SDK

Alternatively the SDK can be installed manually instead of using a published version.

Clone and build the library

git clone https://github.com/aerobase/aerobase-android-sdk
cd aerbase-android-sdk
./gradlew install

You can verify the install went well by checking your local maven repository

ls ~/.m2/repository/org/aerobase

# Should output auth core

MavenLocal()

If you are using a build of the SDK from source you will need to add mavenLocal() to the build.gradle file in your project’s root directory.

allprojects {
    repositories {
        mavenLocal() // <-- Add This line
        google()
        jcenter()
    }
}

Reference the Dependencies

In the build.gradle file of your app you can begin adding dependencies provided by the SDK.

dependencies {
    ...
    implementation 'org.aerobase:android-core:0.1.0-SNAPSHOT'
    implementation 'org.aerogear:android-auth:0.1.0-SNAPSHOT' //If you are using IDM services provided by KeyCloak
}

Using the SDK

In an example you can use the SDK as follows

...
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        PushService pushService = MobileCore.getInstance().getService(PushService.class);
        pushService.registerDevice(new Callback() {
            @Override
            public void onSuccess() {
                MobileCore.getLogger().info("AB", "Successfully registered device to aerobase server");
            }

            @Override
            public void onError(Throwable error) {
                new AppExecutors().mainThread().execute(() -> {
                    MobileCore.getLogger().error("AB", error.getMessage(), error);
                });
            }
        });
    }
...

Bill of materials

Our project provides a BOM artifact to lock the dependencies (direct and transitive) down to known compatible versions. Gradle itself does not offer such a mechanism but it is a well known and used concept in the Maven world (see Dependency Management ).

In order to bring this functionality to Gradle the Android SDK relies on the dependency management plugin provided by Spring. This plugin allows us to use a standard Maven BOM in a Gradle project.

Setting up project to use any Aerobase Services SDK

  1. Add gradle plugin to At the top of your gradle build file (but below buildscripts) add the plugin itself:

plugins {
    id "io.spring.dependency-management" version "1.0.4.RELEASE"
}
  1. Import bom plugin into your gradle config Add following code before your dependencies add the dependencyManagement section that refers to our BOM:

dependencyManagement {
    imports {
        mavenBom 'org.jboss.aerogear:aerogear-android-sdk-bom:1.1.10'
    }
}
  1. In case your project contains multiple modules you need to apply this to all your subprojects. Make sure to apply the previous steps to your parent modules build.gradle and wrap the dependencyManagement section as follows:

subprojects {
    apply plugin: 'io.spring.dependency-management'

    dependencyManagement {
        imports {
            mavenBom 'org.jboss.aerogear:aerogear-android-sdk-bom:1.1.10'
        }
    }
}
  1. After applying this changes developers can import the dependencies that are listed in the BOM without specifying a version:

dependencies {
    implementation group: 'org.aerobase', name: 'core'
}

Importing individual SDK

Please follow individual SDK’s documentation to see how to add them to the project

Certificate Pinning

To implement certificate pinning in the individual SDKs, see the certificate pinning guide.