Android Integration

Why use EMMA SDK in your App?

Download and basic integration

Acquisition Integration

Behavior Integration

Push Notifications Integration

Messaging Integration

Depurando el código

 

Why use EMMA SDK in your App?

EMMA SDK offers an unique functionality with the whole user tracking of your App. We have developed a robust, secure and light SDK with more than 2.000 Millions of installs until the day. And, of course, easy to be integrated. 

 EMMA_1.png

EMMA can track the install origin (including Facebook, Twitter & Google), sessions, user events, location, ... with a powerful segmentation unit to evaluate the ROI and your user retention engaging them thanks to our communication tools, Push and In-app Messaging. 

EMMA Android SDK is compatible with all Android devices.

 

Download and basic integration

Android SDK Download

You can download and install EMMA through Gradle.

Use Gradle to download. 

If you are using Gradle's dependency management, you can integrate easily SDK :

  1. Add to /app/build.gradle file repository in which is EMMA.
    repositories {
        maven { url 'http://repo.emma.io/emma' }
    }

  2. Add dependency on the same .gradle file.
    dependencies {
        compile 'io.emma:eMMaSDK:4.+'
    }
  3. If your app already has the com.google.android.gms:playservices package, you can use your App's dependency and exclude EMMA's dependency.
    compile ('io.emma:eMMaSDK:4.+') {
        exclude group: 'com.google.android.gms'
    }
  4. Finally, compile the project with Gradle.

 

Permisos and EMMA SESSION KEY

Edit AndroidManifest.xml. Permissions required are:

  • android.permission.INTERNET
  • android.permission.ACCESS_NETWORK_STATE
  • android.permission.READ_PHONE_STATE
  • com.google.android.c2dm.permission.RECEIVE

Is needed permission for Android Advertising ID too:

  • <meta-data android:name="com.google.android.gms.version android:value="@integer/google_play_services_version" />

Optional permissions:

  • android.permission.ACCESS_COARSE_LOCATION or
  • android.permission.ACCESS_FINE_LOCATION

Add your EMMA SESSION_KEY to AndroidManifest.xml, add to application element

<meta-data android:name="io.emma.SESSION_KEY" android:value="@string/emma_session_key" />

And in file res/strings.xml add into resources:

<string name="emma_session_key">YOUR_EMMA_SESSION_KEY</string>

You can get your EMMA Session_Key following this instructions

 

Running the SDK & Install Event (Minimum Requirement)

In your Application class, import EMMA:

import com.emma.android.eMMa;

In your application onCreate() method add the following call:

eMMa.startEMMASession(this); 

Optional

In some cases, It is necessary to change the API EMMA URL (e.g proxies), this requires add the next method before starteMMaSession(...):  

eMMa.setAPIeMMaURL("https://www.your_proxy_url.com/");

 

Activate Install Referrer

When directing a user to Google Play, the install referrer can be used for 100% tracking accuracy. Your app MUST be setup to allow our SDK to collect the install referrer value and enable the source of the application install to be recorded and associated with future users.

Android will fire an intent called: com.android.vending. INSTALL_REFERRER during the application install process. This occurs before the application is launched for the first time. To capture the relevant information:

Add the eMMaReferralReceiver broadcast receiver to yout AndroidManifest.xml:

<receiver android:name="com.emma.android.eMMaReferralReceiver" android:exported="true">
<intent-filter>
<action android:name="com.android.vending.INSTALL_REFERRER"/>
</intent-filter>
</receiver>
</application>

If you are using your own receiver, perform the following steps:  

Register the following intent in your broadcast receiver:

<intent-filter>
<action android:name="com.android.vending.INSTALL_REFERRER"/>
</intent-filter>

In the onReceive of your receiver class, add the following code:

if (intent.getAction().equals("com.android.vending.INSTALL_REFERRER")) {
eMMaReferralReceiver eMMaReceiver = new eMMaReferralReceiver();
eMMaReceiver.onReceive(context, intent);
}

eMMaInstallsBroadcastReceiver

From version 2.5 it includes the eMMaInstallsBroadcastReceiver that allows more than one receiver with com.android.vending.INSTALL_REFERRER action. If the receiver is used you will not have to create an own as explained above. The receiver must be declared as the first receiver of AndroidManifest.xml.

<receiver android:name="com.emma.android.eMMaInstallsBroadcastReceiver" android:exported="false">
    <intent-filter>
       <action android:name="com.android.vending.INSTALL_REFERRER" />
    </intent-filter>
</receiver>

Note: If you are using the Multiple Install BroadcastReceiver of Appsflyer will not need to use the previous receiver.

 

