我想在我的应用程序中添加引荐系统。我正在使用Firebase动态链接。但是当其他用户安装该应用程序时无法收听。如果有人使用动态链接安装该应用程序,则发件人将获得一些要点。是我生成短链接的代码。
public static Uri buildDeepLink( String product_name, int minVersion) {
String DEEP_LINK_URL = null;
FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();
String uid = user.getUid();
String domain = "example.com";
JSONObject json_data = new JSONObject();
JSONObject json_parent = new JSONObject();
try {
json_data.put("useremail",product_name);
json_parent.put("data",json_data);
DEEP_LINK_URL = "https://example.com/?invitedby=" + product_name;
} catch (JSONException e) {
e.printStackTrace();
}
DynamicLink dynamicLink = FirebaseDynamicLinks.getInstance().createDynamicLink()
.setLink(Uri.parse(DEEP_LINK_URL))
.setDynamicLinkDomain(domain)
.setAndroidParameters(new DynamicLink.AndroidParameters.Builder()
.setMinimumVersion(minVersion)
.build())
.buildDynamicLink();
return dynamicLink.getUri();
}
这是侦听的代码。但是此侦听器始终提供空的深层链接。
FirebaseDynamicLinks.getInstance()
.getDynamicLink(getIntent())
.addOnSuccessListener(this, new OnSuccessListener<PendingDynamicLinkData>() {
@Override
public void onSuccess(PendingDynamicLinkData pendingDynamicLinkData) {
//Get dynamic link from result (may be null if no link is found)
Uri deepLink = null;
if (pendingDynamicLinkData != null) {
deepLink = pendingDynamicLinkData.getLink();
}
if (deepLink != null) {
String referrerUid = deepLink.getQueryParameter("invitedby");
Toast.makeText(getApplicationContext(),referrerUid,Toast.LENGTH_LONG).show();
sendReward(referrerUid);
}
//Here, Handle deep link. For example open the linked content.
//Display deep link in UI
}
})
.addOnFailureListener(this, new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
}
});