Firebase动态链接在安装后首次启动时不会调用动态链接。

huangapple go评论66阅读模式
英文:

Firebase dynamic link doesn't invoke dynamic link on first launch after install

问题

以下是翻译好的内容:

我在 Stack Overflow 上阅读了许多问题,但没有一个解答了我的问题。

我正在尝试设置动态链接,以便如果用户已经安装了应用程序,链接将深层链接到应用程序,如果用户尚未安装,则链接将导航至 Play Store。我期望链接能在 Play Store 安装过程中保留,并且带着链接被发送到启动器活动。当应用程序已安装时,动态链接起作用。然而,当应用程序未安装时,它会将用户发送到 Play Store,但动态链接无法在安装过程中保留。我阅读到,“打开”按钮应该在用户通过动态链接发送到 Play Store 时变为“继续”,但当我这样做时,它仍然显示为“打开”。这是我在 AndroidManifest.xml 中为活动添加的内容:

<activity
    android:name="com.xxx.xxx.xxx.xxx"
    android:label="@string/app_name"
    android:theme="@style/AppTheme.SplashScreen">
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>

    <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="yyy.page.link"
            android:scheme="http" />
        <data
            android:host="yyy.page.link"
            android:scheme="https" />
    </intent-filter>
</activity>

活动代码如下:

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_ia_login);

    checkIfReferral();
}

private void checkIfReferral(){
    FirebaseDynamicLinks.getInstance()
            .getDynamicLink(getIntent())
            .addOnSuccessListener(this, new OnSuccessListener<PendingDynamicLinkData>() {
                @Override
                public void onSuccess(PendingDynamicLinkData pendingDynamicLinkData) {
                    // 获取深层链接(如果未找到链接,可能为 null)
                    Uri deepLink = null;
                    Log.w(TAG, "FBDL we have a dynamic link");
                    if (pendingDynamicLinkData != null) {
                        deepLink = pendingDynamicLinkData.getLink();
                    } else {
                        Log.w(TAG, "FBDL pending dynamic Link Data is null, returning");
                        return;
                    }
                    // 其余部分在这里被省略...
                }
            }).addOnFailureListener(this, new OnFailureListener() {
        @Override
        public void onFailure(@NonNull Exception e) {
            Log.w(TAG, "FBDL we couldnt receive dynamic link");
        }
    });

    // 下面的部分在这里被省略...
}

我已经添加了动态链接,它与清单文件中声明的内容相同。我已经添加了使用发布密钥生成的 SHA 256。应用程序已经发布到 Google Play Store 生产环境。

请告诉我错误在哪里。

为什么当动态链接将我带到 Google Play Store 时,我看不到“继续”按钮?

英文:

I have read a lot of question on stackoverflow but none of them answer the question.

I am trying to set up dynamic links so that a link will deep link the user to the app if they already have it installed and the play store if they don't. I expect the link to survive the play store installation process and be sent to the launcher activity with the link. The dynamic link works when the app is already installed. However, when the app is not installed, it sends the user to the play store but the dynamic link does not survive the installation process. I have read that the "Open" button is supposed to change to "Continue" when the user is sent to the play store with a dynamic link, but when I do it, it still says "Open". Here is my activity in AndroidManifest.xml for the activity

    &lt;activity
        android:name=&quot;com.xxx.xxx.xxx.xxx&quot;
        android:label=&quot;@string/app_name&quot;
        android:theme=&quot;@style/AppTheme.SplashScreen&quot;&gt;
        &lt;intent-filter&gt;
            &lt;action android:name=&quot;android.intent.action.MAIN&quot; /&gt;

            &lt;category android:name=&quot;android.intent.category.LAUNCHER&quot; /&gt;
        &lt;/intent-filter&gt;

        &lt;intent-filter&gt;
            &lt;action android:name=&quot;android.intent.action.VIEW&quot; /&gt;

            &lt;category android:name=&quot;android.intent.category.DEFAULT&quot; /&gt;
            &lt;category android:name=&quot;android.intent.category.BROWSABLE&quot; /&gt;

            &lt;data
                android:host=&quot;yyy.page.link&quot;
                android:scheme=&quot;http&quot; /&gt;
            &lt;data
                android:host=&quot;yyy.page.link&quot;
                android:scheme=&quot;https&quot; /&gt;
        &lt;/intent-filter&gt;
    &lt;/activity&gt;

The Activity is as follows:

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_ia_login);

        checkIfReferral();
    }

    private void checkIfReferral(){
    FirebaseDynamicLinks.getInstance()
            .getDynamicLink(getIntent())
            .addOnSuccessListener(this, new OnSuccessListener&lt;PendingDynamicLinkData&gt;() {
                @Override
                public void onSuccess(PendingDynamicLinkData pendingDynamicLinkData) {
                    // Get deep link from result (may be null if no link is found)
                    Uri deepLink = null;
                    Log.w(TAG, &quot;FBDL we have a dynamic link&quot;);
                    if (pendingDynamicLinkData != null) {
                        deepLink = pendingDynamicLinkData.getLink();
                    }else{
                        Log.w(TAG, &quot;FBDL pending dynamic Link Data is null , returning &quot; );
                        return;
                    }
                    FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();
                    Boolean ret1 = (user==null);
                    Boolean ret2 = (deepLink !=null);
                    Boolean ret3 = (deepLink.getBooleanQueryParameter(&quot;invitedby&quot;, false));
                    referrerUid = deepLink.getQueryParameter(&quot;invitedby&quot;);                   
                    if (deepLink != null &amp;&amp; deepLink.getBooleanQueryParameter(&quot;invitedby&quot;, false)) {
                        referrerUid = deepLink.getQueryParameter(&quot;invitedby&quot;);
                        createAnonymousAccountWithReferrerInfo(referrerUid);
                    }
                }
            }).addOnFailureListener(this, new OnFailureListener() {
        @Override
        public void onFailure(@NonNull Exception e) {
            Log.w(TAG, &quot;FBDL we couldnt receive dynamic link&quot;);
        }
    });

    FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();
    if(user !=null) {
        Log.w(TAG, &quot;FBDL if use != null&quot;);
        userRecord = FirebaseDatabase.getInstance().getReference()
                .child(&quot;users&quot;)
                .child(user.getUid());
    }
}

