1 回答
TA贡献1815条经验 获得超6个赞
好的,所以在敲了我的头这么多小时之后,我找到了一个解决方案,它帮助我找到了解决方案:
所以我从头开始: 1. 创建一个动态链接。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);
}
});
现在是测试您的应用程序的时候了:谷歌搜索您的网址,即 example555.page.link 之后,它会将您重定向到应用程序,然后您填写并输出。如果这有效,谢谢。
添加回答
举报