Why full/long dynamic link is not getting retrieved/received?

好久不见. 提交于 2019-12-28 07:05:11

问题


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?


回答1:


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




回答2:


replace

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

with

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


来源:https://stackoverflow.com/questions/42093902/why-full-long-dynamic-link-is-not-getting-retrieved-received

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!