我已经成功实现了Firebase动态链接。我也创建了短动态链接,当单击链接时,它会重定向到应用程序或Playstore,但在iPhone链接中显示错误。当我检查控制台中已创建的链接时,它不会显示该链接。
但是,当尝试在控制台中手动创建相同的链接时,它表明该链接已存在。为什么链接没有列出?
我的代码:
Uri shortUrl;
public void buildDeepLink(@NonNull final Uri deepLink) {
shortUrl = deepLink;
String domain = "myapp.page.link";
Log.d("TAG::",">"+deepLink);
DynamicLink dynamicLink = FirebaseDynamicLinks.getInstance().createDynamicLink()
.setLink(deepLink)
.setDynamicLinkDomain(domain)
// Open links with this app on Android
.setAndroidParameters(new DynamicLink.AndroidParameters.Builder().build())
// Open links with com.example.ios on iOS
.setIosParameters(new DynamicLink.IosParameters.Builder("com.ios.myapp").build())
.buildDynamicLink();
Uri dynamicLinkUri = dynamicLink.getUri();
Log.d("TAG::",">"+dynamicLink.getUri());
String s = dynamicLinkUri.toString().replace("%2F","/" );
s= s.replace("%3A",":" );
s= s.replace("%3F","?" );
s =s.replace("%3D","=" );
Log.d("TAG::",">"+s);
buildShortLink(Uri.parse(s),0);
}
public void buildShortLink(@NonNull final Uri deepLink, int minVersion) {
shortUrl = deepLink;
Task<ShortDynamicLink> shortLinkTask = FirebaseDynamicLinks.getInstance().createDynamicLink()
.setLongLink(deepLink)
.buildShortDynamicLink()
.addOnCompleteListener(getActivity(), new OnCompleteListener<ShortDynamicLink>() {
@Override
public void onComplete(@NonNull Task<ShortDynamicLink> task) {
if (task.isSuccessful()) {
// Short link created
shortUrl = task.getResult().getShortLink();
Uri flowchartLink = task.getResult().getPreviewLink();
Log.d("TAG::",""+shortUrl+" , "+flowchartLink);
String s = shortUrl.toString().replace("%2F","/" );
s= s.replace("%3A",":" );
msg_body= Application.string(R.string
.sms_message_body)+s+Application.string(R.string.now_in)+
(message.replace("XXX",REF_KEY));
msg_body.replace("%3F","?" );
msg_body.replace("%3D","=" );
shareDeepLink(msg_body);
} else {
// Error
// ...
}
}
});
}
答案 0 :(得分:0)
对于在控制台中创建的链接,您只能在控制台的“动态链接”部分中查看“动态链接”统计信息。
对于以编程方式创建的链接,您将能够在控制台的“分析”部分看到一些link stats(例如app_open和app_first_open)。