gpt4 book ai didi

android - onSuccess 方法不在 android 中调用 firebase

转载 作者:搜寻专家 更新时间:2023-11-01 09:25:57 24 4
gpt4 key购买 nike

我正在尝试创建一个动态链接,当我尝试调试代码时,它正在调用回调方法 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) {

}
});

});
}

请帮帮我..

最佳答案

我解决了这是非常基本的愚蠢错误我正在做实际上链接没有在上面的代码中解析因为我在动态链接和动态链接域中提到了两次 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) {

}
});

});
}

关于android - onSuccess 方法不在 android 中调用 firebase,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50654241/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com