Deploy your App to Google Play

Now you are ready to start tracking with EMMA!

Continue with the advanced integration if you want to extend the EMMA metrics and features.  

*Except Facebook App Installs and Twitter App Promotion

 

Update to version 4.0

When upgrade to version 4.0, is mandatory do some minor changes.

Changes in EMMA Session_Key

Initalization method with Session_Key is deprecated.

eMMa.starteMMaSession(this, SESSION_KEY);

Instead, Session_Key must be added to AndroidManifest.xml, you can continue to use the same Session_Key you don't need create a new one.

Edit AndroidManifest.xml, add into application elemente

<meta-data android:name="io.emma.SESSION_KEY" android:value="@string/emma_session_key" />

And in file res/strings.xml add into resources:

<string name="emma_session_key">YOUR_EMMA_SESSION_KEY</string>

Finally, change initialization by new method.

eMMa.startEMMASession(this);

Changes in tracking events

It is deprecated the method:

eMMa.trackEvent(Context ctx, String event);

Now, you don't need include a context for track events, replace all uses of deprecated method by new one:

eMMa.trackEvent(String event);

 

Acquisition Integration

In the Acquisition section you can have the data of all your campaigns managed with EMMA

Here is the specific documentation so you can manage with EMMA your Facebook and Twitter campaigns and also the detailed documentation to integrate the Powlink functionality.

 

Tracking Facebook App Installs and Twitter App Promotion

EMMA is 100% integrated with Facebook and Twitter for tracking via AppsFlyer. You will be able to track all the App Installs sources in our Dashboard with no need to integrate Facebook or Twitter SDKs.

Add the following: (available here)

  • Add AF-Android-SDK.jar

You need to modify your AndroidManifest.xml file and set a Receiver. Please, modify your AndroidManifest.xml to look like this:

**************** Referral for Facebook and Twitter
<receiver android:name="com.appsflyer.MultipleInstallBroadcastReceiver" android:exported="true">
<intent-filter>
<action android:name="com.android.vending.INSTALL_REFERRER" />
</intent-filter>
</receiver>
**************** Current eMMa referral
<receiver android:name="com.emma.android.eMMaReferralReceiver" android:exported="true">
<intent-filter>
<action android:name="com.android.vending.INSTALL_REFERRER"/>
</intent-filter>
</receiver>

PLEASE MAKE SURE THE RECEIVER TAG IS WITHIN THE APPLICATION TAG

You need to initialize the SDK on the application’s first launch. Please make sure the SDK is initialized before sending the tracking events below.

AppsFlyerLib.setAppsFlyerKey(@"EMMASOCIALKEY");

Add the following line to the main activity’s onCreate.

AppsFlyerLib.sendTracking(getApplicationContext());

In order to track app sessions (opens), please make sure to call this API upon every app session

The EMMA Social Key you have to introduce is the ID to follow the Facebook and Twitter campaigns.

To get the EMMA Social Key you have to follow these steps: 

1.  Login EMMA website and go to My Account > Configuration > Edit app.

EMMA_2.png

2.  Go to Media Source Settings and fill the App information:  

EMMA_3.png 

To get the App Store ID you can copy the ID of the AppStore link, like this example:

EMMA_4.png

To get Google Play ID you can copy the ID of the GooglePlay link, like this example:

EMMA_5.png

To get the Facebook App ID visit this article to know how to do it. 

4.  Select the Submit option to keep the changes. 

5.  Send a email to support@emma.io and we will send you the EMMA Social Key.

6. If everything is set up correctly, you will find the Facebook and Twitter campaigns in the Acquisition > AppTracker. Once you start to run the campaigns, the data will automatically enter in EMMA.

EMMA_6.png

 

 

Powlink Integration

To support the Powlink on Android, first of all you need to configure in the EMMA dashboard the subdomain in powlink.io that your app will use, and cover the data of the Google Play ID and the certificate Fingerprint with which you must sign your app in SHA256 format. You can configure this in My Account in the Media Source Settings section of your app. 

EMMA_7.png

Once you know the subdomain of your Powlinks, you have to add a new filter to the AndroidManifest.xml of your app:

<activity ...>
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="https" android:host="mysubdomain.powlink.io" />
</intent-filter>
</activity>

In the method onCreate, you can manage the receive Powlinks to process them and show the corresponding section of your app:

protected void onCreate(Bundle savedInstanceState) {
//Your stuff

Intent deeplink = getIntent();
String action = deeplink.getAction();
if (action == "android.intent.action.VIEW") {
Uri data = deeplink.getData();
//Process data. Manage Powlink path
}
}

 

 

