gpt4 book ai didi

android - 使用 Firebase 的应用程序邀请不起作用

转载 作者:塔克拉玛干 更新时间:2023-11-02 20:46:14 26 4
gpt4 key购买 nike

开发一个以 Firebase 作为后端的应用程序。目前,在实现 Firebase App Invite 时卡住了。只是想发送邀请(目前没有尝试实现安装的新用户点击动态链接)但是 onActivityResult 返回错误的 result_code

遵循的步骤

  • 集成 FireBase SDK 并成功验证。
  • 启用 Firebase 动态链接并在应用中引用
  • 点击邀请按钮会显示内置的 Firebase Activity ,其中包含选择要邀请和发送的用户(短信或电子邮件邀请)的选项
  • 应用按预期返回邀请屏幕。

代码 fragment

邀请 Activity

 btnInvite.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new AppInviteInvitation.IntentBuilder(INVITATION_TITLE)
.setMessage(INVITATION_MESSAGE)
.setDeepLink(Uri.parse("https://ewyc6.app.goo.gl/eNh4"))
.setCallToActionText(INVITATION_CALL_TO_ACTION)
.build();
startActivityForResult(intent, REQUEST_INVITE);
}
});

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
Log.d(TAG, "onActivityResult: requestCode=" + requestCode + ", resultCode=" + resultCode + "result_ok ="+RESULT_OK);

if (requestCode == REQUEST_INVITE) {
if (resultCode == RESULT_OK) {

// You successfully sent the invite,
// we can dismiss the button.
btnInvite.setVisibility(View.GONE);

String[] ids = AppInviteInvitation.getInvitationIds(resultCode, data);
StringBuilder sb = new StringBuilder();
sb.append("Sent ").append(Integer.toString(ids.length)).append(" invitations: ");
for (String id : ids) sb.append("[").append(id).append("]");
Toast.makeText(getApplicationContext(),"Invited!!!",Toast.LENGTH_SHORT).show();

} else {

Toast.makeText(getApplicationContext(),"Sorry, unable to send invite.",Toast.LENGTH_SHORT).show();

}
}
}

//调试时result_code为3,RESULT_OK为-1

Firebase 的新手,如果指出我做错了什么,将不胜感激。

最佳答案

经过几个小时的努力,发现并修复了问题,将其张贴在这里,因为它可能对其他人也有帮助。

最初的提示是“Create invitations failed to error code: 3” 在 SO 中也有类似的问题 Get suggested invitees failed due to error code: 3

但在我的例子中,SHA1 证书已经添加,但 Firebase 中的包名称结果是一个区分大小写的问题。

还有一点值得注意,从Firebase下载的google-services.json中的“api_key”和Web Api Key没有关系。我试图将 web api key 从仪表板手动复制并粘贴到 json 文件到 api_key,因为误解可能是导致错误的问题。

关于android - 使用 Firebase 的应用程序邀请不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40106497/

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