我正在用 React-Native 开发一个移动应用程序。数据存储在 Cloud Firestore 上。我有一个关于在 Cloud Firestore 上构建数据的最佳方式的问题。
应用程序的每个用户在他/她的手机上都有的联系人列表被复制到数据库上的文档中。数据存储在Cloud Firestore 上的“数组”中。下面是一个例子。
例如,对于用户#1,以下是文档的内容collection("users").doc("1"):
name: "Suzi",
contacts: [
{userID:"2", name:"John", appMember: false},
{userID:"3", name:"Cathy", appMember: false}
]
Run Code Online (Sandbox Code Playgroud)
当其中一个联系人(John 或 Cathy)注册为应用程序的用户时,云函数需要检查他/她是否是另一个应用程序用户的联系人。如果他/她是,则需要更新他/她与该“用户”的联系记录,以表明他/她现在是应用程序成员。
例如,如果John 注册为应用程序的用户,Cloud Function 将更新上面的文档,如下所示。
name: "Suzi",
contacts: [
{userID:"2", name:"John", appMember: true}, // <--- appMember changed from false to true
{userID:"3", name:"Cathy", appMember: false}
]
Run Code Online (Sandbox Code Playgroud)
我知道无法直接访问/更新John 的对象{"userID":"2", "name":"John", "appMember": false}。更新这个数组的唯一方法是(1)“获取”整个数组,(2)循环遍历它以找到相关对象,(3)更新该对象,以及(4)将新更新的数组保存回数据库.
你能想出更好的数据结构来处理这些数据吗?
我想将联系人存储在(1)联系人对象的“地图”(而不是联系人对象的数组)中,或(2)联系人的 …
firebase react-native google-cloud-functions google-cloud-firestore
每当我尝试使用 react-native-firebase sdk 使用电话号码登录时,我都会通过短信收到 OTP 代码,当我提交收到的代码时,会出现错误消息:“短信代码已过期。请重新发送验证码再试一次。” 在这里要注意的是,即使出现错误,相应电话号码的条目也会写入 firebase 的“用户”部分。
我正在使用以下内容:
NodeJS: v8.11.1,
NPM: v5.6.0,
react-native: "^0.59.9",
react-native-firebase: "^5.5.3"
Run Code Online (Sandbox Code Playgroud)
我已经尝试过的一些链接是:
1. https://github.com/invertase/react-native-firebase-
docs/blob/master/docs/auth/phone-auth.md
2. /sf/ask/3256590851/
authentication-error-the-sms-code-has-expired
3. https://www.bountysource.com/issues/45308170-firebase-phone-
number-auth-integration
4. https://medium.com/@chrisbianca/getting-started-with-firebase-
authentication-on-react-native-a1ed3d2d6d91
5. https://invertase.io/oss/react-native-firebase/v6/auth/phone-
auth
Run Code Online (Sandbox Code Playgroud)
在 MobileRegistration.js 中:
navigateToOtpScreen() {
console.log("Phone number: ", "+91" + this.state.phoneNumber)
firebase.auth().signInWithPhoneNumber("+91" +
this.state.phoneNumber)
.then(confirmResult => {
this.setState({ confirmResult, message: 'Code has been sent!'})
this.props.navigation.navigate('EnterOtp', { 'confirmResult':
confirmResult})
})
.catch(error => {
alert(error.message);
this.setState({ message: `Sign In With Phone Number Error:
${error.message}` })
});
Run Code Online (Sandbox Code Playgroud)
};
在 …
react-native firebase-authentication react-native-android react-native-firebase
对于 iOS,库react-native-community/datetimepicker支持日期时间模式,在该模式下它显示日期和时间选择器。
但是,此模式不适用于 Android。
是否有一种解决方法可以显示 2 个连续的选择器,一个用于日期,另一个用于时间?
class ShiftTimingScreen extends Component {
state = {
dateTimePickerVisible: false,
dateOrTimeValue: new Date(),
};
render() {
return (
<View>
<TouchableOpacity
onPress={() => this.setState({ dateTimePickerVisible: true, })}
>
<Input
label='Shift Starts At'
placeholder={"01/01/2019 - 09:00 AM"}
editable={false}
value={this.state.dateOrTimeValue.toLocaleDateString()}
/>
</TouchableOpacity>
{this.state.dateTimePickerVisible &&
(<DateTimePicker
mode={"datetime"} // THIS DOES NOT WORK ON ANDROID. IT DISPLAYS ONLY A DATE PICKER.
display='default' // Android Only
is24Hour={false} // Android Only
value={defaultShiftStartDateTime}
onChange={(event, value) => {
this.setState({
dateOrTimeValue: …Run Code Online (Sandbox Code Playgroud) 当我执行以下命令时。
emulator -avd Nexus_S_API_28_86 -wipe-data -no-boot-anim
我收到以下错误消息。
Failed to open /usr/local/google/home/joshuaduong/emu/master/prebuilts/android-emulator-build/qemu-android-deps/windows_msvc-x86_64/qemu.conf, err: 2
模拟器启动并正常工作。但是,我对收到错误消息感到不舒服。而且,我不知道“joshuaduong”是谁。我在 Android Studio 文件中搜索了这个路径。有趣的是(或可怕),我在以下 dll 文件中找到了它:
C:\Users\<MyUserName>\AppData\Local\Android\Sdk\emulator\lib64\glib-2-vs11.dll
并在 8 个 exe 文件中:
C:\Users\<MyUserName>\AppData\Local\Android\Sdk\emulator\qemu\windows-x86_64\qemu-system<something>.exe
为什么“joshuaduong”会出现在 dll 和 exe 文件中!这些文件是否已被泄露?Avast Free Antivirus 找不到任何问题。我应该重新安装什么包/库来获取这些文件的新副本。我得到的时间戳为 12/12/2019。我想我在那一天下载了一些更新。
如何将react-native-elements按钮的标题分成多行?
import { Button } from 'react-native-elements';
....
// The \n in the following statement does NOT work!
<Button
title="Creating a Shift \n(and inviting employees)"
onPress={ () => {
console.log("Button Pressed");
}}
/>
Run Code Online (Sandbox Code Playgroud)