Playstore will no longer broadcast install_referrer, install_referrer is deprecated.
As we were using install_referrer for Campaign, but InstallBroadcast is deprecated and stopped working after 1st march 2020.
What to do now ?
Google have launched Play Install Referrer Library for the same so we can migrate from install_referrer broadcast to Play Install Referrer Library.
How to migrate from install_referrer to Play Install Referrer Library ?
firstly we need to add a gradle dependency
dependencies {
...
implementation 'com.android.installreferrer:installreferrer:1.1'
}
after sync, we need to make with connection with Google play. and once connection is success we can read the data passed to playstore
below is the code to make connection with google play
InstallReferrerClient referrerClient;
referrerClient = InstallReferrerClient.newBuilder(this).build();
referrerClient.startConnection(new InstallReferrerStateListener() {
@Override
public void onInstallReferrerSetupFinished(int responseCode) {
switch (responseCode) {
case InstallReferrerResponse.OK:
// Connection established.
break;
case InstallReferrerResponse.FEATURE_NOT_SUPPORTED:
// API not available on the current Play Store app.
break;
case InstallReferrerResponse.SERVICE_UNAVAILABLE:
// Connection couldn't be established.
break;
}
}
@Override
public void onInstallReferrerServiceDisconnected() {
// Try to restart the connection on the next request to
// Google Play by calling the startConnection() method.
}
});
once the connection is success we can use below code to fetch the required details
ReferrerDetails response = referrerClient.getInstallReferrer();
String referrerUrl = response.getInstallReferrer();
long referrerClickTime = response.getReferrerClickTimestampSeconds();
long appInstallTime = response.getInstallBeginTimestampSeconds();
boolean instantExperienceLaunched = response.getGooglePlayInstantParam();
According to google doc. install referrer information will be available for 90 days and won’t change unless the application is reinstalled.
Please do comment if you have any or clap to motivate and show like.