diff --git a/.gitmodules b/.gitmodules index 7debf12bc..12fa86081 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,9 +1,6 @@ [submodule "kits/apteligent-kit"] path = kits/apteligent-kit url = git@github.com:mParticle-integrations/mparticle-android-integration-apteligent.git -[submodule "kits/branch-kit"] - path = kits/branch-kit - url = git@github.com:mParticle-integrations/mparticle-android-integration-branch.git [submodule "kits/button-kit"] path = kits/button-kit url = git@github.com:mparticle-integrations/mparticle-android-integration-button.git diff --git a/.mobsf b/.mobsf index 3afef2999..959a74975 100644 --- a/.mobsf +++ b/.mobsf @@ -8,6 +8,7 @@ - "**/src/test/**" - "**/example/**" - "**/*-example/**" + - "**/SampleApplication/**" ignore-rules: - webview_javascript_interface # Intentional: JS bridge for mParticle WebView SDK; workspace token controls access @@ -27,3 +28,6 @@ - android_certificate_pinning - android_ssl_pinning - accept_self_signed_certificate + - android_manifest_well_known_assetlinks # Sample apps use third-party domains (e.g. Branch mp-fortune.app.link) + - android_task_hijacking1 # Sample apps; targetSdk in build.gradle + - android_task_hijacking2 # Sample apps; targetSdk in build.gradle diff --git a/.trunk/trunk.yaml b/.trunk/trunk.yaml index 9621ccb0b..87f9dad31 100644 --- a/.trunk/trunk.yaml +++ b/.trunk/trunk.yaml @@ -73,6 +73,7 @@ lint: - kits/apptentive/apptentive-6/** - kits/appsflyer/appsflyer-6/** - kits/apptimize/apptimize-3/** + - kits/branch/branch-5/** - kits/braze/braze-38/** - kits/clevertap/clevertap-7/** - kits/comscore/comscore-6/** diff --git a/kits/apptentive/apptentive-6/src/main/kotlin/com/mparticle/kits/CustomDataParser.kt b/kits/apptentive/apptentive-6/src/main/kotlin/com/mparticle/kits/CustomDataParser.kt index 94d1bfa42..4926752d0 100644 --- a/kits/apptentive/apptentive-6/src/main/kotlin/com/mparticle/kits/CustomDataParser.kt +++ b/kits/apptentive/apptentive-6/src/main/kotlin/com/mparticle/kits/CustomDataParser.kt @@ -22,7 +22,7 @@ internal object CustomDataParser { try { if (value != null) parseValueGuarded(value) else null } catch (e: Exception) { - Log.e(LogTag("pParticle"), "Unable to parse value: $value") + Log.e(LogTag("pParticle"), "Unable to parse custom data value") value } diff --git a/kits/branch-kit b/kits/branch-kit deleted file mode 160000 index 22f5de5b4..000000000 --- a/kits/branch-kit +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 22f5de5b4cc892cbbd6fa9f65f922eebdd8a47ef diff --git a/kits/branch/branch-5/README.md b/kits/branch/branch-5/README.md new file mode 100644 index 000000000..7f7a4c253 --- /dev/null +++ b/kits/branch/branch-5/README.md @@ -0,0 +1,23 @@ +## Branch Kit Integration + +This repository contains the [Branch](https://www.branch.io/) integration for the [mParticle Android SDK](https://github.com/mParticle/mparticle-android-sdk). + +### Adding the integration + +1. Add the kit dependency to your app's build.gradle: + + ```groovy + dependencies { + implementation 'com.mparticle:android-branch-kit:5+' + } + ``` +2. Follow the mParticle Android SDK [quick-start](https://github.com/mParticle/mparticle-android-sdk), then rebuild and launch your app, and verify that you see `"Branch Metrics detected"` in the output of `adb logcat`. +3. Reference mParticle's integration docs below to enable the integration. + +### Documentation + +[Branch integration](https://docs.mparticle.com/integrations/branch-metrics/event/) + +### License + +[Apache License 2.0](http://www.apache.org/licenses/LICENSE-2.0) diff --git a/kits/branch/branch-5/SampleApplication/.gitignore b/kits/branch/branch-5/SampleApplication/.gitignore new file mode 100644 index 000000000..39fb081a4 --- /dev/null +++ b/kits/branch/branch-5/SampleApplication/.gitignore @@ -0,0 +1,9 @@ +*.iml +.gradle +/local.properties +/.idea/workspace.xml +/.idea/libraries +.DS_Store +/build +/captures +.externalNativeBuild diff --git a/kits/branch/branch-5/SampleApplication/README.md b/kits/branch/branch-5/SampleApplication/README.md new file mode 100644 index 000000000..c0077d0ac --- /dev/null +++ b/kits/branch/branch-5/SampleApplication/README.md @@ -0,0 +1,14 @@ +##mParticle-Branch Example + +###Overview + +This sample app demonstrates: + +• How to use the mParticle and Branch in a simple Android application. + +• How to create and share Branch links in your app. + +• How to Branch deep links are handled in an app when using branch with mParticle. + +• How event tracking is handled in mParticle and Branch. + diff --git a/kits/branch/branch-5/SampleApplication/app/.gitignore b/kits/branch/branch-5/SampleApplication/app/.gitignore new file mode 100644 index 000000000..796b96d1c --- /dev/null +++ b/kits/branch/branch-5/SampleApplication/app/.gitignore @@ -0,0 +1 @@ +/build diff --git a/kits/branch/branch-5/SampleApplication/app/build.gradle b/kits/branch/branch-5/SampleApplication/app/build.gradle new file mode 100644 index 000000000..4f749ed58 --- /dev/null +++ b/kits/branch/branch-5/SampleApplication/app/build.gradle @@ -0,0 +1,43 @@ +apply plugin: 'com.android.application' + +android { + compileSdk = 34 + buildToolsVersion "27.0.3" + defaultConfig { + applicationId "com.mparticle.branchsample" + minSdk = 25 + targetSdk = 33 + versionCode 1 + versionName "1.0" + testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } + packagingOptions { + exclude 'META-INF/proguard/androidx-annotations.pro' + exclude 'META-INF/versions/9/module-info.class' + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + implementation 'androidx.appcompat:appcompat:1.6.1' + implementation 'com.google.android.material:material:1.8.0' + implementation 'com.android.installreferrer:installreferrer:2.2' + + // Local project dependency + api project(':local-mParticle-Branch-kit') + + // Uncomment below to use published version instead + // implementation 'com.mparticle:android-branch-kit:5+' + + testImplementation 'junit:junit:4.13.2' + + androidTestImplementation('androidx.test.espresso:espresso-core:3.5.1', { + exclude group: 'androidx.test', module: 'runner' + }) +} diff --git a/kits/branch/branch-5/SampleApplication/app/proguard-rules.pro b/kits/branch/branch-5/SampleApplication/app/proguard-rules.pro new file mode 100644 index 000000000..2d3430033 --- /dev/null +++ b/kits/branch/branch-5/SampleApplication/app/proguard-rules.pro @@ -0,0 +1,16 @@ +# Add project specific ProGuard rules here. +# By default, the flags in this file are appended to flags specified +# You can edit the include path and order by changing the proguardFiles +# directive in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# Add any project specific keep options here: + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} diff --git a/kits/branch/branch-5/SampleApplication/app/src/androidTest/java/com/mparticle/branchsample/ExampleInstrumentedTest.java b/kits/branch/branch-5/SampleApplication/app/src/androidTest/java/com/mparticle/branchsample/ExampleInstrumentedTest.java new file mode 100644 index 000000000..6cb710a35 --- /dev/null +++ b/kits/branch/branch-5/SampleApplication/app/src/androidTest/java/com/mparticle/branchsample/ExampleInstrumentedTest.java @@ -0,0 +1,26 @@ +package com.mparticle.branchsample; + +import android.content.Context; +import android.support.test.InstrumentationRegistry; +import android.support.test.runner.AndroidJUnit4; + +import org.junit.Test; +import org.junit.runner.RunWith; + +import static org.junit.Assert.*; + +/** + * Instrumentation test, which will execute on an Android device. + * + * @see Testing documentation + */ +@RunWith(AndroidJUnit4.class) +public class ExampleInstrumentedTest { + @Test + public void useAppContext() throws Exception { + // Context of the app under test. + Context appContext = InstrumentationRegistry.getTargetContext(); + + assertEquals("com.mparticle.branchsample", appContext.getPackageName()); + } +} diff --git a/kits/branch/branch-5/SampleApplication/app/src/main/AndroidManifest.xml b/kits/branch/branch-5/SampleApplication/app/src/main/AndroidManifest.xml new file mode 100644 index 000000000..a81275e7e --- /dev/null +++ b/kits/branch/branch-5/SampleApplication/app/src/main/AndroidManifest.xml @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/kits/branch/branch-5/SampleApplication/app/src/main/java/com/mparticle/branchsample/SampleApplication.java b/kits/branch/branch-5/SampleApplication/app/src/main/java/com/mparticle/branchsample/SampleApplication.java new file mode 100644 index 000000000..65b473293 --- /dev/null +++ b/kits/branch/branch-5/SampleApplication/app/src/main/java/com/mparticle/branchsample/SampleApplication.java @@ -0,0 +1,101 @@ +package com.mparticle.branchsample; + +import android.app.Application; + +import com.mparticle.AttributionError; +import com.mparticle.AttributionListener; +import com.mparticle.AttributionResult; +import com.mparticle.MParticle; +import com.mparticle.MParticleOptions; + +import org.json.JSONObject; + +import io.branch.referral.Branch; + +public class SampleApplication extends Application implements AttributionListener { + private IBranchEvents branchEventCallback; + private static SampleApplication instance; + + @Override + public void onCreate() { + super.onCreate(); + instance = this; + MParticleOptions options = MParticleOptions.builder(this) + .credentials("REPLACE_ME_WITH_API_KEY", "REPLACE_ME_WITH_API_SECRET") + .attributionListener(this) + //Set an instance of AttributionListener + //this instance will continually be called whenever + //there is new attribution/deep linking information. + //It is essentially equivalent to the Branch SDK's BranchReferralInitListener class + //that is passed to the Branch SDK's initSession() API. + .logLevel(MParticle.LogLevel.VERBOSE) + .build(); + + MParticle.start(options); + } + + public static void setBranchEventCallback(IBranchEvents branchEventCallback) { + instance.branchEventCallback = branchEventCallback; + } + + + /** + * A few typical scenarios where this callback would be invoked: + *

