File tree Expand file tree Collapse file tree
android-core/src/main/java/com/mparticle Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1515import com .mparticle .internal .Logger ;
1616import com .mparticle .internal .MPUtility ;
1717
18+ /**
19+ * Helper class to fetch install referrer via reflection.
20+ * <p>
21+ * To test the install referrer functionality:
22+ * 1. Set test application `applicationId` to a real app's Play Store package name, e.g. "com.medium.reader".
23+ * <p>
24+ * 2. Ensure the app is fully uninstalled from the test device:
25+ * `adb uninstall com.medium.reader`
26+ * <p>
27+ * 3. Broadcast the test referrer to the Play Store. This will open the Play Store app:
28+ * `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'"`
29+ * <p>
30+ * 4. Install the debug version of your test app.
31+ * <p>
32+ * 5. Launch the app and check the logs for the referrer:
33+ * `adb logcat -d | grep 'Install Referrer received'`
34+ * <p>
35+ * 6. Verify the referrer is logged in the test app's logs by checking for the utm_* parameters passed in during step 3.
36+ * e.g. `Install Referrer received: utm_source=google&utm_medium=cpc&utm_term=running%2Bshoes&utm_content=content&utm_campaign=promo`
37+ *
38+ * @see <a href="https://developer.android.com/reference/com/android/installreferrer/api/InstallReferrerClient">InstallReferrerClient</a>
39+ * @see <a href="https://medium.com/@madicdjordje/how-to-test-the-play-store-install-referrer-api-78a63d59945b">How to Test the Play Store Install Referrer API</a>
40+ * @noinspection JavadocLinkAsPlainText
41+ */
1842public class InstallReferrerHelper {
1943
2044 @ Nullable
Original file line number Diff line number Diff line change @@ -593,7 +593,9 @@ public static Boolean isFirebaseAvailablePreV21() {
593593
594594 public static boolean isInstallRefApiAvailable () {
595595 try {
596+ Class .forName ("com.android.installreferrer.api.InstallReferrerClient" );
596597 Class .forName ("com.android.installreferrer.api.InstallReferrerStateListener" );
598+ Class .forName ("com.android.installreferrer.api.ReferrerDetails" );
597599 return true ;
598600 } catch (Exception ignored ) {
599601 }
You can’t perform that action at this time.
0 commit comments