为什么我无法从Android中的Firebase深层链接网址获取查询参数?

问题描述 投票:1回答:1

我试图从这个简短的动态链接获取查询参数:https://easyloans.page.link/test

长动态链接:https://easyloans.page.link/?link=https://www.availfinance.in&apn=com.avail.easyloans.android&utm_campaign=Test_Campaign_Name&utm_medium=Test_Medium&utm_source=Test_Source

清单:

<activity android:name=".Activites.DynamicLink">
    <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="easyloans.page.link"
                android:scheme="http"
                android:pathPrefix="/"
                android:pathPattern=".*"/>
            <data
                android:host="easyloans.page.link"
                android:scheme="https"
                android:pathPrefix="/"
                android:pathPattern=".*"/>
    </intent-filter>
</activity>

在Android活动中:

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.d(TAG, "source : " + pendingDynamicLinkData.getLink().getQueryParameter("utm_source"));
            }

            Log.d(TAG, "link " + deepLink);

        }
    })
    .addOnFailureListener(this, new OnFailureListener() {
        @Override
        public void onFailure(@NonNull Exception e) {
            Log.d(TAG, "getDynamicLink:onFailure", e);
        }
    });

我收到的输出是:链接https://www.availfinance.in和source:null(我期待这里的Test_Source)

android firebase deep-linking firebase-dynamic-links
1个回答
3
投票

getLink()方法返回您在长FDL上设置的link参数,在您的示例链接中就是返回的内容:link = https://www.availfinance.in

UTM参数会自动传递到Google Analytics for Firebase。

pendingDynamicLinkData.getLink().getQueryParameter("foo")只有在link参数中包含的URL上才会返回值,例如如果您的链接是link = https://www.availfinance.in/?foo=bar(具有适当的URL编码)。

© www.soinside.com 2019 - 2024. All rights reserved.