2

I'm creating a deep/dynamic link following this github project.

Here's the link which is getting created: https://appcode.app.goo.gl/?link=http://example.com/-example&apn=com.abc.xxx&amv=16&ad=0&extraParameter=null

This is the method I'm using for sharing it:

private void shareDeepLink(String deepLink) {
            Intent intent = new Intent(Intent.ACTION_SEND);
            intent.setType("text/plain");
            intent.putExtra(Intent.EXTRA_SUBJECT, "Firebase Deep Link");
            intent.putExtra(Intent.EXTRA_TEXT, deepLink);

            itemView.getContext().startActivity(intent);
}

This is the intent-filters defined in my app's AndroidManifest.xml file:

<intent-filter>
      <action android:name="android.intent.action.VIEW"/>

      <category android:name="android.intent.category.DEFAULT"/>
      <category android:name="android.intent.category.BROWSABLE"/>

      <data android:host="example.com" android:scheme="http"/>
      <data android:host="example.com" android:scheme="https"/>
</intent-filter>

This is how I'm trying to receive the shared deep-link:

boolean autoLaunchDeepLink = false;
        AppInvite.AppInviteApi.getInvitation(mGoogleApiClient, this, autoLaunchDeepLink)
                .setResultCallback(
                        new ResultCallback<AppInviteInvitationResult>() {
                            @Override
                            public void onResult(@NonNull AppInviteInvitationResult result) {
                                if (result.getStatus().isSuccess()) {
                                    // Extract deep link from Intent
                                    Intent intent = result.getInvitationIntent();
                                    final String deepLink = AppInviteReferral.getDeepLink(intent);
                                    Log.d("deepLinkMainActivity", deepLink);

                                } else {
                                    Log.d("getInvitation", "getInvitation: no deep link found.");
                                }
                            }
                        });

Here's what is getting logged out (received deep-link): http://example.com/-example

As you can clearly see, I'm not getting the exact deep-link which was created and instead I'm getting it's altered version. Why?

And how can I get exactly the same deep-link which was created and shared?

Hammad Nasir
  • 2,889
  • 7
  • 52
  • 133
  • Do you mean that the line 'Log.d("deepLinkMainActivity", deepLink);' outputs 'http://example.com/-example'? I think that is exactly what you should expect with a link that you provided. Can you please tell what do you expect to see? – diidu Feb 08 '17 at 08:34
  • Your intent filter defines scheme "https", but you use "http" in your link. That is one thing that could cause problems. – diidu Feb 08 '17 at 08:36
  • @diidu I expect to see this whole thing: `https://appcode.app.goo.gl/?link=http://example.com/-example&apn=com.abc.xxx&amv=16&ad=0&extraParameter=null` – Hammad Nasir Feb 08 '17 at 11:46
  • That is not the purpose. In the original url you can even give different url to be given to browser and to the app with &al= and you can also provide fallback link. – diidu Feb 08 '17 at 12:01
  • @diidu I want to add extra query parameters and then retrieve them later when the link is received. How to? – Hammad Nasir Feb 08 '17 at 12:02
  • did you find any solution for this? – Deeksha Jun 04 '20 at 19:07

3 Answers3

2

You are reciving the deeplink properly

This is the complete link generated that contains info like the apn : the package name of your app, the information to know for example which app need to be opened

https://appcode.app.goo.gl/?link=http://example.com/-example&apn=com.abc.xxx&amv=16&ad=0&extraParameter=null

This is your deeplink link=http://example.com/-example. So, if you want to add more parameters you can do it here, like in the example bellow

link=http://example.com/-example&blabla.

So you have this as result https://appcode.app.goo.gl/?link=http://example.com/-example&blabla&apn=com.abc.xxx&amv=16&ad=0

If you want this portion can be encoded http://example.com/-example&blabla

You can try this and let me know.

You can refer this info here https://firebase.google.com/docs/dynamic-links/android

  • 1
    I have added more parameters as told by you, now how can I retrieve them when I receive the link? – Hammad Nasir Feb 08 '17 at 13:22
  • Did you see the extra parameters in the deeplink when call `AppInvite.AppInviteApi.getInvitation` if true, so can use a parse to get the parameters, maybe and split of "&". Right now i dont have an example because right now i am using Branchio. – Bryan Acuña Núñez Feb 08 '17 at 14:55
  • I'm unable to understand what you said here.. ^ – Hammad Nasir Feb 08 '17 at 17:03
  • I have explained the problem much clearly here: http://stackoverflow.com/q/42119692/6144372 Please have a look. – Hammad Nasir Feb 08 '17 at 17:23
0

replace

<data
       android:host="xxx.abc.com"
       android:scheme="https"/>

with

<data
       android:host="example.com"
       android:scheme="http"/>
0

I also faced this problem. The issue was the link which I'm receiving is "Long link". We can create two types of links from firebase:

  1. Short Link https://appcode.app.goo.gl/?email=abc@gmail.com
  2. Long Link https://appcode.app.goo.gl/?link=http://example.com/-example&apn=com.abc.xxx&amv=16&ad=0&extraParameter=null

So that's why I'm facing this issue. I solved it by fetching the whole link from

 Uri uriData = intent.data

And to fetch particular query param from the link:

  String email = uriData.getQueryParameter("email")

I hope it will help anyone!!

Deeksha
  • 536
  • 5
  • 14