We have a mobile app that\'s available in both Google Play Store and Apple AppStore, we want to implement a referral program to get more users to install and use our App. >
Gradle File
implementation 'com.android.installreferrer:installreferrer:1.0'
PUT CODE IN ACTIVITY WHERE IT NEED TO RECIEVE REFFERAL CODE
InstallReferrerClient mReferrerClient;
mReferrerClient = InstallReferrerClient.newBuilder(this).build();
mReferrerClient.startConnection(new InstallReferrerStateListener() {
@Override
public void onInstallReferrerSetupFinished(int responseCode) {
switch (responseCode) {
case InstallReferrerClient.InstallReferrerResponse.OK:
// Connection established
try {
ReferrerDetails response =
mReferrerClient.getInstallReferrer();
if (!response.getInstallReferrer().contains("utm_source"))
edtPRferelCode.setText("" +
response.getInstallReferrer());
} catch (Exception e) {
e.printStackTrace();
}
mReferrerClient.endConnection();
break;
case
InstallReferrerClient.InstallReferrerResponse.FEATURE_NOT_SUPPORTED:
// API not available on the current Play Store app
break;
case
InstallReferrerClient.InstallReferrerResponse.SERVICE_UNAVAILABLE:
// Connection could not be established
break;
}
}
@Override
public void onInstallReferrerServiceDisconnected() {
// Try to restart the connection on the next request to
// Google Play by calling the startConnection() method.
}
});
SHARE LINK EXAMPLE
https://play.google.com/store/apps/details?id=com.yourpackage&referrer=9BE46300