我对firebase创建的shortLink有一个小问题。 我是应用程序的Android开发人员,可能有两种情况,首先是URL,我从服务器获取此URL,该URL是我使用firebase创建DeepLink时使用的,第二种情况是从服务器获取的URL可能被firebase缩短,以及何时我尝试创建深度链接,但Firebase不允许为短链接创建短链接。
DynamicLink.Builder builder;
try {
shareData = (ShareData) activity;
} catch (ClassCastException e) {
throw new ClassCastException(this.toString() +
"you must implement ShareData interface in this class");
}
String domain = getString(R.string.fire_base_domain);
showDialog();
Uri uri = Uri.parse(url);
if (deelink) {
builder = FirebaseDynamicLinks.getInstance().createDynamicLink()
.setLink(uri)
.setDynamicLinkDomain(domain)
.setAndroidParameters(new DynamicLink.AndroidParameters.Builder("com.example.anyThing")
.setFallbackUrl(uri)
.build())
.setIosParameters(new DynamicLink.IosParameters.Builder("com.example.anyThing")
.setAppStoreId("1321645123541313541")
.setFallbackUrl(uri)
.build())
.setSocialMetaTagParameters(new DynamicLink.SocialMetaTagParameters.Builder()
.setTitle(title)
.setDescription(description)
.setImageUrl(Uri.parse(imageUrl))
.build());
} else {
builder = FirebaseDynamicLinks.getInstance().createDynamicLink()
.setLink(uri)
.setDynamicLinkDomain(domain)
.setSocialMetaTagParameters(new DynamicLink.SocialMetaTagParameters.Builder()
.setTitle(title)
.setDescription(description)
.setImageUrl(Uri.parse(imageUrl))
.build());
}
builder.buildShortDynamicLink()
.addOnCompleteListener(new OnCompleteListener<ShortDynamicLink>() {
@Override
public void onComplete(@NonNull Task<ShortDynamicLink> task) {
if (task.isSuccessful()) {
Uri shortLink = task.getResult().getShortLink();
shareData.shareData(shortLink);
} else {
shareData.shareData(null);
}
hideDialog();
}
});
我问是否有一种方法可以检查我是否从服务器获取的URL是否短路。