I have added the dynamic link. It is the same as declared in the manifest file. I have added SHA 256 generated from the release key that i signed the app with. The app is on Google Play Store production release.

Please let me know what the mistake is.

Why don't I see "continue" on the Google Play store when dynamic link took me there?

答案1

得分: 3

你需要在将处理动态链接的Activity中添加一个自动验证的意图过滤器,将主机设置为在Firebase控制台中找到的项目的动态链接域。在 AndroidManifest.xml 文件中:

<intent-filter android:autoVerify="true">
    <action android:name="android.intent.action.VIEW"/>
    <category android:name="android.intent.category.DEFAULT"/>
    <category android:name="android.intent.category.BROWSABLE"/>
    <data android:host="yyy.page.link" android:scheme="http"/>
    <data android:host="yyy.page.link" android:scheme="https"/>
</intent-filter>

请注意,android:host 必须设置为您的动态链接域,而不是您的深层链接域。

更多信息请参见此处

英文:

You have to add an auto-verified intent filter to the Activity that will handle the Dynamic Link, setting the host to your project's Dynamic Links domain as found in the Firebase console. In the AndroidManifest.xml:

&lt;intent-filter android:autoVerify=&quot;true&quot;&gt;
    &lt;action android:name=&quot;android.intent.action.VIEW&quot;/&gt;
    &lt;category android:name=&quot;android.intent.category.DEFAULT&quot;/&gt;
    &lt;category android:name=&quot;android.intent.category.BROWSABLE&quot;/&gt;
    &lt;data android:host=&quot;yyy.page.link&quot; android:scheme=&quot;http&quot;/&gt;
    &lt;data android:host=&quot;yyy.page.link&quot; android:scheme=&quot;https&quot;/&gt;
&lt;/intent-filter&gt;

Note that the android:host must be set to your Dynamic Links domain, and not the domain of your deep link.

More informations here

答案2

得分: 1

我看到在你的Firebase Dynamic Links实现中已启用了应用链接(App Links)。应用链接需要将动态链接域添加到清单(Manifest)的intent-filter中,但动态链接仍需要具有用于深层链接的intent-filter,以便应用接收。通过在intent-filter中添加深层链接,不仅使FDL与应用程序配合使用,而且还确保如果使用常规链接,应用程序仍将正常工作。

如果在此之后问题仍然存在,您可以在此处提交工单:https://firebase.google.com/support。您可能需要共享动态链接和您使用的Firebase SDK版本。

英文:

I see that App Links is enabled in your implementation of Firebase Dynamic Links. App Links require the Dynamic Link domain to be added in the Manifest intent-filter, but Dynamic Links still needs to have intent-filter for the deep links that the app will receive. By adding deep links in the intent-filter, not only that it makes FDL to work with the app, but it also ensures that the app will still work if a regular link is used.

If you're still having issues after this, you can file a ticket here https://firebase.google.com/support. You may need to share the Dynamic Link and the Firebase SDK version you're using.

答案3

得分: 0

我认为你需要为你的应用启用链接处理验证。[这里有更多详细信息][1]

    <intent-filter android:autoVerify="true">
        <action android:name="android.intent.action.VIEW"/>
        <category android:name="android.intent.category.DEFAULT"/>
        <category android:name="android.intent.category.BROWSABLE"/>
        <data android:host="yyy.page.link" android:scheme="https"/>
    </intent-filter>

[1]: https://developer.android.com/training/app-links/verify-site-associations#request-verify
英文:

i think you need to enable link handling verification for your app. here is more details

&lt;intent-filter  android:autoVerify=&quot;true&quot;&gt;
    &lt;action android:name=&quot;android.intent.action.VIEW&quot;/&gt;
    &lt;category android:name=&quot;android.intent.category.DEFAULT&quot;/&gt;
    &lt;category android:name=&quot;android.intent.category.BROWSABLE&quot;/&gt;
    &lt;data android:host=&quot;yyy.page.link&quot; android:scheme=&quot;https&quot;/&gt;
&lt;/intent-filter&gt;

答案4

得分: 0

一个动态链接是指一个深层链接,可以在您的应用安装与否的情况下运行。在桌面上,它将转到深层链接的URL

请检查您的移动浏览器模式。桌面模式是否已启用?如果是的话,在链接点击时,它将仅重定向到URL,而不会转到Google Play商店。

英文:

A Dynamic Link is a deep link into your app that works whether or not your app is installed. On desktop it will go to the deep link URL

Please check your mobile browser mode. Is desktop mode enabled? if yes, then on link click, it will redirect on URL only not to google play store.

huangapple
  • 本文由 发表于 2020年10月13日 01:15:09
  • 转载请务必保留本文链接:https://go.coder-hub.com/64322384.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定