+ * (1) Base case: + * - User does not tap on a link, and then opens the app (either after a fresh install or not) + * - This block will be invoked with Branch Metrics' response indicating that this user did not tap on a link. + *

+ * (2) Deferred deep link: + * - User without the app installed taps on a link + * - User is redirected from Branch Metrics to the App Store and installs the app + * - User opens the app + * - This block will be invoked with Branch Metrics' response containing the details of the link + *

+ * (3) Deep link with app installed: + * - User with the app already installed taps on a link + * - Application opens directly to an Activity via a link click, mParticle forwards the launch URI etc to Branch + * - This callback will be invoked with Branch Metrics' response containing the details of the link + *

+ * If the user navigates away from the app without killing it, this callback could be invoked several times: + * once for the initial launch, and then again each time the user taps on a link to re-open the app. + * + *

+ * This method is equivalent to {@link io.branch.referral.Branch#initSession(Branch.BranchReferralInitListener)}. + * This will return deep links params if the app is opened by a link click otherwise a JSONObject with ""+clicked_branch_link = false". + * The below example shows how you can message this to your Activities listening for Branch deep link params. + *

+ * + * @param attributionResult + **/ + @Override + public void onResult(AttributionResult attributionResult) { + //this will be invoked for + if (attributionResult.getServiceProviderId() == MParticle.ServiceProviders.BRANCH_METRICS) { + JSONObject params = attributionResult.getParameters(); + // The Branch SDK will return a response for all new session/app opens, even + // if the user did not click a branch link. + // The parameters supported by the Branch SDK are documented here: + // https://github.com/BranchMetrics/android-branch-deep-linking#branch-provided-data-parameters-in-initsession-callback + // For eg: +// if (params.optBoolean("+clicked_branch_link", false)) { +// //handle the Branch link click +// } + if (branchEventCallback != null) { + branchEventCallback.onBranchInitialised(params); + } + } + } + + @Override + public void onError(AttributionError attributionError) { + //if the Branch SDK returns an error, it will be surfaced here. + if (branchEventCallback != null) { + branchEventCallback.onBranchInitialised(new JSONObject()); + } + } + + public interface IBranchEvents { + void onBranchInitialised(JSONObject params); + } +} diff --git a/kits/branch/branch-5/SampleApplication/app/src/main/java/com/mparticle/branchsample/activities/HomeActivity.java b/kits/branch/branch-5/SampleApplication/app/src/main/java/com/mparticle/branchsample/activities/HomeActivity.java new file mode 100644 index 000000000..ee1e49062 --- /dev/null +++ b/kits/branch/branch-5/SampleApplication/app/src/main/java/com/mparticle/branchsample/activities/HomeActivity.java @@ -0,0 +1,272 @@ +package com.mparticle.branchsample.activities; + +import android.content.Intent; +import android.os.Bundle; +import androidx.appcompat.app.AppCompatActivity; +import android.text.TextUtils; +import android.view.View; +import android.widget.CompoundButton; +import android.widget.Spinner; +import android.widget.TextView; +import android.widget.ToggleButton; + +import com.mparticle.MPEvent; +import com.mparticle.MParticle; +import com.mparticle.branchsample.R; +import com.mparticle.commerce.CommerceEvent; +import com.mparticle.commerce.Impression; +import com.mparticle.commerce.Product; +import com.mparticle.commerce.TransactionAttributes; +import com.mparticle.identity.IdentityApiRequest; + +import org.json.JSONException; +import org.json.JSONObject; + +import java.util.Date; +import java.util.HashMap; +import java.util.Map; + +import io.branch.indexing.BranchUniversalObject; +import io.branch.referral.SharingHelper; +import io.branch.referral.util.BranchContentSchema; +import io.branch.referral.util.ContentMetadata; +import io.branch.referral.util.CurrencyType; +import io.branch.referral.util.LinkProperties; +import io.branch.referral.util.ProductCategory; +import io.branch.referral.util.ShareSheetStyle; + +public class HomeActivity extends AppCompatActivity { + public static final String BRANCH_PARAMS = "branch_params"; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.home_activity); + ((ToggleButton) findViewById(R.id.tracking_cntrl_btn)).setChecked(MParticle.getInstance().getOptOut()); + + findViewById(R.id.cmdSetIdentity).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + MParticle.getInstance().Identity().login(IdentityApiRequest.withEmptyUser() + .email("foo@example.com") + .customerId("12332424555") + .build()); + } + }); + + findViewById(R.id.cmdLogout).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + MParticle.getInstance().Identity().logout(); + } + }); + + findViewById(R.id.cmdTrackView).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + logScreen(); + } + }); + + findViewById(R.id.cmdLogSimpleEvent).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + logSimpleEvent(); + } + }); + + findViewById(R.id.cmdShareBtn).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + shareBranchLink(); + } + }); + + findViewById(R.id.cmdTrackEvent).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + logCommerceEvent((String) ((Spinner) findViewById(R.id.event_name_spinner)).getSelectedItem()); + } + }); + + ((ToggleButton) findViewById(R.id.tracking_cntrl_btn)).setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + @Override + public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { + MParticle.getInstance().setOptOut(isChecked); + } + }); + + } + + @Override + protected void onStart() { + super.onStart(); + ((TextView) findViewById(R.id.deep_link_params_txt)).setText(""); + } + + @Override + protected void onResume() { + super.onResume(); + Intent intent = getIntent(); + if (!TextUtils.isEmpty(intent.getStringExtra(BRANCH_PARAMS))) { + String deepLinkParams = getIntent().getStringExtra(BRANCH_PARAMS); + try { + String deepLikMsg = "Branch Deep Link Params \n\n" + new JSONObject(deepLinkParams).toString(4); + ((TextView) findViewById(R.id.deep_link_params_txt)).setText(deepLikMsg); + } catch (JSONException e) { + e.printStackTrace(); + } + intent.removeExtra(BRANCH_PARAMS); + setIntent(intent); + } else { + ((TextView) findViewById(R.id.deep_link_params_txt)).setText(""); + } + } + + @Override + protected void onNewIntent(Intent intent) { + setIntent(intent); + } + + private void logScreen() { + Map eventInfo = new HashMap<>(2); + eventInfo.put("screen_attr_key1", "screen_attr_val1"); + eventInfo.put("screen_attr_key2", "screen_attr_val2"); + MParticle.getInstance().logScreen("SecondActivity", eventInfo); + } + + private void logSimpleEvent() { + Map eventInfo = new HashMap<>(2); + eventInfo.put("custom_attr_key1", "custom_attr_val1"); + eventInfo.put("custom_attr_key2", "custom_attr_val2"); + + MPEvent event = new MPEvent.Builder("Simple Event", MParticle.EventType.Transaction) + .duration(100) + .info(eventInfo) + .category("Food and Beverages") + .build(); + MParticle.getInstance().logEvent(event); + } + + private void logCommerceEvent(String eventName) { + + Map customAttr = new HashMap<>(2); + customAttr.put("custom_attr_key1", "custom_attr_val1"); + customAttr.put("custom_attr_key2", "custom_attr_val2"); + + Product product1 = new Product.Builder("Prod1", "my_sku", 100.00) + .brand("my_prod_brand") + .category("my_prod_category") + .couponCode("my_coupon_code") + .customAttributes(customAttr) + .name("my_prod_name") + .position(1) + .quantity(2.5) + .sku("my_sku") + .unitPrice(12.5) + .variant("my_variant") + .quantity(4) + .build(); + + Product product2 = new Product.Builder("Impression_prod", "my_sku", 100.00) + .brand("my_prod_brand") + .category("my_prod_category") + .couponCode("my_coupon_code") + .customAttributes(customAttr) + .name("my_prod_name") + .position(1) + .quantity(2.5) + .sku("my_sku") + .unitPrice(12.5) + .variant("my_variant") + .quantity(4) + .build(); + + Product product3 = new Product.Builder("prod3", "my_sku", 100.00) + .brand("my_prod_brand") + .category("my_prod_category") + .couponCode("my_coupon_code") + .customAttributes(customAttr) + .name("my_prod_name") + .position(1) + .quantity(2.5) + .sku("my_sku") + .unitPrice(12.5) + .variant("my_variant") + .quantity(4) + .build(); + + TransactionAttributes attributes = new TransactionAttributes("foo-transaction-id") + .setCouponCode("transaction_coupon_code") + .setAffiliation("transaction_affiliation") + .setId("transaction_id") + .setRevenue(13.5) + .setShipping(3.5) + .setTax(4.5); + + Impression impression = new Impression("Impression", product2); + + CommerceEvent commerceEvent = new CommerceEvent.Builder(eventName, product1) + .currency("USD") + .customAttributes(customAttr) + .transactionAttributes(attributes) + .addImpression(impression) + .productListName("my_commerce_event_prod_list") + .addProduct(product3) + .build(); + MParticle.getInstance().logEvent(commerceEvent); + } + + private void shareBranchLink() { + BranchUniversalObject buo = new BranchUniversalObject() + .setCanonicalIdentifier("item/12345") + .setCanonicalUrl("https://branch.io/deepviews") + .setContentIndexingMode(BranchUniversalObject.CONTENT_INDEX_MODE.PRIVATE) + .setLocalIndexMode(BranchUniversalObject.CONTENT_INDEX_MODE.PUBLIC) + .setTitle("My Content Title") + .setContentDescription("my_product_description1") + .setContentImageUrl("https://example.com/mycontent-12345.png") + .setContentExpiration(new Date(1573415635000L)) + .setContentImageUrl("https://test_img_url") + .addKeyWord("My_Keyword1") + .addKeyWord("My_Keyword2") + .setContentMetadata( + new ContentMetadata().setProductName("my_product_name1") + .setProductBrand("my_prod_Brand1") + .setProductVariant("3T") + .setProductCategory(ProductCategory.BABY_AND_TODDLER) + .setProductCondition(ContentMetadata.CONDITION.EXCELLENT) + .setAddress("Street_name1", "city1", "Region1", "Country1", "postal_code") + .setLocation(12.07, -97.5) + .setSku("1994320302") + .setRating(6.0, 5.0, 7.0, 5) + .addImageCaptions("my_img_caption1", "my_img_caption_2") + .setQuantity(2.0) + .setPrice(23.2, CurrencyType.USD) + .setContentSchema(BranchContentSchema.COMMERCE_PRODUCT) + .addCustomMetadata("Custom_Content_metadata_key1", "Custom_Content_metadata_val1") + ); + + + LinkProperties linkProperties = new LinkProperties() + .addTag("Tag1") + .setChannel("Sharing_Channel_name") + .setFeature("my_feature_name") + .addControlParameter("$android_deeplink_path", "custom/path/*") + .addControlParameter("$ios_url", "http://example.com/ios") + .setDuration(100); + + ShareSheetStyle shareSheetStyle = new ShareSheetStyle(this, "My Sharing Message Title", "My Sharing message body") + .setCopyUrlStyle(getResources().getDrawable(android.R.drawable.ic_menu_send), "Save this URl", "Link added to clipboard") + .setMoreOptionStyle(getResources().getDrawable(android.R.drawable.ic_menu_search), "Show more") + .addPreferredSharingOption(SharingHelper.SHARE_WITH.FACEBOOK) + .addPreferredSharingOption(SharingHelper.SHARE_WITH.EMAIL) + .addPreferredSharingOption(SharingHelper.SHARE_WITH.MESSAGE) + .addPreferredSharingOption(SharingHelper.SHARE_WITH.TWITTER) + .setAsFullWidthStyle(true) + .setSharingTitle("Share With"); + + buo.showShareSheet(this, linkProperties, shareSheetStyle, null); + } + +} diff --git a/kits/branch/branch-5/SampleApplication/app/src/main/java/com/mparticle/branchsample/activities/SplashActivity.java b/kits/branch/branch-5/SampleApplication/app/src/main/java/com/mparticle/branchsample/activities/SplashActivity.java new file mode 100644 index 000000000..3e9b42f95 --- /dev/null +++ b/kits/branch/branch-5/SampleApplication/app/src/main/java/com/mparticle/branchsample/activities/SplashActivity.java @@ -0,0 +1,81 @@ +package com.mparticle.branchsample.activities; + +import android.app.Activity; +import android.content.Intent; +import android.os.Bundle; +import android.os.Handler; +import androidx.annotation.Nullable; +import androidx.appcompat.app.AppCompatActivity; + +import com.mparticle.MPEvent; +import com.mparticle.MParticle; +import com.mparticle.branchsample.R; +import com.mparticle.branchsample.SampleApplication; + +import org.json.JSONObject; + +import java.util.HashMap; +import java.util.Map; + +/** + * Created by sojanpr on 4/18/18. + *

+ * Splash Activity for MParticle-Branch Kit integration + *

+ */ + +public class SplashActivity extends AppCompatActivity implements SampleApplication.IBranchEvents { + + private static final int SPLASH_DELAY = 1500; + + @Override + protected void onCreate(@Nullable Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.splash_activity); + SampleApplication.setBranchEventCallback(this); + } + + @Override + protected void onStart() { + super.onStart(); + new Handler().postDelayed(new Runnable() { + @Override + public void run() { + + + } + }, SPLASH_DELAY); + } + + /** + * Note : Branch needs the new intents to be set to the activity if the launch mode is `SingleTask` + **/ + @Override + protected void onNewIntent(Intent intent) { + this.setIntent(intent); + } + + @Override + public void onBranchInitialised(JSONObject params) { + final Intent intent = new Intent(SplashActivity.this, HomeActivity.class); + if (params.optBoolean("+clicked_branch_link")) { + Map infoMap = new HashMap<>(); + infoMap.put("Referred Link", params.optString("~referring_link")); + + MPEvent event = new MPEvent.Builder("Referred Session", MParticle.EventType.UserContent) + .duration(300) + .info(infoMap) + .category("Session").build(); + MParticle.getInstance().logEvent(event); + intent.putExtra(HomeActivity.BRANCH_PARAMS, params.toString()); + } + new Handler().postDelayed(new Runnable() { + @Override + public void run() { + SplashActivity.this.startActivity(intent); + SplashActivity.this.finish(); + } + }, 1500); + } + +} diff --git a/kits/branch/branch-5/SampleApplication/app/src/main/res/drawable/app_icon.png b/kits/branch/branch-5/SampleApplication/app/src/main/res/drawable/app_icon.png new file mode 100644 index 000000000..e1148ad54 Binary files /dev/null and b/kits/branch/branch-5/SampleApplication/app/src/main/res/drawable/app_icon.png differ diff --git a/kits/branch/branch-5/SampleApplication/app/src/main/res/layout/home_activity.xml b/kits/branch/branch-5/SampleApplication/app/src/main/res/layout/home_activity.xml new file mode 100644 index 000000000..8bce436d0 --- /dev/null +++ b/kits/branch/branch-5/SampleApplication/app/src/main/res/layout/home_activity.xml @@ -0,0 +1,128 @@ + + + + + + + +