Behavior Integration

With EMMA you can do a complete integration of the SDK that allows you to know the location of your uses, how they register in the App, how many transactions they do and even their own characteristics. You will obtain all the information about your users in the Behavior section.

The following articles specify the integration of the measurement of each of these aspects:

 

Tracking Events  

In the EMMA platform you have the option to measure between two types of events. Those that the platform includes by default and the Custom events that you want to integrate according to the structure of your application.

Default Events

The EMMA default events allow you to know the Leads (registered users outside the app, old registers and any tags that you want to link to a user in order to be able to create custom segments) and the Login (users that have logged in the App through an existing mail or through some social platform).

Follow these steps to do this integration:

User's Sign Up

eMMa.registerUserID(this, userId, mail);

RegisterUser set a complete registration from device on EMMA database for a userId (String) and email (String).

User's Login 

eMMa.loginUserID(this, userId, mail);

LoginUser logs the user on EMMA database for a userId (String) and email (String). When logged you can use eMMa.loginDefault(this); to log another sign in for the user with the same data.

Custom Events

With EMMA you can measure every user action like a custom event: 

eMMa.trackEvent(String event);

Use trackEvent to count the number of times certain events happen during a session of your application. This can be useful for measuring how often users perform various actions or create custom segments on EMMA dashboard.

Events must be created in EMMA dashboard and use the EVENT_TOKEN with the trackEvent method. If you send an event_token wich not exists, EMMA returns an error.

Your application is currently limited to counting occurrences for 30 different event ids.

Marked as deprecated:

eMMa.trackEvent(Context ctx, String event);

Tracking transactions

EMMA allows you to track every purchase that you make in your mCommerce.

Start Order 

startOrder(Activity ctx, String orderId, String customerId, float totalPrice, String coupon, Map<String,String> extras, String currencyCode);

Starts an order for adding products. You can pass the following parameters:

  • ctx: Activity object.
orderID

: String with your order id

customerId

: String with your Customer ID. If not passed, EMMA will use the logged one (if exists).

totalPrice

: Float with your total price.

coupon

: String with your coupon if needed.

extras

: Map with until 20 extra parameters, like currency, category…

currencyCode

: String with valid Currency Code (EUR,USD,..) If the currency code is not valid EUR currency will be taken

You can use abbreviated methods if you don’t need all parameters, you can find them at the end of the document or in eMMa.jar.

Add products to the order 

addProduct(String productId, String name, float qty, float price, Map<String,String> extras);

Adds products to your current started order. Always startOrder should be called before. You can pass the following parameters: You can pass the following parameters:

productId

: String with your product id.

name

: String with your product name.

qty

: Float with your product qty.

price 

: Float with product price.

extras

: Map with until 20 extra parameters, category, …

Track Order

trackOrder(Activity ctx);

Track the current order. It should be called after startOrder and after being all cart products added.

The sequence of tracking order in EMMA is always

startOrder>addProduct(*distinct products)>trackOrder

Cancel Order

cancelOrder(Activity ctx, String orderId);

Cancel the order referenced by an order id. If your e-commerce allows canceling orders this method updates the purchases data with the cancelled orders.

 

Tracking User Tags

Track User's Extra Info

eMMa.trackExtraUserInfo(this, extras);

This method update or add extra parameters for current logged user in order to have a better segmentation data. It can be used anywhere.

If you want to use the EMMA RULE On his Birthday send us the date of the user birthday with the following format: 

Name: BIRTHDAY

Value: YYYY-MM-DD

 

Tracking location

If your application has location permissions, EMMA will track where your application is being used.

To disable detailed location reporting even when your app has permission, call eMMa.disableReportLocation() before calling eMMa.starteMMaSession() and no detailed location information will be sent.

 

Get User Info

Get User ID

eMMa.getUserID(Context ctx);

This method will return the user’s EMMA ID. This ID is unique for each user and can be used to filter when using mobactions push, start view and dynamic tags.

Your Activity has to implement the interface eMMaUserInfoInterface and the method OnGetUserID(int id) that will be called when the id of the user is available.

Get User Info

eMMa.getUserInfo(Context ctx);

This method will return the user’s info on EMMAa in JSON format.

Your Activity has to implement the interface eMMaUserInfoInterface and the method OnGetUserInfo(JSONObject json) that will be called when the information of the user is available.

The JSON will include the following parameters:

 

