Android referral tracking not working with Google play

妖精的绣舞 提交于 2019-12-05 01:28:12

you can write this simple reciever:

public class DetectInstall extends BroadcastReceiver{

private String referrerId;

@Override
public void onReceive(Context context, Intent intent) {

    if ((null != intent)
            && (intent.getAction().equals("com.android.vending.INSTALL_REFERRER"))) {
        Log.e("Message", "App is getting installed first time..");
        referrerId = intent.getStringExtra("referrer");

    }
}

}

then in manifest add the receiver tag inside the application like this :

<application

    android:hardwareAccelerated="true"
    android:icon="@drawable/ic_bmg"
    android:label="@string/app_name"
    android:screenOrientation="portrait"
    android:theme="@style/AppTheme" >
    <receiver
        android:name=".DetectInstall"
        android:exported="true" >
        <intent-filter>
            <action android:name="com.android.vending.INSTALL_REFERRER" />
        </intent-filter>
    </receiver>

then you will need to send the referrer parameter to the google playstore URL Like this :

https://play.google.com/store/apps/details?id=you.package.name&hl=en&referrer=you will get this first time when you install app

referrer field is required, whatever string u pass in referrer field you will get it in the broadcast reciever

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!