【问题标题】:Android- How to send invitations to friends using Firebase in-app?Android-如何使用 Firebase 应用内向朋友发送邀请?
【发布时间】:2018-01-02 18:27:35
【问题描述】:

我正在使用 Firebase 制作一个应用,让人们可以在应用上向他们的朋友发送活动邀请。他们将可以从数据库中的好友列表中进行选择,而被选中的人将收到活动邀请。每个事件都有自己的密钥/唯一 ID,我需要将其保存在他们选择的朋友的用户 UID 下。那么,我如何才能将事件 ID 保存给用户选择的多个朋友?

我知道如何像这样将事件保存到用户自己的数据库中:

newEvent.child(userUID).setValue(eventID);

但我无法将其保存给其他人。谢谢

【问题讨论】:

  • 检查这是否解决了您的问题,Intent intent = new AppInviteInvitation.IntentBuilder("Invite title") .setEmailSubject("") .setEmailHtmlContent("") .setMessage("") .setDeepLink(Uri .parse("")) .setCustomImage(Uri.parse("")) .setCallToActionText("Open") .build(); startActivityForResult(intent, Constants.RequestCode.INVITE);
  • 不不,邀请不是通过邮件发送的,而是在应用内发送的
  • newEvent.child(userUID).child(friendUID).setValue(eventID);
  • friendUID可以设置多个值吗? IE。不止一个朋友? @FrankvanPuffelen

标签: android firebase firebase-realtime-database


【解决方案1】:

看起来您正在尝试进行客户端扇出:将相同的值写入多个位置。可以通过单个多位置更新来做到这一点:

usersRef = ref.child("users");
Map updates = new HashMap();
updates.put(userUID+"/"+friendUID1, eventID);
updates.put(userUID+"/"+friendUID2, eventID);
usersRef.updateChildren(updates);

只需确保您在哈希图的键中拥有要更新的各个属性的路径。

【讨论】:

  • 这是否意味着用户想要邀请的朋友数量是静态的?
  • 没有。您还可以遍历一组朋友来填充地图。
猜你喜欢
  • 1970-01-01
  • 2012-12-02
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-07-29
  • 2012-08-17
  • 1970-01-01
相关资源
最近更新 更多