-
Notifications
You must be signed in to change notification settings - Fork 0
Integration
Add the following to the root gradle file.
allprojects {
repositories {
...
maven { url "https://repos.appsfly.io/artifactory/libs-release-local" }
}
}
implementation ('io.appsfly.android.utils:micro-app:1.2.15'){
transitive = true
}
If you are using a lower version of Android Studio, use 'compile' instead of 'implementation'
Obtain a unique secret key from Appsfly.io (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx). To keep the secret key secure, it is recommended to follow the below steps.
-
Place this key in the gradle.properties file of the Android Project.
appsfly_app_key=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx -
Add the following config to the manifest placeholders.
defaultConfig {
...
manifestPlaceholders.appsfly_app_key = "${appsfly_app_key}"
}
- Add the following to the application module Manifest file.
<application
android:name=".MyApplication"
...
android:label="My Application">
<meta-data
android:name="appsfly_app_key"
android:value="${appsfly_app_key}" />
...
/>
Override your Application/Activity Instance onCreate() method
@Override
public void onCreate() {
super.onCreate();
ArrayList<AppsFlyClientConfig> appsFlyClientConfigs = new ArrayList<AppsFlyClientConfig>();
AppsFlyClientConfig appsflyConfig = new AppsFlyClientConfig(context, "MICRO_MODULE_HANDLE", "EXECUTION_URL");
appsFlyClientConfigs.add(appsflyConfig);
AppsFlyProvider.getInstance().initialize(appsFlyClientConfigs, this);
}
This will start the process of syncing Metadata required to run MicroApp in your application.
To launch the MicroApp, run the following snippet where there is a call to action.
MicroAppLauncher.pushApp(*MICRO_MODULE_HANDLE*, *INTENT*, *new JSONObject(){INTENT_DATA}*, *ACTIVITY*);
Note: This will create an activity showing the MicroApp.
//Put user context data inside a JSONobject and pass it as intent data.
JSONObject userContextData = new JSONObject();
data.put(*key* , *value*);
AppsFlyProvider.getInstance().pushApp("MICRO_MODULE_HANDLE", "APPLICATION_KEY", "INTENT", userContextData, context);
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (resultCode == RESULT_OK && requestCode == AppsFlyProvider.REQUEST_CODE) {
String dataStr = data.getStringExtra("result");
JSONObject resultData;
try {
resultData = new JSONObject(dataStr);
} catch (JSONException e) {
e.printStackTrace();
}
//Get values from resultData with keys specified by the MicroApp Service Provider .
Object value1 = result.get(*key1*);
String value2 = result.getString(*key2*);
}
}
Note: Contact the [email protected] for any issues with integration.
Copyright Dhurya Technologies Pvt. Ltd. ® 2016