diff --git a/android-core/src/main/java/com/mparticle/InstallReferrerHelper.java b/android-core/src/main/java/com/mparticle/InstallReferrerHelper.java index 46b01d90d..f36979c80 100644 --- a/android-core/src/main/java/com/mparticle/InstallReferrerHelper.java +++ b/android-core/src/main/java/com/mparticle/InstallReferrerHelper.java @@ -15,6 +15,30 @@ import com.mparticle.internal.Logger; import com.mparticle.internal.MPUtility; +/** + * Helper class to fetch install referrer via reflection. + *
+ * To test the install referrer functionality: + * 1. Set test application `applicationId` to a real app's Play Store package name, e.g. "com.medium.reader". + *
+ * 2. Ensure the app is fully uninstalled from the test device: + * `adb uninstall com.medium.reader` + *
+ * 3. Broadcast the test referrer to the Play Store. This will open the Play Store app: + * `adb shell "am start -a android.intent.action.VIEW -d 'https://play.google.com/store/apps/details?id=com.medium.reader&referrer=utm_source%3Dgoogle%26utm_medium%3Dcpc%26utm_term%3Drunning%252Bshoes%26utm_content%3Dcontent%26utm_campaign%3Dpromo'"` + *
+ * 4. Install the debug version of your test app. + *
+ * 5. Launch the app and check the logs for the referrer: + * `adb logcat -d | grep 'Install Referrer received'` + *
+ * 6. Verify the referrer is logged in the test app's logs by checking for the utm_* parameters passed in during step 3. + * e.g. `Install Referrer received: utm_source=google&utm_medium=cpc&utm_term=running%2Bshoes&utm_content=content&utm_campaign=promo` + * + * @see InstallReferrerClient + * @see How to Test the Play Store Install Referrer API + * @noinspection JavadocLinkAsPlainText + */ public class InstallReferrerHelper { @Nullable diff --git a/android-core/src/main/java/com/mparticle/internal/MPUtility.java b/android-core/src/main/java/com/mparticle/internal/MPUtility.java index cb6f1ca5e..6e8efcc7f 100644 --- a/android-core/src/main/java/com/mparticle/internal/MPUtility.java +++ b/android-core/src/main/java/com/mparticle/internal/MPUtility.java @@ -593,7 +593,9 @@ public static Boolean isFirebaseAvailablePreV21() { public static boolean isInstallRefApiAvailable() { try { + Class.forName("com.android.installreferrer.api.InstallReferrerClient"); Class.forName("com.android.installreferrer.api.InstallReferrerStateListener"); + Class.forName("com.android.installreferrer.api.ReferrerDetails"); return true; } catch (Exception ignored) { }