1 回答

TA貢獻(xiàn)1815條經(jīng)驗 獲得超6個贊
好的,所以在敲了我的頭這么多小時之后,我找到了一個解決方案,它幫助我找到了解決方案:
所以我從頭開始: 1. 創(chuàng)建一個動態(tài)鏈接。2.將以下代碼添加到您的清單
<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>
在您的主要活動中添加此代碼:
FirebaseAnalytics mFirebaseAnalytics;
mFirebaseAnalytics=FirebaseAnalytics.getInstance(this);
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.w("deepLink", "" + deepLink);
String cn=String.valueOf(deepLink.getQueryParameters("utm_campaign"));
String cm = String.valueOf(deepLink. getQueryParameters("utm_medium"));
String cs = String.valueOf(deepLink.getQueryParameters("utm_source"));
if (cs != null && cn != null) {
Bundle params = new Bundle();
params.putString(FirebaseAnalytics.Param.CAMPAIGN, cn);
params.putString(FirebaseAnalytics.Param.MEDIUM, cm);
params.putString(FirebaseAnalytics.Param.SOURCE, cs);
mFirebaseAnalytics.logEvent(FirebaseAnalytics.Event.CAMPAIGN_DETAILS, params);
mFirebaseAnalytics.logEvent(FirebaseAnalytics.Event.APP_OPEN, params);
}
}
}
})
.addOnFailureListener(this, new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
Log.w("TAG", "getDynamicLink:onFailure", e);
}
});
現(xiàn)在是測試您的應(yīng)用程序的時候了:谷歌搜索您的網(wǎng)址,即 example555.page.link 之后,它會將您重定向到應(yīng)用程序,然后您填寫并輸出。如果這有效,謝謝。
添加回答
舉報