Getting Started with Android

Register and Create App

Here are the steps you need to follow in order to get started with the App42 platform

  • Register with the App42 platform.
  • Create an App once you are on Quick-start page (after registration)
  • If you are already registered, login to the AppHQ console and create an App from the App Manager -> Create App link
  • Once the App is created, you will get an ApiKey/SecretKey that you will use in your app for initialization of the SDK.
Set up SDK

Here are following 2 options of setting up SDK

  • Option 1: (Recommended) Use App42 Android SDK gradle dependency
  • Option 2: Download App42 Android SDK and setup locally
Option 1: Use App42 Android SDK gradle dependency

Add the following line in your gradle.properties

authToken=jp_n0cr04o1s0as4utq72eqd1o1co

SetUpAndroidJar

Add following code in your project level build.gradle file

allprojects {
    repositories {
        . . .
        . . .
        maven {
            url "https://jitpack.io"
            credentials { username authToken }
        }
    }
}

Add following line in your app level build.gradle file

  dependencies {
    . . .
    . . .
    implementation 'com.github.shephertz:App42_ANDROID_API:4.1.3'
}
Option 2: Download App42 Android SDK and setup locally
  • Download Android SDK
  • Unzip the downloaded Zip file, the unzipped folder contains App42_ANDROID-x.x.jar
  • Put this jar file in your app/libs folder of Android project.
Initialize SDK

You have to pass your ApiKey/SecretKey to initialize the SDK.

App42API.initialize("ANDROID_APPLICATION_CONTEXT","YOUR_API_KEY","YOUR_SECRET_KEY");
Using App42 Services

Once you have initialized your SDK with the API Key/SecretKey you have to build the target service that you want to use in your App. User Service can be built with following snippet. You can build the other services in a similar manner. Want to know about all the services of App42 Platform? Click Here

 //Build User Service  
 UserService userService = App42API.buildUserService();  
 // Using userService reference, you should be able to call all its methods like create user/update user/authenticate etc.  
 //Build Storage Service  
 StorageService storageService = App42API.buildStorageService(); 
 // Using storageService reference, you should be able to call all its methods like insert/save/update/delete etc for JSON objects.  
 //Similarly you can build other services like App42API.buildXXXXService()  

Go To Creating App User for learning App User Management

OR

Go To Saving App Data to learn about App Data Storage.

Set up Campaign SDK
  • After App42 Android SDK set up and Initialization, you could use the Campaign SDK for Marketing Automation.
  • Your previous Unzipped folder and CampaignAPI folder both contain App42_ANDROID-CAMPAIGN_x.x.jar
  • Put this jar file into your libs folder of the Android project in Eclipse as shown below