Identify referrer URL after installation through Play Store
What you're describing is called Deferred Deep Linking (Deep Linking
refers to using a link to open your app directly to a specific piece of content, and Deferred
means that it works even if the app isn't installed first).
Unfortunately there's no native way to accomplish this on either iOS or Android. The Google Play INSTALL_REFERRER
could work in theory, but it's unreliable and often gets delivered too late (i.e., seconds to minutes of waiting) to provide a good UX. URL schemes don't work, because they always fail with an error if the app isn't installed. Universal Links in iOS 9+ and App Links on Android 6+ at least don't trigger an error if the app isn't installed, but you'd still have to handle redirecting the user from your website to the App Store. You still can't pass context through to the app after install with Universal Links and App Links, so you wouldn't be able to send the user to the correct item.
To make this work, you need a remote server to close the loop. You can build this yourself, but you really shouldn't for a lot of reasons, not the least of which being you have more important things to do. A free service like Branch.io (full disclosure: they're so awesome I work with them) or Firebase Dynamic Links can handle all of this for you.
Android - Is it possible to get install referrer programmatically
You can use com.android.vending.INSTALL_REFERRER
.
The Google Play com.android.vending.INSTALL_REFERRER Intent is
broadcast when an app is installed from the Google Play Store.
Add this receiver to AndroidManifest.xml
<receiver
android:name="com.example.android.InstallReferrerReceiver"
android:exported="true"
android:permission="android.permission.INSTALL_PACKAGES">
<intent-filter>
<action android:name="com.android.vending.INSTALL_REFERRER" />
</intent-filter>
</receiver>
Create a BroadcastReceiver:
public class InstallReferrerReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
String referrer = intent.getStringExtra("referrer");
//Use the referrer
}
}
You can test the referral tracking following the steps of this answer.
Related Topics
Intercept Back Button from Soft Keyboard
Background Service with Location Listener in Android
Android Studio 0.4 Duplicate Files Copied in APK Meta-Inf/License.Txt
Mapview in a Fragment (Honeycomb)
How to Set Onclicklistener on a Radiobutton in Android
How to Remove Application from App Listings on Android Developer Console
Android- Create JSON Array and JSON Object
Android: How to Get Accurate Altitude
How to Set Tint for an Image View Programmatically in Android
Bitmapfactory Oom Driving Me Nuts
How to Create Directory Automatically on Sd Card
How to Access the Drawable Resources by Name in Android
What Exactly Does the Post Method Do
Media Player Called in State 0, Error (-38,0)
How to Access Call Log for Android
How to Add a Textview to a Linearlayout Dynamically in Android