Skip to content

Getting started

Jóhannes Erlingsson edited this page May 15, 2017 · 1 revision

There are a few important steps to get out of the way when integrating the Meniga SDK with your app for the first time. Follow these instructions carefully to ensure that you will have a smooth development experience.

Meniga SDK Setup

The Meniga SDK is hosted in a Maven repository for which you need a user name and password (provided by Meniga). To make sure it works correctly inspect "maven" under "repositories" in your gradle file, it should look like this:

maven {
  url 'http://mobiledev.meniga.com/artifactory/[CUSTOMER NAME]/'
  credentials {
    username '[YOUR USER NAME]'
    password '[YOUR PASSWORD]'
  }
}

To import the SDK make sure you have the following line in "dependencies" (the x stand for different version numbers):

compile 'com.meniga:sdk:x.x.xx'

Add the necessary permissions to the AndroidManifest.xml file

<!-- REQUIRED for Meniga SDK -->
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

To import files for use you simply import them like any other object, here's an example for MenigaTransaction

import com.meniga.sdk.businessobjects.MenigaTransaction;

Initalize the Meniga SDK

The Meniga SDK requires only a single entry point in the application. To start, create a class that extends Application and set the name of the class for the application entry in the AndroidManifest.xml. Then overrite the applications onCreate call to call Meniga.settings().init(context, MenigaSettings) with the oppropriate MenigaSettings class instance

@Override
public void onCreate() {
	MenigaSettings settings = new MenigaSettings.Builder()
				.endpoint(BuildConfig.API_BASE_URL)
				.authenticationProvider(authProvider)
				.persistanceProvider(new CachePersistanceProvider())
				.addHttpInterceptor(new MenigaHttpLogger("Bank42", LogLevel.INFO, LogType.BODY_AND_HEADERS))
				.addEndpointForService(Service.OFFERS, BuildConfig.API_OFFERS_URL)
				.timeout(60000)
				.build();
    MenigaSDK.init(this, settings);
}

The following items can be configured through the MenigaSettings class

  • endpoint: String or MenigaSettings, the base url of the server.
  • authenticationProvider: Instance of a class that implements the AuthenticationProvider interface.
  • persistanceProvider: Instance of a class that implements the PersistenceProvider interface for chaching/persisting data.
  • addEndpointForService: Specifies a different endpoint url for specific services. Here for example the Offers service uses a different endpoint than the rest of the services.
  • addHttpInterceptor: A way to add a custom OkHttp interceptor. Takes any class that implements the okHttp3.Interceptor interface. Here it is taking the default Meniga logger in for logging requests and responses.