id The same ID than previous method (eMMa.getUserID)
udid Unique ID per app installation
emma_build EMMA version"]">Build identifier of the current EMMA version
email Email of the user in case that register or login methods are implemented
customerid Id of the user returned by register and login methods if exists
created_at When the user was created
updated_at Last time user updated its info
registred_at When user got registered on app (if register method is implemented)
fisrt_login When user got logged on app for first time (if login method is implemented)
last_login When user got logged on app for last time (if login method is implemented and it’s allowed to the user make more than one login)
device User’s device
app_version  Version of the app
os_version  Version of the Operate System
rated If user has rated the app
token Push token
inactive If user has deactivated the push service
latitude  User's latitude in case geolocation is activated
longitude  User's longitude in case geolocation is activated
emma_city  User's city in case geolocation is activated
emma_country  User's country in case geolocation is activated
emma_state  User's statate in case geolocation is activated
emma_device_id Unique device ID
emma_referrer_id ID of the campaign that user came from (if AppTracker is used)
loyal_user_at When the user became loyal
loyal_buy_at When the user became a loyal buyer
emma_num_sessions User’s num session
last_session_at User’s last session
tag_name Name and value of all the custom tags of the user

Also, if the user came from a Facebook campaign, we include the following parameters:

eat_sub1 App Name
eat_sub2 "facebook" (Fixed value)
eat_sub3 "Facebook's Campaign" (Fixed value)
eat_sub4 "cpi" (Fixed value)
eat_sub5 Facebook campaign name
eat_sub6 Facebook campaign ID
eat_sub7 Facebook adgroup name
eat_sub8 Facebook adgroup ID
eat_sub9 Facebook adset name
eat_sub10 Facebook adset ID

In case of user came from AppTracker, the JSON may include following custom parameters.

To use this method you need to buy the Raw Export feature in My Account > My Plan

 

Push Notifications integration

EMMA allows you to add a very powerful notification system easy to integrate using the Google Cloud Messaging for Android (GCM).

Also allows you to send info through notifications and do whatever you want inside your app with it.

Please obtain your own Project Number and API key for the GCM as explained this post, and set these parameters for the app in your EMMA account.

IMPORTANT: Use the Server API Key for GCM, not the Browser nor the Simple API Access.

In your application, you need to configure the AndroidManifest.xml.

Required Permissions:

<permission android:name=”your.own.package.permission.C2D_MESSAGE”
android:protectionLevel=”signature” />
<uses-permission android:name=”your.own.package.permission.C2D_MESSAGE” />
<uses-permission android:name=”com.google.android.c2dm.permission.RECEIVE” />
<uses-permission android:name=”android.permission.GET_ACCOUNTS” />
<uses-permission android:name=”android.permission.VIBRATE” />
<uses-permission android:name=”android.permission.WAKE_LOCK” />

Also, we have to indicate the EMMA service and receiver that will manage the notification:

<service android:name=”com.emma.android.eMMaGCMReceiver” />
<receiver
android:name=”com.emma.android.GCMBroadcastReceiver”
android:permission=”com.google.android.c2dm.permission.SEND”>
<intent-filter>
<action android:name=”com.google.android.c2dm.intent.REGISTRATION”/>
<action android:name=”com.google.android.c2dm.intent.RECEIVE”/>
<category android:name=”your.own.package” />
</intent-filter>
</receiver>
</application>

eMMaPushBroadcastReceiver is the responsible for tracking the open in push notifications

<receiver android:name="com.emma.android.eMMaPushBroadcastReceiver" android:exported="false">
<intent-filter>
<action android:name="your.own.package.PUSH_OPEN"/>
</intent-filter>
</receiver>

EMMA Android SDK Push system has changed. Now it is not called on your activity, it is called on your Application object.

Call the method below in your Application onCreate() method after starting EMMA session:

eMMa.starteMMaSession(this, "EMMA_KEY");
....
eMMa.startPushSystem(this, MainActivity.class,R.drawable.icon,true);
ctx

: Context object (Application).

activity

: Activity you want to be opened when push is received.

icon

: (Optional) The resource id of the image you want to show with the notification. If no icon is specified, the notification will use the application icon.

customDialog

: (Optional) Set to true if you want to use your custom dialog.

Override the Activity’s onNewIntent() method calling to eMMa.onNewNotification() that will check if the user has received a notification and treat it.

@Override
public void onNewIntent(Intent intent) {
super.onNewIntent(intent);
eMMa.onNewNotification(this, intent, true);
}

Note: onNewNotification has a boolean parameter that checks if notification push contains a Rich Push Url.

For check Rich Push Url when app is opened through push notification:

public class YOUR_ACTIVITY extends Activity implements eMMaNotificationInterface, eMMaWebViewInterface {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
eMMa.checkForRichPushUrl(this);
}

