Firebase深度链接打开Play商店而不是App [英] Firebase Deep Link Opens the Play Store instead of App

查看:430
本文介绍了Firebase深度链接打开Play商店而不是App的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我是Firebase动态链接的新手,自己学习它,我一直在关注教程即可完成。

Hello there I am new to Firebase Dynamic Links and learning it to my own, I have been following this tutorial to get through it.

我的代码创建方法是:

private void createLink() {
        String link = "https://play.google.com/store/apps/details?id=com.test.app&referrer="+"test1234" ;
        FirebaseDynamicLinks.getInstance().createDynamicLink()
                .setLink(Uri.parse(link))
                .setDynamicLinkDomain("testxyz.page.link")
                .setAndroidParameters(
                        new DynamicLink.AndroidParameters.Builder("com.test.app")
                                .setMinimumVersion(125)
                                .build())
                .buildShortDynamicLink().addOnFailureListener(new OnFailureListener() {
            @Override
            public void onFailure(@NonNull Exception e) {
                Log.e("xyz", "error:::" + e.toString());
            }
        })
                .addOnSuccessListener(new OnSuccessListener<ShortDynamicLink>() {
                    @Override
                    public void onSuccess(ShortDynamicLink shortDynamicLink) {
                        Log.e("xyz", "link:::" + shortDynamicLink.getShortLink());
                    }
                });
    }

它给我的网址是: https://testxyz.page.link/RhSKMYMnE2YHLbZk6
复制并粘贴到浏览器中它运行正常,将我带到Play商店,并显示了我要使用此链接打开的所需应用,该链接的应用ID为: com.test.app

我要做的测试是从安装了应用程序ID为 com.test.app 的应用程序的Android手机中单击该URL,应使用我单击的URL来打开该URL。 !

What I done for testing is to click on this url from my Android Phone that has the app installed with app id: com.test.app that it should be opened with the URL I clicked!

我在我的应用程序中收到ID为 com.test.app 的链接,其方法为:

I am receiving the Link in my app with id: com.test.app with method:

private void check(){
        FirebaseDynamicLinks.getInstance()
                .getDynamicLink(getIntent())
                .addOnSuccessListener(this, new OnSuccessListener<PendingDynamicLinkData>() {
                    @Override
                    public void onSuccess(PendingDynamicLinkData pendingDynamicLinkData) {
                        // Get deep link from result (may be null if no link is found)
                        Uri deepLink = null;
                        if (pendingDynamicLinkData != null) {
                            deepLink = pendingDynamicLinkData.getLink();
                            Log.e("deeplink","link:::"+deepLink);
                            Toast.makeText(IndexActivity.this, "link:::"+deepLink, Toast.LENGTH_SHORT).show();
                        }else{
                            Log.e("deeplink","link is null:::");
                            Toast.makeText(IndexActivity.this, "link is null:::", Toast.LENGTH_SHORT).show();
                        }
                        //
                        // If the user isn't signed in and the pending Dynamic Link is
                        // an invitation, sign in the user anonymously, and record the
                        // referrer's UID.
                        //

                    }
                });
    }

此方法放置在Splash活动之后的主要活动中!

This method is being placed inside my main activity that comes after my Splash activity!

清单中的内容如下:

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

        </activity>






问题:
当我单击我的Firebase生成了Dynamic Link,它可以正常工作,并带我进入浏览器,并使用所需的应用程序打开了Google Play商店。


The Problem: When i clicked my Firebase generated Dynamic Link it works and takes me to the browser and opened the Google Play Store with my required app.

我想要打开的应用程序并获取引荐来源网址的动态链接信息!

What I want is to open the app and get the dynamic link info for the referrer!

我做错了,因为我完全不了解Firebase深度链接,所以我不知道。

What I am doing wrong is that I have no idea because I am totaly new to Firebase Deep Linking.

实际上,我想创建一个链接,该链接可以使用我的用户名发送给其他用户,如果用户单击该链接,则会打开该应用程序(如果已安装,如果未安装)已安装将用户带到应用程序商店安装应用程序并获取引荐来源网址

Actually I want to create a link that I can send to the other user with my username and if the user clicks that link will open up the app if installed and if not installed take the user to the app store installs the app and get the deep link info for referrer

感谢任何帮助或教程,谢谢

Any help or tutorial is heighly appreciated, thanks in advance!

推荐答案

将您的android参数设置如下:

Set your android parameter as follow:

setAndroidParameters(new DynamicLink.AndroidParameters.Builder(BuildConfig.APPLICATION_ID)
                                .setMinimumVersion(1)
                                .build())

您的动态链接无法打开您的应用程序,因为您没有在Android参数中定义包。

Your dynamic link is not able to open your app because you are not defining your package in Android parameter.



请注意: Firebase的构造函数看起来像默认添加了程序包名称,但是它不起作用。


Be careful: The constructor of Firebase looks like adding package name as default, but it does not works.

public Builder() {
    if (FirebaseApp.getInstance() == null) {
        throw new IllegalStateException("FirebaseApp not initialized.");
    } else {
        this.zzf = new Bundle();
        this.zzf.putString("apn", FirebaseApp.getInstance().getApplicationContext().getPackageName());
    }
}

这篇关于Firebase深度链接打开Play商店而不是App的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