Android   发布时间:2022-04-28  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了android – Firebase动态链接在特定情况下没有启动我的应用程序大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我已经为用户创建了一个动态链接,可以在我的应用中分享一些内容.

当我在Android设备上使用href标记单击HTML页面中的链接时,该链接正在运行.

这意味着,如果未安装应用程序,请转到Play商店,否则打开应用程序,我就可以收到深层链接地址.

但是当链接在Facebook信使或电子邮件等其他地方完全相同时,我点击链接,然后它就不起作用了.

即使我的应用已经安装,它也始终会重定向到Play商店.

有什么问题?

我的代码在这里.

> .java用于接收深层链接

GoogleApiClient mGoogleApiClient = new GoogleApiClient.builder(this)
        .enableAutoManage(this,this)
        .addApi(AppInvite.API)
        .build();

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();
                            String deepLink = AppInviteReferral.getDeepLink(intent);

                            Log.e("sf","### deep link : " + deepLink );
                        } else {
                            Log.d("asdf","geTinvitation: no deep link found.");
                        }
                    }
                });

> AndroidManifest.xml中活动的意图部分

<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="mycode.app.goo.gl/"
            android:scheR_871_11845@e="https"
            android:pathPattern=".*" />
    </intent-filter>

>动态链接https://mycode.app.goo.gl/?link=web页面地址& al =我的@L_489_24@方案共享& apn =我的Android应用程序的包名称

解决方法

我们已根据此文档 https://firebase.google.com/docs/dynamic-links/实施了Firebase动态链接,除Facebook和Facebook Messenger应用程序外,它们在所有情况下都能正常运行.

首先,我们为@R_27_9616@生成动态链接

Builder builder = new Builder()
  .scheR_871_11845@e("https")
  .authority("winged-guild-133523.appspot.com")
  .appendPath("share")
  .appendQueryParameter("query",query);

然后我们生成长动态链接

Builder builder = new Builder()
  .scheR_871_11845@e("https")
  .authority("zkkf4.app.goo.gl")
  .appendPath("")
  .appendQueryParameter("link",deepLink)
  .appendQueryParameter("apn","com.mydomain.myapp");

然后我们在https://firebasedynamiclinks.googleapis.com/v1/shortLinks用短链接交换长动态链接并使用意图共享它:

Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_TEXT,text);
startActivity(Intent.createChooser(intent,null));

如果我们使用Facebook应用分享链接

>正确分享链接.
>如果未安装该应用程序,则单击Facebook应用程序中的链接可正常进入Google Play,并在安装应用程序后正确处理深层链接.
>如果安装了应用程序,点击Facebook应用程序中的链接也会转到Google Play,点击打开按钮后,深层链接不会转移到应用程序,因为如果安装有Google Play,则不会将引荐来源信息传递给应用程序没有被执行过.

如果我们使用Facebook Messenger app分享链接

>该链接共享为https://l.facebook.com/l.php?u=https%3A%2F%2Fwinged-guild-133523.appspot.com%2Fshare%3Fquery%3Dquery&h=fAQEAiTGn&s=1
>如果安装了应用程序,单击Facebook Messenger应用程序中的链接将转到深层链接目标(我们的网站)而不是Google Play.
>如果已安装该应用程序,则单击Facebook Messenger应用程序中的链接可正确打开该应用程序.

所以我在这里看到三个问题:

> Facebook应用程序未正确检测到应用程序已安装.
> Facebook Messenger应用程序共享一个长动态链接而不是短链接.
> Facebook Messenger应用程序可以检测到应用程序已安装,但如果未安装该应用程序,则会转到链接而不是Google Play.

有谁知道如何解决这些问题?

PS:然这是无关紧要的,因为应用程序中的深层链接处理工作正常,这是我们的明显意图过滤器:

<intent-filter>
    <action android:name="android.intent.action.MAIN"/>
    <category android:name="android.intent.category.LAUNCHER"/>
  </intent-filter>

  <intent-filter android:label="@String/app_name">
    <action android:name="android.intent.action.VIEW"/>
    <category android:name="android.intent.category.DEFAULT"/>
    <category android:name="android.intent.category.bROWSABLE"/>
    <data android:scheR_871_11845@e="http"/>
    <data android:scheR_871_11845@e="https"/>
    <data android:host="winged-guild-133523.appspot.com"/>
    <data android:host="www.winged-guild-133523.appspot.com"/>
    <data android:pathPattern="/share.*"/>
  </intent-filter>

大佬总结

以上是大佬教程为你收集整理的android – Firebase动态链接在特定情况下没有启动我的应用程序全部内容,希望文章能够帮你解决android – Firebase动态链接在特定情况下没有启动我的应用程序所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。