Note: richPushUrl can be used in any part of app.

If your application is WebView-based, you have to add the checkForRichPushUrl in the next method:

webView.setWebViewClient(new WebViewClient(){
.........
@Override
public void onPageFinished(new WebViewClient() {
   eMMa.checkForRichPushUrl(this);
}});

Optionally, if you want to control what you receive from push, your Activity has to implement the interface eMMaNotificationInterface and the methods pushTag(String pushTag) and pushMessage(String message) that will be called when the user opens the notification (even if you don’t set a pushTag in the EMMA dashboard). You can also declare if you want to show the EMMA Dialog or your own custom Dialog.

@Override
public void pushTag(String pushTag) {
//Do whatever you want with pushTag
}

 

@Override
public void pushMessage(String message) {
//Create your own dialog with the push message
}
}

To disable notifications from a device, use eMMa.unregisterPushService(context) and be sure not to call startPushSystem again.

You can use abbreviated methods if you don’t need all parameters, you can find them here.

Rich Push, custom sounds in push notifications. Required SDK version 2.5.5 or later

You need to add your sound files into the raw folder of your app's res folder. Remember use the same name for sound files in iOS and Android.

Rich Push URL uso DeepLinking

You can redirect your push notifications openings a section into your app. For that you can use a structure like this

scheme://host/page1/page2/page3

In order to make your app available to receive a scheme deep link:

1) Add the following code into your AndroidManifest.xml:

<activity android:name=".YOUR_PUSH_ACTIVITY"
      android:launchMode="singleTask">
       <intent-filter>
          <action android:name="android.intent.action.VIEW" />
          <category android:name="android.intent.category.DEFAULT"/>
          <category android:name="android.intent.category.BROWSABLE"/>
          <data android:scheme="YOUR_SCHEME"
                   android:host="YOUR_HOST"/>
        </intent-filter>
</activity>

2) Into the activity defined as push activity (YOUR_PUSH_ACTIVITY), you can follow this example to capture the deep link:

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

       eMMa.checkForRichPushUrl(this);

        if (getIntent() != null && getIntent().getData() != null){
            openDeeplinkActivity(getIntent().getData());
        }

   } private void openDeeplinkActivity(Uri uri){
       Intent intent = new Intent(this, DeepLinkActivity.class);
       if (uri != null){
           intent.putExtra(DeepLinkActivity.URL_TAG, uri.toString());
       }
       startActivity(intent);
   }

   @Override
   public void onNewIntent(Intent intent){
       openDeeplinkActivity(intent.getData());
   }

Adding this method into the activity, you could get the push deep link when the app is opened:

@Override
   public void onNewIntent(Intent intent){
       openDeeplinkActivity(intent.getData());
   }

This conditional into the onCreate allows you get the deep link after open the app through the push:

if (getIntent() != null && getIntent().getData() != null){
    openDeeplinkActivity(getIntent().getData());
}

IMPORTANT: When you create the API Key in Google Developers Console, you must add the IP address 52.48.24.86 and 5.9.147.231 corresponding with own push server.

EMMA_8.png 

 

 You must add the Google API: Google Cloud Messaging.

EMMA_9.png


Now, Google binds the push notifications with Firebase. Click button "First steps".

EMMA_10.png

Import Google Project to Firebase.

EMMA_11.png

Select the project and add it.

EMMA_12.png

Once time you have the project added, you API Key is enabled.

 

Messaging Integration

Messaging includes six different communicative formats that you can integrate to impact your users:

In many of these communicative formats you can delete the redirection url's that you want to introduce. With the EMMA Whitelist functionality you can define what content you want to be displayed in the scheduled webviews.  

 

Using EMMA Banner 

EMMA Banner lets you show a banner on your app with promotional info. The banner will be shown and hidden depending on your dashboard configuration. If you press the banner a web view with HTML content will be shown.

EMMA_13.png

In order to allow them in your app you need at least implement the first method. The bannerInterface (eMMaBannerInterface) is a callback that executes when the banner is displayed or when no banners available.

Check Banner

eMMa.checkForBanner(context, bannerInterface);

Use checkForBanner in order to check if show Banner added on EMMA dashboard. Use the Activity where you want to show the Banner as context.

Banner with label

eMMa.checkForBanner(context, labelString, bannerInterface);

Use checkForBanner in order to check if show Banner added on EMMA dashboard. Use the Activity where you want to show the Banner as context. If you want you can pass a custom String that labels the Banner in case you use more than one Banner on your app and you need to distinguish them.

Banner with custom close button

eMMa.checkForBanner(context, closeButton, bannerInterface);

