我正在尝试创建一个动态链接,当我尝试调试代码时,它调用了回调方法addOnSuccessListener,但之后它没有调用或我们说它正在跳过方法onSuccess()而我没有得到任何线索为什么它正在发生。
private void firebaseInvite() {
FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();
String uid = user.getUid();
String url = "https://larky.funswitch.io/?invitedby=" + uid;
FirebaseDynamicLinks.getInstance().createDynamicLink()
.setLink(Uri.parse(url))
.setDynamicLinkDomain("https://fmu3k.app.goo.gl")
.setAndroidParameters(
new DynamicLink.AndroidParameters.Builder("io.funswitch.funrooster")
.setMinimumVersion(5)
.build())
.buildShortDynamicLink()
.addOnSuccessListener(shortDynamicLink -> {
在此之后我的调试器跳过此代码并且没有调用
mInvitationUrl = shortDynamicLink.getShortLink();
mDatabase.child("Name").addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
String referrerName = dataSnapshot.getValue(String.class);
String subject = String.format("%s wants you to play MyExampleGame!", referrerName);
String invitationLink = mInvitationUrl.toString();
String msg = "Let's play MyExampleGame together! Use my referrer link: "
+ invitationLink;
String msgHtml = String.format("<p>Let's play MyExampleGame together! 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(getActivity().getPackageManager()) != null) {
startActivity(intent);
}
}
@Override
public void onCancelled(@NonNull DatabaseError databaseError) {
}
});
});
}
请帮帮我..
答案 0 :(得分:2)
我得到它解决它是非常基本的愚蠢错误我实际上链接不解析上面的代码因为我已经在动态链接域和动态链接域中提到https两次从动态链接域删除https我得到它的工作
private void firebaseInvite() {
FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();
String uid = user.getUid();
String url = "https://larky.funswitch.io/?invitedby=" + uid;
FirebaseDynamicLinks.getInstance().createDynamicLink()
.setLink(Uri.parse(url))
.setDynamicLinkDomain("fmu3k.app.goo.gl")
.setAndroidParameters(
new DynamicLink.AndroidParameters.Builder("io.funswitch.funrooster")
.setMinimumVersion(5)
.build())
.buildShortDynamicLink()
.addOnSuccessListener(shortDynamicLink -> {
mInvitationUrl = shortDynamicLink.getShortLink();
mDatabase.child("Name").addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
String referrerName = dataSnapshot.getValue(String.class);
String subject = String.format("%s wants you to play MyExampleGame!", referrerName);
String invitationLink = mInvitationUrl.toString();
String msg = "Let's play MyExampleGame together! Use my referrer link: "
+ invitationLink;
String msgHtml = String.format("<p>Let's play MyExampleGame together! 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(getActivity().getPackageManager()) != null) {
startActivity(intent);
}
}
@Override
public void onCancelled(@NonNull DatabaseError databaseError) {
}
});
});
}