4

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?

Utsav Gupta
  • 3,785
  • 5
  • 30
  • 52

1 Answers1

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.

Utsav Gupta
  • 3,785
  • 5
  • 30
  • 52
  • For me, this causes the Play Store app to open and display a white screen. Looking at the Device Monitor, I see this record: `03-14 16:45:30.931: I/ActivityManager(1289): START u0 {act=android.intent.action.VIEW cat=[android.intent.category.BROWSABLE] dat=market://details?id=com.some.app.name&referrer=extra1&referrer=com.android.chrome flg=0x10000000 pkg=com.android.vending cmp=com.android.vending/com.google.android.finsky.activities.LaunchUrlHandlerActivity} from uid 10034 pid 19319 on display 0` You can see that it added `referrer` to the URI twice in this case. – asciimo Mar 14 '17 at 23:53
  • A note to future adventurers: adding `&referer` to the package has a controversial history, documented in a number of Chromium bug reports. The solution was to add the extra `S.market_referrer` to the `intent://` URI, which went live in September 2016. Here's the ["fixed" comment](https://bugs.chromium.org/p/chromium/issues/detail?id=459711#c32). – asciimo Mar 15 '17 at 00:29