android

Getting Started

  • 1.

    Integrate SDK:

    Here are some easy steps to integrate App42 SDKs for Android:
  • (a)Download the latest Android SDK from Here.
  • (b)UnZip the downloaded SDK
  • (c) App Creation
  • 1. Register with App42 platform.
  • 2. Create an app once you are on Quick start page after registration.
  • 3. If you are already registered, login to AppHQ console and create an app from App Manager Tab.
  • (d)Android Studio Configuration :-
  • 1. Then add App42_ANDROID_SDK_x.x.x.jar in your libs folder of your application.
  • 2. Add dependency in build.gradle file of your app.
  • dependencies {
            compile fileTree(dir: 'libs', include: ['*.jar'])
    }  
    
  • (g) Eclipse Configuration :-
  • 1. Then add App42_ANDROID_SDK_x.x.x.jar in your libs folder.
  • 2. Put the jar file in class path of your Android project.
  • 2.

    Initialise SDK:

    Your first step is SDK initialization, API and Secret Keys are required for SDK Initialization. You can easily get keys while app creation on AppHQ Dashboard Settings https://apphq.shephertz.com/service#/settings
  • (a)Create Android class that will Extends App42Application (App42Application extends Android Application).
  • (b)Define Application name in AndroidManifest.xml file in application tag.
    android:name="Application Name with fully defined path"  
    
  • (c)Use following code in onCreate function of your class.
    App42API.initialize(ANDROID_APPLICATION_CONTEXT,"API_KEY","SECRET_KEY");
    
  • (d)import following packages if not added.
    import com.shephertz.app42.paas.sdk.android.App42API;
    import com.shephertz.app42.paas.sdk.android.app.App42Application;
    
  • 3.

    Event API Integration:

  • 3.1 Enable Configuration
  • (a)App42 SDK helps you to track application as well as user behaviour of your application.
  • (b)If you want to track User behaviour as well as App behaviour like App Session, please add the following in class you have initialized the SDK.
    App42API.enableAppStateEventTracking(true);  
    
  • 3.2 Tracking Events You can trigger events based on user behaviour or action against your application, also can bind parameters with that event.It will help you in user engagement and remarketing. You can also able to visualize user behaviour on AppHQ dashboard by applying filtration.
    Here is the code snippet you can use :
  • 3.2.1 import statement:
    import com.shephertz.app42.paas.sdk.android.App42API;
    import com.shephertz.app42.paas.sdk.android.App42CallBack;
    import com.shephertz.app42.paas.sdk.android.App42Exception;
    import org.json.JSONObject;
    
  • 3.2.1 Code Snippet API:
    String eventName=”EventName”;
    JSONObject properties=new JSONObject();
    properties.put(“property”,””value”);
    App42API.buildEventService().trackEvent(eventName,properties, new App42CallBack() { 
    			@Override
    			public void onSuccess(Object arg0) {
    						} 
    			@Override
    			public void onException(Exception arg0) {
    							}
    });
    
  • 3.3 Tracking App Activities: You can track user session or user Time with respective to particular application screen. It has been tracked in two parts START and END.
  • 3.3.1 Start Activity:
    Here are the code snippet
    				String activityName=”ActivityName”;
    JSONObject properties=new JSONObject();
    properties.put(“property”,””value”);
    App42API.buildEventService().startActivity(activityName,properties, new App42CallBack() { 
    			@Override
    			public void onSuccess(Object arg0) {
    						}
    @Override
    			public void onException(Exception arg0) {
    							}
    });
    
  • 3.3.2 End Activity:
    Here are the code snippet
    String activityName=”ActivityName”;
    JSONObject properties=new JSONObject();
    properties.put(“property”,””value”);
    App42API.buildEventService().endActivity(activityName,properties, new App42CallBack() { 
    			@Override
    			public void onSuccess(Object arg0) {
    						} 
    			@Override
    			public void onException(Exception arg0) {
    							}
    });
    
  • 4.

    Property Configuration :

    You can associate related properties along with activities, events or with logged in Users. We have divided the properties in 3 different types based on the source as follows:
  • 4.1. Super Properties: These properties are basically related the platform from which the event are triggered such as OS, OS Version, Carrier, Brand Model etc. These are automatically extracted by the SDK and added to the event request before sending it to server.
  • 4.2. Event Properties : These can be event related meta informations which is passed along with the event while triggering as shown above
  • 4.3. User Properties : Any kind of information which you want to associate with a User, can be saved as user properties. It can be used in Email, SMS or Push Personalisation or can help you in uniquely segmenting the group of users to target using campaigns. For example, You can segment user based on their gender, age group, location, profession where gender, age etc. can be saved user properties.
  • 4.3.1. Setting User Properties: Use following API If you want to set user properties first time or you want or reset it.
  • 4.3.2. Updating User Properties: You can update existing user properties as follows:
  • 5.

    In-App Notification:

    In App Notifications are basically UI pop-up those you want to show when user do some action in your application. I can be either offer, confirmation, coupon. These can be easily configure on AppHQ dashboard.

    You can also see effectiveness of these InApp in campaign section of AppHQ dashboard. By seeing analytics you can easily take decision about the use behavior or engagement. And can create in App campaign accordingly.
  • 5.1. Android Studio Configuration: Add app42_ma_library as a module in your Android Application. As library also contains the Android SDK please remove if you have added App42_Android_SDK jar file in libs folder.:
  • 5.2. Eclipse Configuration: import app42_ma_library project in Eclipse IDE and add it as a library project in your Android application. As library also contains the Android SDK please remove if you have added App42_Android_SDK jar file in libs folder.
  • 5.3. Import Statement:
    import com.shephertz.app42.iam.App42CampaignAPI;
    import com.shephertz.app42.iam.ui.InAppListener;
    
  • 5.4. SDK Initialization : Initialize Campaign API:
    App42CampaignAPI.initWithListener(new InAppListener(), 1);
    
  • 5.5. UI Customization: As we are providing inApp as a library project you can also customize default UI as per your requirement. You can change available screen layouts available in res/layout folder of library project. Also can make changes in UI source code available in com.shephertz.app42.iam.ui package of library project.
  • 6.

    Growth Hack Integration:

    Growth Hack API helps to increase your application users by referring application through different applications. It also helps to earn or reward management to those users. You can create Virality Campaign on AppHQ Dashboard, also you can manage the reward points distribution against these campaign.
  • 6.1. AndroidManifest.xml configurations:
    Here are the configuration you need to add in AndroidManifest.xml file.
  • (a) Add App42ViralityReceiver
    
                
                    
                
    
    
    
  • (b) Add ViralityActivity
    
    
    
    
  • 6.2. Referring Action: Do Referrer Action in case application installation at application where you have initialized the SDK. Here is the code snippet.
    App42CampaignAPI.doReferRewardAction(); 
    
  • 6.3. App Sharing: You can use share your application using the sharing widget you have added in your application.Here are the code snippet.
    if (App42CampaignAPI.isViralityAvailable()) {
    			Intent intent = new Intent(this, ViralityActivity.class);
    			startActivity(intent);
    } 
    
  • 6.4. Check Availability: You can also check the availability of Virality Campaign If any, using following API.
    boolean isViralityAvailable=App42CampaignAPI.isViralityAvailable();
    
  • 6.5. Active Campaigns API: You can fetch list of active campaign available for Virality. Here is the code
    ArrayList list=App42CampaignAPI.getActiveViralityCampaigns();
    
  • 6.6. Get User Reward Based on Campaign: You can use following API to get Reward points of user against the Virality campaign.
    App42CampaignAPI.getRewardOfUser(“userName” “virality CampaignName”, new App42CallBack() {			
    			@Override
    			public void onSuccess(Object response) {
    				ArrayList app42Response=(ArrayList) response;
    							} 
    @Override
    			public void onException(Exception ex) {								}
    });  
    
  • 6.7. Redeem Reward Point: YYou can easily redeem reward point earned by User through Virality Campaigns. Here is the API you can use to redeem reward points.
    App42CampaignAPI.redeemRewardForUser(“userName” point.getRewardPoints(), point.getRewardUnit(), point.getCampaignName(), new App42CallBack() {				
    				@Override
    				public void onSuccess(Object response) {
    									}				
    				@Override
    				public void onException(Exception ex) {
    									}
    });
    
  • 7.

    Push Notification :

    Edit Old blog
  • 7.1. Add FCM Configurations
  • 7.2. Push Notification Configurations
  • 7.3. AndroidManifest.xml configurations