Use checkForBanner in order to check if the shown Banner added on EMMA dashboard. Use the Activity where you want to show the Banner as context. If you want you can pass a custom Button for using it on the webview.

Banner with margins

eMMa.checkForBanner(context, labelString, topMarginY, bottomMarginY, bannerInterface);

Use checkForBanner in order to check if the shown Banner added on EMMA dashboard. You can set different margins for the banner in case you want to leave some space at the bottom (for banners configured at the button of the screen) or top (for banners configured at the top of the screen) of the banner.

Banner with interface

eMMa.checkForBanner(context, myButton, myLabel, myParams, myWebviewInterface, topMarginY, bottomMarginY, bannerInterface);

Use checkForAdBall in order to check if the shown Banner added on EMMA dashboard. If you want to track which URL is currently displayed in the webview and which links are pressed by the user, you can pass as a parameter a class that implements the interface  “eMMaWebViewInterface” and its “oneMMaWebviewClick(String url)” method, to receive the url String each time a new one is loaded.

Close Banner

eMMa.closeBanner();

Use closeBanner in case you want to remove your last Banner manually. It will return true when there’s a Banner to close, false otherwise.

Extra: You can use a mixture of this methods in order to pass more parameters. See appendix with all EMMA header options.

 

Using EMMA Startview 

EMMA StartView lets you show HTML info on your app startup via a web view.

EMMA_14.png

In order to allow them in your app, you need to call first the starteMMaSession method.

checkForWebview(Context ctx);

StartView will be presented in the root element and you can use it in the activity’s onCreate() method to show it the first time, in the onResume() to show it every time the activity resumes, or whenever you want.

Check WebView

Use checkForWebview in order to check if show StartView added on EMMA dashboard and show it automatically:

eMMa.checkForWebview(this);

StartView with close button

Use checkForWebview in order to check if show StartView added on EMMA dashboard and show it automatically. If you want you can pass a custom Button for using it on the web view.

eMMa.checkForWebview(this, myButton);

StartView with params

Use checkForWebview in order to check if show StartView added on EMMA dashboard and show it automatically. If you want you can pass a Map<String,String> of parameters (key-value pair) that will append to the URL as GET parameters. This is useful in case that you need to pass some data from the app to a StartView with a landing page.

eMMa.checkForWebview(this, myParams);

StartView with label

Use checkForWebview in order to check if show StartView added on EMMA dashboard and show it automatically. If you want you can pass a String that labels the StartView in case you use more than one StartViews on your app and you need to distinguish between them.

eMMa.checkForWebview(this, myLabel);

StartView with inference

eMMa.checkForWebview(this, myButton, myLabel, myParams, myWebviewInterface);

Use checkForWebview in order to check if show Promotion web views added on EMMA dashboard. If you want to track which URL is currently displayed and which links are pressed by the user, you can pass as a parameter a class that implements the interface  “eMMaWebViewInterface” and its “oneMMaWebviewClick(String url)” method to receive the url String each time a new one is loaded.

public class MyClass implements eMMaWebViewInterface {
@Override
public void oneMMaWebviewClick(String url) {
}
}

Close StartView

eMMa.closeWebview();

Close the StartView if shown. This method is useful if user makes a redirect click and you want that the StartView close itself without pressing close button.

Extra: You can use a mixture of this methods in order to pass more parameters. See appendix with all EMMA header options.

 

Using EMMA Adball 

EMMA AdBall lets you show an AdBall Icon on your app that you can move freely around the app view and also hide it. If you press the AdBall a popup with HTML content will be shown.

EMMA_15.png

 In order to allow them in your app you need at least implement the first method.

Check AdBall

eMMa.checkForAdBall(context);

Use checkForAdBall in order to check if show AdBalls added on EMMA dashboard. Use the Activity where you want to show the Adball as context.

AdBall with label

eMMa.checkForAdBall(context, labelString);

Use checkForAdBall in order to check if show AdBalls added on EMMA a dashboard. Use the Activity where you want to show the Adball as context. If you want you can pass a custom String that labels the AdBall in case you use more than one AdBalls on your app and you need to distinguish between them.

AdBall with params

eMMa.checkForAdBall(context, myParams);

Use checkForAdBall in order to check if show AdBalls added on EMMA dashboard. If you want you can pass a Map<String,String> of parameters (key-value pair) that will append to the URL as GET parameters. This is useful in case that you need to pass some data from the app to the AdBall webview.

AdBall with inference

eMMa.checkForAdBall(context, myLabel, myParams, myWebviewInterface);

