firebase-realtime-database

React Native how to read Real Time Database Firebase

混江龙づ霸主 提交于 2021-01-29 10:08:49
问题 So I got one Screen with the Firebase configuration and one which should call the data. I'd like to have up to date Information. As of now I have the following code: export const firebaseFetchProfileItem = (category) => { var snap; database .ref("users/" + authentification.currentUser.uid + "/profile/" + category) .on("value", function (snapshot) { snapshot.val() ? (snap = snapshot.val()) : undefined; }), function (error) { log.error(error); }; return snap; }; It works "okayish", since it

React Native: Iterate through nested objects to display values

允我心安 提交于 2021-01-29 09:45:47
问题 I want to display multiple images into a screen. My database tree looks like this: I am also able to load the object through snapshot.val() and this is how it looks like in the console while running: Object { "4aae-47bb-e0f7-36e2-7e66": Object { "author": "edm9AAbPpFUWrO9HDXfV442QzSE2", "caption": "Test 1", "photo": Object { "2e30-b971-5c62-0b68-837f": Object { "url": "https://firebasestorage.googleapis.com/v0/b/...someURL...", }, "38de-15f2-bb7b-b58d-e863": Object { "url": "https:/

Code not executing after .observe firebase method swift4

[亡魂溺海] 提交于 2021-01-29 09:33:42
问题 I have a structure in which users are registering for events, and the registered events are stored as the following: I am trying to access the registeredEvents and display the children on a table view. So far, I have done this: override func viewDidLoad() { super.viewDidLoad() let id = Auth.auth().currentUser?.uid let ref = Database.database().reference() ref.child("users").child(id!).child("registeredEvents").observeSingleEvent(of: .value, with: { snapshot in print(snapshot.childrenCount)

Firebase Cloud Function error: Registration token(s) provided to sendToDevice() must be a non-empty string or a non-empty array

北慕城南 提交于 2021-01-29 09:29:31
问题 I want to send a notification to all users who are confirmed guests when the object confirmedGuests is created in the Firebase Realtime Database. So, I first create an array of all the users from confirmedGuests object. Then, I iterate through all these users and push their deviceTokens to an array of deviceTokens. The array allDeviceTokens is expected to be the array of device tokens of all users in confirmedGuests. However, when confirmedGuests object is created, the function returns an

Functions notifications not working in chat app firebase

笑着哭i 提交于 2021-01-29 09:26:43
问题 I made a android chat app and setup the automated notifications using functions in firebase, everything is working fine but when i send a message notifications won't come Here are the logs in firebase function - Here is the index.js file - 'use strict' const functions = require('firebase-functions'); const admin = require('firebase-admin'); admin.initializeApp(functions.config().firebase); exports.sendNotification = functions.database.ref('/Notifications/{user_id}/{notification_id}').onWrite

Is it possible to connect a local Functions emulator to a non-local Firebase Realtime Database?

限于喜欢 提交于 2021-01-29 09:14:48
问题 Due to problems using a Realtime Database emulator for development in Flutter ( see How do I connect to my local Realtime Database emulator in my Flutter app? ), I am now simply using my non-local Realtime Database for development. However, I am also using Cloud Functions, and I have created a Functions emulator. I tried the following to connect to it, based on this StackOverflow-answer: const functions = require("firebase-functions"); const admin = require("firebase-admin"); functions.config

Querying array from Firebase (React Native) [duplicate]

*爱你&永不变心* 提交于 2021-01-29 09:00:13
问题 This question already has an answer here : Firebase query if child of child contains a value (1 answer) Closed 1 year ago . I'm new to react-native and firebase, and I am building an app. I stumble upon a problem using "array" in firebase (i know that firebase doesn't work with array), but I want to know if there is some way to retrieve this data. This is the data I have in the server, and I want to get all the purchases that have the product "id" (in red) I tried to use the code below and

Firebase database transactional search and update

时间秒杀一切 提交于 2021-01-29 08:30:22
问题 I have a collection in firebase real time database that is a pool of codes that can be used once per 'store'. I need to search for an unused code, then mark it reserved by a store in an atomic fashion. The problem is I can't figure out how to do a transactional search and update in firebase, and the unused code is being 'used' multiple times until it gets updated. const getUnusedCode = (storeID) => { const codeRef = rtdb.ref('codes'); return codeRef .orderByChild(storeID) .equalTo(null)

How to trigger firebase function on all database instances rather than default one?

喜欢而已 提交于 2021-01-29 08:28:50
问题 I have 50 realtime firebase database instances which are all identical. Is it possible to get all my firebase functions to trigger on all instances, rather than just the default instance? I know you can do this exports.myWriteFunction = functions.database.instance('my-secondary-db').ref('path/to/data').onUpdate((snap, context) => { ... }) But I really want to run this function on every instance... 回答1: There is no way to automatically associate a function with all database instances. You will

Firebase Realtime Database to Cloud Firestore

≡放荡痞女 提交于 2021-01-29 08:12:00
问题 I´m searching the best way to migrate Firebase Realtime Database Data to Cloud Firestore for a json database with many nested rows. Example: I found nothing that could help me. For what I need the migration is the new offline functionality of the Cloud Firestore. I´m using Ionic3 (Angular5) 回答1: Actually there's no standard way to migrate from Firebase Realtime Database to Cloud Firestore, because every application or project has is unique. You have to implement your own way of migrating to