问题描述
创建动态链接
DynamicLink dynamicLink = FirebaseDynamicLinks.getInstance().createDynamicLink()
.setLink(Uri.parse("http://shaharapp.in/"))
.setDynamicLinkDomain("https://cuh8g.app.goo.gl/")
// Open links with this app on Android
.setAndroidParameters(new DynamicLink.AndroidParameters.Builder().build())
// Open links with com.example.ios on iOS
.buildDynamicLink();
dynamicLinkUri = dynamicLink.getUri();
在此之后,我得到了很长的动态链接.将此dynamicLinkUri传递给shortLinkTask
after this, i get a long dynamic link.passing this dynamicLinkUri to shortLinkTask
Task<ShortDynamicLink> shortLinkTask = FirebaseDynamicLinks.getInstance().createDynamicLink()
.setLongLink(dynamicLinkUri)
.buildShortDynamicLink();
shortLinkTask.addOnCompleteListener(new OnCompleteListener<ShortDynamicLink>() {
@Override
public void onComplete(@NonNull Task<ShortDynamicLink> task) {
if (task.isSuccessful()) {
Uri shortLink = task.getResult().getShortLink();
link_txt.setText(shortLink.toString());
}
else {
ViewGroup container = (ViewGroup) findViewById(R.id.snackbar_layout);
Snackbar.make(container, "error", Snackbar.LENGTH_SHORT).show();
}
}
});
此任务未完成,调试后我得到了
This task is not completing, after debugging I got this
推荐答案
您得到的长链接是什么?我建议尝试长链接,并确保链接正常工作.
What is the long link you are getting? I suggest trying long link and ensure the link works correctly.
此外,将&d=1
附加到长链接.这样的链接将导航到调试页面,并显示可能的错误/警告.
Also, append &d=1
to long link. Such link will navigate to debug page with possible errors/warnings displayed.
查看您的代码,失败的可能原因之一是域的格式.请参阅示例 https://firebase.google.com/docs/dynamic-links/android/create .域应该是仅包含域的字符串,没有https方案:
Looking at your code, one possible reason for failure is format of the domain. See example https://firebase.google.com/docs/dynamic-links/android/create . Domain expected to be string containing only domain, without https scheme:
.setDynamicLinkDomain("abc123.app.goo.gl")
这篇关于ShortDynamicLink不会为动态链接生成短链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!