Use checkForAdBall in order to check if show Adballs added on EMMA dashboard. If you want to track which URL is currently displayed in the webview and which links are pressed by the user, you can pass as a parameter a class that implements the interface  “eMMaWebViewInterface” and its “oneMMaWebviewClick(String url)” method, to receive the url String each time a new one is loaded.

Close AdBall

eMMa.closeAdBall();

Use closeAdBall in case you want to remove your last AdBall manually. It will return true when there’s an AdBall to close, false otherwise.

Extra: You can use a mixture of this methods in order to pass more parameters. See appendix with all EMMA header options.

 

Using EMMA Dynamic Tab

EMMA Dynamic Tab lets you show HTML info on your app in a new app section (Only if you use a TabHost or Tabs in the ActionBar of your app).

EMMA_16.png

 If you are using a TabHost with Activities:

checkForPromoOnTabHost(Context ctx, TabHost mTabHost, TabSpec mTabSpec,
Map<String,String> params);

Use checkForPromoOnTabHost in order to check if show Dynamic Tab added on EMMA dashboard and add it automatically. You can pass the following parameters:

ctx:

Context object.

mTabHost:

TabHost where you want to put your new section.

mTabSpec:

(Optional) TabSpec for customize your new section

params:

(Optional) Map of parameters (key-value pair) that will append to the URL as a GET parameters. This is useful in case that you need to pass some data from the app to the webview showed.

Extra: You can use abbreviated methods if you don’t need all parameters. See appendix with all eMMa header options.

New and important: The title and image of the new tab can be specified via web on EMMA platform. If it is specified, the web configuration will prevail over local configuration. On Android versions > 3, the image of the tab is no longer supported.

Add the Activity eMMaTabWebView to your AndroidManifest.xml:

.
.
.
android:label="eMMaPromoTab">

If you are using a TabHost with Fragments or Tabs in the ActionBar:

checkForPromoFragment(eMMaPromoFragmentInterface context);

Use checkForPromoFragment in order to check if show Dynamic Tab added on EMMA dashboard. If added, it will call to the eMMaPromoFragmentInterface’s onAddeMMaTab(String url, String title, String imageUrl) method, that you should implement adding the Fragment to your TabManager or TabListener (just like the other Fragments).

To create this Fragment you can add to your project the eMMaFragmentWebView class, and pass it the url given.

public class Main extends FragmentActivity implements eMMaPromoFragmentInterface {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
eMMa.starteMMaSession(this, "YOURSESSIONKEY");
eMMa.checkForPromoFragment(this);
.
.
.
}
@Override
public void onAddeMMaTab(String url, String title, String imageUrl) {
/* Use one of this methods to create the Fragment and add it to your
* TabHost or ActionBar just like the other Fragments.
*/
//Method 1
Fragment f1 = eMMaFragmentWebView.newInstance(url);
//Method 2
Bundle bundle = new Bundle();
bundle.putString(“url”, url);
String className = eMMaFragmentWebView.class.getName();
Fragment f2 = Fragment.instantiate(this, className, bundle);
}
}

 

Using EMMA Strip

EMMA Strip lets you show a Strip above the status bar with a message for your customers. It can be placed in any part of the app

EMMA_17.png

 Check Strip

eMMa.checkForStrip(context);

Use checkForStrip in order to check if show Strip added on EMMA dashboard.

Strip with label

eMMa.checkForBanner(context, labelString)

Use checkForStrip in order to check if show Strip added on EMMA dashboard. If you want you can pass a custom string that labels the Strip in case you use more than one Strip on your app and you need to distinguish between them.

Extra: You can use a mixture of this methods in order to pass more parameters. See appendix with all EMMA header options.

 

Using EMMA Coupons

EMMA Coupons allows you to obtain, verify, redeem coupons that are defined and configured on the EMMA platform.

EMMA_18.png

Get Coupons 

eMMa.getCoupons(contexto)

With this call, we will get all the Coupons information available to the user, depending on the conditions that have been set on the EMMA platform.

The context parameter must be of type eMMaCouponsInterface.

getCoupons calls to eMMaCouponsInterface.onCouponsReceived (ArrayList < eMMaCoupon>) in the case that the user has available coupons to redeem them or to eMMaCouponsInterface.onCouponsFailure () if the user has no coupons available.

eMMaCoupon contains all the information about the coupon: id (EMMA internal identifier), code, maximum number of redemptions, number of times traded, title, description, picture ...

Details of a Coupon

eMMa.getCoupon(contexto, int couponId)

With this call, we will get information about a particular coupon.

The context parameter must be of type eMMaCouponsInterface .

The couponId parameter must be the EMMA internal identifier of a coupon, ID that can be obtained from a call to getCoupons made ​​earlier.

