0

Into my App, the user could share a fitness workout with his friends. So there are different use cases:

  1. The user's sharing with a friend on our App (this friend uses the App too). Just select his friend into his followings. So the sharing process is internal (between App and our server). OK for that.
  2. The user's sharing to a friend by using SMS/ Email/ etc.. This friend has no account on our App. In this case, we'll generate a referred link to catch elements after the App setup from Google Play. OK for that.
  3. The user's sharing with a friend by using SMS/ Email/ etc. too. This friend has an account on our App, and the App is installed on his mobile phone. How can I get back the data from the share link?

Thank you very much guys for your help!

Kaushal Panchal
  • 1,785
  • 1
  • 11
  • 27
anthony
  • 7,653
  • 8
  • 49
  • 101

2 Answers2

0

The sample URL can be like following

https://play.google.com/store/apps/details?id=com.example.application&referrer=utm_source%3Dgoogle%26utm_medium%3Dcpc%26utm_term%3Drunning%252Bshoes%26utm_content%3Dlogolink%26utm_campaign%3Dspring_sale

You can send this urlin the sms or email(shortened URL) or embed them in your website. So when someone clicks on the URL it will navigate the user to play store.

To receive the utm data in the URL like utm_referrer,utm_medium,utm_term,utm_content you will have to configure the app like following.

  1. Add google referrer receiver in your android manifest file
 <receiver
            android:name="com.example.application.ReferrerReceiver"
            android:exported="true">
            <intent-filter>
                <action 
               android:name="com.android.vending.INSTALL_REFERRER" />
            </intent-filter>
 </receiver>

2 Create a ReferrerReceiver.java BroadcastReceiver class

public class ReferrerReceiver extends BroadcastReceiver {

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

        if (!intent.getAction().equals("com.android.vending.INSTALL_REFERRER")) {
            return;
        }

        String referrer = intent.getStringExtra("referrer");
        try {
        // This is your data from th URL, you can do any kind of 
        //    manipulation using this.
            referrer = URLDecoder.decode(referrer, "UTF-8");
        } catch (UnsupportedEncodingException e) {
            return;
        }
    }
}
Swayangjit
  • 1,875
  • 2
  • 13
  • 22
0

Your deep link should have query parameters, and when you recieve your deep link - you can get them with getQueryParameter(key) function and do what you need.

For example your deeplink is: myCustomScheme://myHost?value=92&title=test

private fun handleDeepLink() {
    val data = intent.data
    val value = data?.getQueryParameter("value")
    val title = data?.getQueryParameter("title")
    if (value == null || title == null) {
        toast(R.string.deep_link_error)
        return
    }
    // do something with your data
}
Vitalii Malyi
  • 874
  • 6
  • 13