1

How to share playstore link to share app along with referral code. Playstore link to the app will not allow appending custom parameters so can't set it as deeplink for firebase dynamic links as parameters cant be appended in the dynamic link or can I?Is there any other way such that link opens or installs app and invite code is automatically inserted in text view

Referred below link but didnt work How can I share referral code on facebook,whatapp,instagram and other platforms in android

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
charmy
  • 31
  • 2
  • 7
  • I think you could use firebase dynamic links. If the app is not install, it goes to the play store as you said but after the installation, the app will be opened with the code you put in the dynamic link. – Juanje Jul 18 '18 at 13:42
  • @Juanje can i append the code in dynamic link? as i cannot in deep link of playstore – charmy Jul 18 '18 at 13:55
  • Are you generating the deep links manually? You can select a custom path to get in the app opening. – Juanje Jul 18 '18 at 17:41
  • I put some code below. I hope this solution helps. – Juanje Jul 18 '18 at 17:55
  • I build the dynamic link manually ,it contains the playstore link with appended parameters .When i recieve the link in my app the parameters are gone This is link https://example.page.link/?link=https://play.google.com/store/apps/details?id%3Decample.com&?invite=9000&apn=example.com.I only get id parameter and invite parameter is null.I hv replaced package name with example – charmy Jul 19 '18 at 06:55

2 Answers2

1

This is a bit tricky.

Solution 1: use external tool from Branch.io

What is the proper way to create user invite codes using Branch?

Solution 2: Manual (hacky)

Peter wants to share it to Max.

  • Peter sends invitation url to Max.

The Url is not a direct PlayStore Url, it links to a PHP file. This file saves, when opened the IP of the client and redirects to the PlayStore.

  • Max opens the url, his IP is stored and he downloads the App.

  • On the first Appstart, you make a request to your database. If the IP matches, you can redeem.

This is not a perfect solution and needs to be improved, but just to give you an idea of how it could be done.

Philipp
  • 468
  • 3
  • 24
-1

Here it is some code I have used with Firebase Dynamic Links.

private void createFirebaseLink(Uri linkUri){
    FirebaseDynamicLinks.getInstance().createDynamicLink()
            .setLongLink(linkUri)
            .buildShortDynamicLink()
            .addOnCompleteListener(new OnCompleteListener<ShortDynamicLink>() {
                @Override
                public void onComplete(@NonNull Task<ShortDynamicLink> task) {
                    if (task.isSuccessful()) {
                       // SHARE BY LOCAL METHODS
                    } else {
                        Toast.makeText(getApplicationContext(), R.string.share_error, Toast.LENGTH_LONG).show();
                        Log.e("FIREBASE_SHORT_LINK", task.getException().getLocalizedMessage());
                    }
                }
            });
}

private Uri createDynamicUri(Uri uri){
    DynamicLink dynamicLink = FirebaseDynamicLinks.getInstance().createDynamicLink()
            .setLink(uri)
            .setDynamicLinkDomain(getString(R.string.firebase_link_domain))
            .setAndroidParameters(new DynamicLink.AndroidParameters.Builder().build())
            .buildDynamicLink();

    return dynamicLink.getUri();
}

private Uri createShareUri(String id) {
    Uri.Builder builder = new Uri.Builder();
    builder.scheme(getString(R.string.config_scheme))
            .authority(getString(R.string.config_host))
            //PATH IN THE APP TO ALLOW DIFFERENT ACTIONS
            .appendPath(getString(R.string.config_path))
            // HERE YOU PUT WHATEVER YOU WANT TO MANAGE IN THE APP, 
            // REFERRAL CODE FOR EXAMPLE.  
            .appendQueryParameter("KEY", "VALUE"); 
    return builder.build();
}

You can use them like:

 Uri shareItem = createShareUri("Some value");
 Uri dynamicLink = createDynamicLink(shareItem);

 createFirebaseLink(dynamicLink);

You can get more info in Firebase docs.

Juanje
  • 1,235
  • 2
  • 11
  • 28