getCoupon calls to eMMaCouponsInterface.onSingleCouponReceived (eMMaCoupon) in case the indicated coupon exists or otherwise to eMMaCouponsInterface.onCouponsFailure ( ).

eMMaCoupon contains all the information about the coupon: id (EMMA internal identifier), code, maximum number of redemptions, number of times traded, title, description, picture ...

Check the Coupon validity 

eMMa.getCouponValidRedeems(contexto, int couponId)

With this call, we can check if the user can redeem the indicated coupon.

The context parameter must be of type eMMaCouponsInterface .

The couponId parameter must be the EMMA internal identifier of a coupon, ID that can be obtained from a call to getCoupons made ​​earlier.

getCouponValidRedeems calls to eMMaCouponsInterface.onCouponValidRedeemsReceived (int numRedeems), where numRedeems indicates the number of times it can still be redeemed the coupon or -1 in case of error.

Redeem a coupon

eMMa.redeemCoupon(contexto, int couponId)

With this call, the user redeems the indicated coupon.

The context parameter must be of type eMMaCouponsInterface .

The couponId parameter must be the eEMMA internal identifier of a coupon, ID that can be obtained from a call to getCoupons made ​​earlier.

redemmCoupon calls eMMaCouponsInterface.onCouponRedemption (boolean success ), where success indicates if the coupon has redeemed.

Cancel a coupon

eMMa.cancelCoupon(contexto, int couponId)
eMMa.cancelCoupon(contexto, int couponId, int cancelCount)

This call can cancel the redemption of a coupon that has done before.

The context parameter must be of type eMMaCouponsInterface .

The couponId parameter must be the EMMA internal identifier of an identifier coupon that can be obtained from a call to getCoupons made ​​earlier .

Optionally, you can specify a cancelCount parameter if you want to cancel more than one redemption that had made before. If it's not indicated, the coupon will be canceled.

cancelCoupon calls to eMMaCouponsInterface.onCouponCancelled (boolean success ), where success indicates if the coupon is canceled.

 

EMMA Whitelist

Minimum SDK version: 2.5.6 or later

With this functionality we can limit the urls the EMMA will open so in the In-App communication will only be displayed the content that begins with any of the url's we have indicated in the whitelist.  

If we don't indicate any url in the whitelist, any url will be displayed.

This functionality will affect to the a los Push (Rich URL), Banners, StartViews, AdBalls and DynamicTabs.

In the communications (Banners, StartViews, AdBalls y DynamicTabs) you can upload external content to the app via Webview, and for Banners, AdBalls and DynamicTabs you could upload external images that would also be controlled by the whitelist.

If you want to send a push with Rich URL, if it does not comply, the corresponding Webview would not be opened but the push does arrive to the application. It should be noted that if instead a url you use a deeplink, the deeplink scheme must be added to the whitelist in order to open it. 

How to use it

We should call this method after the starteMMaSession and before we call any other method of the In-App communications.

eMMa.setWhitelist(List<String> urls);

Examples

 If my whitelist is “http://mydomain.com”.

List<String> whitelist = Arrays.asList("http://mydomain.com");
eMMa.setWhitelist(whitelist); 

Example 1:

Set up in the EMMA dashboard a Banner with Target URL https://mydomain.com

The Banner will be not displayed, we should add to the whitelist: https://mydomain.com

Example 2:

Set up in the EMMA dashboard a StartView with StartView URL http://www.mydomain.com

The Startview will be not displayed, we should add to the whitelist: https://mydomain.com

Example 3:

Set up in the EMMA dashboard a Banner with Target URL http://mydomain.com/my/url and SmartPhone Banner URL http://subdomain.mydomain.com/my/image

The Banner will be not displayed, the image url isn't in the whitelist, we should add to the whitelist http://subdomain.mydomain.com

Example 4:

Set up in the EMMA dashboard a Banner with Target URL http://mydomain.com/my/url/

The Banner will be displayed because the url that we introduce in the Target URL starts with the same protocol and domain that the whitelist url.  

Example 5:

Set up in the EMMA dashboard a Startview with StartView URL http://mydomain.com/mypage.html&param=value

The StartView will be shown because the url that we introduce in the StartView URL option starts with the same protocol and domain that the whitelist url. 

 

Debugging your code

This step is optional. If you need to see the EMMA log, enable it (before starteMMaSession) by calling:

eMMa.setDebuggerOutput(true);

Please consider that EMMA is not real time. A delay of 1 hour can occur to see your data. 

Have more questions? Submit a request

0 Comments

Article is closed for comments.