我无法通过我的应用程序从 firebase 检索动态链接,因为 pendingdynamiclin

我正在尝试从firebase检索深层链接URL ,但始终显示为 null。

我在清单中添加了以下代码,我也尝试使用短动态 URL,即https://example555.page.link/y6N7但它仍然显示为空。

            <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="example555.page.link"

                android:scheme="https"

                 />


        </intent-filter>

这是我检索动态链接的代码:


             FirebaseDynamicLinks.getInstance()

             .getDynamicLink(getIntent())

             .addOnSuccessListener(this, new 

             OnSuccessListener<PendingDynamicLinkData>() {

            @Override

             public void onSuccess(PendingDynamicLinkData 

             pendingDynamicLinkData) {

              Uri deepLink = null;


                if (pendingDynamicLinkData != null) {

                    deepLink = pendingDynamicLinkData.getLink();

                }

            }

        })

        .addOnFailureListener(this, new OnFailureListener() {

            @Override

            public void onFailure(@NonNull Exception e) {

                Log.w(TAG, "getDynamicLink:onFailure", e);

            }

        });


慕尼黑5688855
浏览 106回答 1
1回答

红糖糍粑

好的,所以在敲了我的头这么多小时之后,我找到了一个解决方案,它帮助我找到了解决方案:所以我从头开始: 1. 创建一个动态链接。2.将以下代码添加到您的清单&nbsp; &nbsp; &nbsp; <intent-filter>&nbsp; &nbsp; &nbsp; &nbsp; <action android:name="android.intent.action.VIEW"/>&nbsp; &nbsp; &nbsp; &nbsp; <category android:name="android.intent.category.DEFAULT"/>&nbsp; &nbsp; &nbsp; &nbsp; <category android:name="android.intent.category.BROWSABLE"/>&nbsp; &nbsp; &nbsp; &nbsp; <data&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:host="example555.page.link"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:scheme="https"/>&nbsp; &nbsp; </intent-filter>在您的主要活动中添加此代码:&nbsp; &nbsp; &nbsp; &nbsp;FirebaseAnalytics mFirebaseAnalytics;&nbsp; &nbsp; &nbsp; &nbsp; mFirebaseAnalytics=FirebaseAnalytics.getInstance(this);&nbsp; &nbsp; &nbsp; &nbsp; FirebaseDynamicLinks.getInstance()&nbsp; &nbsp; &nbsp; &nbsp; .getDynamicLink(getIntent())&nbsp; &nbsp; &nbsp; &nbsp; .addOnSuccessListener(this, new&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;OnSuccessListener<PendingDynamicLinkData>() {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; @Override&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; public void onSuccess(PendingDynamicLinkData pendingDynamicLinkData) {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // Get deep link from result (may be null if no link is found)&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Uri deepLink = null;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (pendingDynamicLinkData != null) {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; deepLink = pendingDynamicLinkData.getLink();&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Log.w("deepLink", "" + deepLink);&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;String cn=String.valueOf(deepLink.getQueryParameters("utm_campaign"));&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; String cm = String.valueOf(deepLink. getQueryParameters("utm_medium"));&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; String cs = String.valueOf(deepLink.getQueryParameters("utm_source"));&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (cs != null && cn != null) {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Bundle params = new Bundle();&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; params.putString(FirebaseAnalytics.Param.CAMPAIGN, cn);&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; params.putString(FirebaseAnalytics.Param.MEDIUM, cm);&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; params.putString(FirebaseAnalytics.Param.SOURCE, cs);&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; mFirebaseAnalytics.logEvent(FirebaseAnalytics.Event.CAMPAIGN_DETAILS, params);&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; mFirebaseAnalytics.logEvent(FirebaseAnalytics.Event.APP_OPEN, params);&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; &nbsp; &nbsp; })&nbsp; &nbsp; &nbsp; &nbsp; .addOnFailureListener(this, new OnFailureListener() {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; @Override&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; public void onFailure(@NonNull Exception e) {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Log.w("TAG", "getDynamicLink:onFailure", e);&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; &nbsp; &nbsp; });现在是测试您的应用程序的时候了:谷歌搜索您的网址,即 example555.page.link 之后,它会将您重定向到应用程序,然后您填写并输出。如果这有效,谢谢。
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Java