Google play store is changing the referrer data to

2019-06-23 23:44发布

问题:

I am new to referrer concept.

I have written a code, the intention of which is to have google playstore send a referrer data as a broadcast to my app after installation which I catch and handle accordingly. The problem is the data that I am asking google to fireback is different from what google is actually sending to me.

I use the following code to create the link:

final String url = "intent://details?id=com.myapp&url="a dummy url"&referrer="+referrer+"#Intent;scheme=market;action=android.intent.action.VIEW;package=com.myapp;S.referrer="+referrer+";end";

Here referrer = < a correct base64 encoded string >

NOTE:
The initial dummy URL is not of any use to me. My interest is to fallback to google to install the app. The assumption here is that I don't have the app installed on device, hence this should work. The fallback is happening correctly and I am directed to Google PlayStore from where I install the app then the referrer data is broadcast to my app. I catch the referrer data and show it in a toast in the production build.

What I expect to see in the toast data: < my base64 encoded which i sent >
What I see: "com.android.chrome"

Why is this happening?

回答1:

After spending too much of time . I was able to figure out what was happening. If there are no referrers given chrome attaches its own referrer whose value is "com.android.chrome". The way I was attaching the referrer was wrong , hence chrome's default referrer was picked up. The correction is in the last part

change this

...;package=com.myapp;S.referrer="+referrer+";end";

to

...;package=com.myapp&referrer="+referrer+";end";

Hope this helps others. My whole day was spent in this.