Steps to Install your Android Installation
Installing the EF Network package allows you to unlock a world of onward journeys for your customers, all served natively within your Android applications. The EF Network library supports Android 5.0 with a minSDK of 26, built using 2021.2.1 Chipmunk.
Installing your Android Integration
Step 1: Import the Client
To get started, add jitpack at the end of the repositories in your root build.gradle:
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
In your app build.gradle, add the import and sync:
dependencies {
implementation 'com.github.mmob-tech:mmob-client-android:main-SNAPSHOT'
}
Step 2: Create webView Reference
In app activity_mail.xml, create a reference to a web_view under an alias 'mmob_view':
<WebView
android:id="@+id/mmob_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
Step 3: Initialise the Client and Webview
In your snippet host app (e.g. activity_main.xml), initialise the client and webView:
val mmobView: MmobView = findViewById(R.id.mmob_view)
val client = MmobClient(mmobView, applicationContext)
Step 3.1: Set your Instance Domain to the Correct Region
If you are operating in the Asia Pacific region, ensure to add InstanceDomain.EFNETWORK
to your val client
parameters. If you do not set an InstanceDomain, the system will default to a different server and your deployment will not function.
val client = MmobClient(mmobView, applicationContext, InstanceDomain.EFNETWORK)
Step 3.2: Set your Environment
environment
should only be set to stag
in the case that you are deploying to your UAT/Staging environment. If you are deploying to production, our system will automatically point to our production server and environment does not need to be specified.
Step 4: Point the Script to the Correct Identifier
A. If you are a Distribution Partner (embedding services into your platform), your configuration will use an cp_deployment_id
and cp_id
and look like the following:
val integration = MmobClient.MmobIntegrationConfiguration(
cp_id = **your CP id**,
cp_deployment_id = **your integration id**
)
B. If you are a Service Provider (you have already created your own widget for embedding in other channels), the configuration for your distribution partner will use a distribution_id
only:
val distribution = MmobClient.MmobDistribution(
distribution=MmobClient.MmobDistribution.Configuration(
distribution_id = "your distribution ID"
environment = "stag"
)
)
If you are unsure about any of the id
options above, please contact your account manager who will be able to confirm.
Step 5: Set the customerInfo Snippet
Configure the customerInfo snippet with the correct parameters:
val customerInfo = MmobClient.MmobCustomerInfo(
customerInfo = MmobClient.MmobCustomerInfo.Configuration(
email: "john.smith@example.com"
first_name: "John"
surname: "Smith"
)
)
Please note that if your organisation does not wish to pass in any data to the snippet, this part of the snippet can be left as follows:
customerInfo = MmobClient.MmobCustomerInfo.Configuration()
For anonymous users (users for whom you do not have a suitable GUID such as an email), do not pass in a non-unique placeholder email. Instead, ensure that the email field is left blank each time an anonymous user starts a journey.
Step 6: Call the Client
Call the client to update the view:
client.loadDistribution(distribution = distribution, customerInfo = customerInfo)
Your Final Script Should Appear as Follows:
package com.mmob.efhub
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import com.mmob.mmob.client.MmobClient
import com.mmob.mmobclient.MmobView
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
val mmobView: MmobView = findViewById(R.id.mmob_view)
val client = MmobClient(mmobView, applicationContext, InstanceDomain.EFNETWORK)
// note that if operating in the APAC Region, InstanceDomain.EFNETWORK should be used. If not, do not include `InstanceDomain`
val integration = MmobClient.MmobIntegrationConfiguration(
cp_id = "cp_DhskfrQ5V0HLfcVwbl54Q",
cp_deployment_id = "cpd_aWYxkROUFpqW0GklMEtBz"
)
val distribution = MmobClient.MmobDistribution(
distribution = MmobClient.MmobDistribution.Configuration(
distribution_id = "tpd_Hze6TCyj06uEg1c3DrmjW",
environment = "stag"
)
)
val customerInfo = MmobClient.MmobCustomerInfo(
customerInfo = MmobClient.MmobCustomerInfo.Configuration(
email = "corey.hudson@example.com",
first_name = "Corey",
surname = "Hudson",
gender = "male",
title = "Mr",
building_number = "8",
address_1 = "Brandon Grove",
town_city = "Newcastle Upon Tyne",
postcode = "NE2 1PA",
dob = "1946-03-26T20:49:19.388Z"
)
)
client.loadDistribution(distribution = distribution, customerInfo = customerInfo)
}
}
Was this page helpful?
On This Page
- Installing your Android Integration
- Step 1: Import the Client
- Step 2: Create webView Reference
- Step 3: Initialise the Client and Webview
- Step 3.1: Set your Instance Domain to the Correct Region
- Step 3.2: Set your Environment
- Step 4: Point the Script to the Correct Identifier
- Step 5: Set the customerInfo Snippet
- Step 6: Call the Client
- Your Final Script Should Appear as Follows: