我無法使用Android Firebase邀請SDK創建ShortDynamicLink。我可以創建很長的DynamicLink,但仍然無法創建ShortDynamic鏈接,並始終給出錯誤消息Bad Request。下面是代碼:Firebase Dynamic Link ShortUrl未在Android中使用
private void sendInvite(String uid, final String displayName){
String link = "https://appdomain.com/?invitedby=" + uid;
com.google.android.gms.tasks.Task<ShortDynamicLink> shortLinkTask = FirebaseDynamicLinks.getInstance().createDynamicLink()
.setLink(Uri.parse(link))
.setDynamicLinkDomain(Constants.DYNAMIC_LINK_DOMAIN)
.buildShortDynamicLink()
.addOnCompleteListener(mActivity, new OnCompleteListener<ShortDynamicLink>() {
@Override
public void onComplete(@NonNull com.google.android.gms.tasks.Task<ShortDynamicLink> task) {
if (task.isSuccessful()){
Uri shortLink = task.getResult().getShortLink();
// String referrerName = SettingsHelper.getHelper(mActivity).getDisplayName();
String subject = String.format("%s wants you to try Awesome App!", displayName);
String invitationLink = shortLink.toString();
String msg = "Enjoy and share your moments with Awesome App! Use my referrer link: "
+ invitationLink;
String msgHtml = String.format("<p>Start having fun with Awesome App's! Use my "
+ "<a href=\"%s\">referrer link</a>!</p>", invitationLink);
Intent intent = new Intent(Intent.ACTION_SENDTO);
intent.setData(Uri.parse("mailto:")); // only email apps should handle this
intent.putExtra(Intent.EXTRA_SUBJECT, subject);
intent.putExtra(Intent.EXTRA_TEXT, msg);
intent.putExtra(Intent.EXTRA_HTML_TEXT, msgHtml);
if (intent.resolveActivity(getPackageManager()) != null) {
startActivity(intent);
}
}else {
String errorMessage = task.getException().getMessage();
Log.d(TAG, "Error creating Dynamic link " + errorMessage);
}
}
});
}
我可以創建從控制檯很短的動態鏈接,但我希望能夠以編程方式從client.I創建使用MOS當前版本Android的SDK版本11.22.1
感謝您的指針,問題是,有一個在應用程序域尾部斜槓。 –
很高興知道。在GMS Core v14即將推出的FDL Android更新中,將爲這些情況帶來更多描述性錯誤消息。 –