firebase-realtime-database

How to handle Firebase Database error in iOS? #AskFirebase

倾然丶 夕夏残阳落幕 提交于 2021-02-07 19:48:47
问题 I need to handle "Permission Denied" error differently from all other errors. In Android I've done it: (Kotlin) override fun onCancelled(error: DatabaseError) { if (error.code == DatabaseError.PERMISSION_DENIED) { // Warn user } } In iOS I have only: someDbReference.observe(.childAdded, with: { data in // Do something }, withCancel: { err in // err is Error print((err as NSError).code) // 1 // Which error? O_o }) How to determine error type? I've read whole documentation, and I think that err

How to share Authentication token between app in Firebase 3.0?

好久不见. 提交于 2021-02-07 14:44:38
问题 In older version of Firebase we can obtain authenticated token for sharing between our app, extensions. But when upgrade to Firebase 3.0, that function doesn't work anymore. I've use getTokenWithCompletion: on FIRUser, then in my App Extension I call signInWithCustomToken:completion: with token i just obtained. But Firebase return an error with messgage: Error Domain=FIRAuthErrorDomain Code=17000 "The custom token format is incorrect. Please check the documentation." UserInfo=0x799b6010

Is There Such A Thing As “Multi-Path Push” in Firebase Real-Time Datasbase?

爷,独闯天下 提交于 2021-02-07 14:20:43
问题 I was watching this video which talks about multi-path updates in Firebase. Multi-path updates are great because they allow you to call the firebaseRef.update() method two or more times while having them be one atomic, all-or-nothing operation. This is great, but in my current situation I don't want to use the update() method. Instead, I want to use the FirebaseRef's push method and allow Firebase to generate a unique key for my object. The tricky part is that I have denormalized my data so

Is there any way to use FieldValue.serverTimestamp() in Firebase Firestore JS without Firebase-Admin

南楼画角 提交于 2021-02-07 13:31:01
问题 According to answer below, Firebase-Admin is required to use FieldValue.serverTimestamp(). How do I get the server timestamp in Cloud Functions for Firebase with Firestore? . But I am using only Firebase JS and Firebase Firestore JS. The application runs only in client side. However, Firebase-Admin requires a server. Is there any way to use server timestamp when doing a write operation ? 回答1: Simply use Firebase.ServerValue.TIMESTAMP within your object. Like this: ref.set({ time: Firebase

Best way to structure my firebase database

醉酒当歌 提交于 2021-02-07 10:52:42
问题 I'm working on a project where users can post things. But, I'm wondering if my firebase database structure is efficient. Below is how my database looks like so far. I have posts child contains all the post that users will post. and each user will be able to track their own posts by having posts child in uid . Is there a better way of structuring my data? or am I good to go? Any advice would be appreciated! { "posts" : { "-KVRT-4z1AUoztWnF-pe" : { "caption" : "", "likes" : 0, "pictureUrl" :

How do I handle Firebase Adapter RecyclerView empty view?

痞子三分冷 提交于 2021-02-07 10:23:21
问题 So the issue is that whenever I set my empty view for the recycler view, it always shows the empty view. I tried following some suggested solutions like the one in this url: FirebaseRecyclerAdapter with empty view, but the problem is that Firebase listeners are asynchronous and runs on its own thread. Before even setting the empty view, the fragment's onCreateView method already returns the view and so the empty view is not set appropriately. Are there any other way to implement the setting

How do I handle Firebase Adapter RecyclerView empty view?

旧巷老猫 提交于 2021-02-07 10:22:32
问题 So the issue is that whenever I set my empty view for the recycler view, it always shows the empty view. I tried following some suggested solutions like the one in this url: FirebaseRecyclerAdapter with empty view, but the problem is that Firebase listeners are asynchronous and runs on its own thread. Before even setting the empty view, the fragment's onCreateView method already returns the view and so the empty view is not set appropriately. Are there any other way to implement the setting

Firestore: What is the best way to populate array of ids with its content?

时间秒杀一切 提交于 2021-02-07 09:57:56
问题 I have array of objects containing users Ids. const userIDs= [{key: 'user_1'},{key: 'user_2'}, {key: 'user_3'}]; I want to fill it with user data from cloud firestore. const userIDs= [ {key: 'user_1', name: 'name1'}, {key: 'user_2', name: 'name2'}, {key: 'user_3', name: 'name3'} ]; What is the fastest and less pricey way of doing it ? This is my current way of doing it. const filledUsers = []; for (let index in userIDs) { const user = Object.assign({}, concatUsers[index]); const snapshot =

Angular 4 Firebase Read data from database and display to browser

爷,独闯天下 提交于 2021-02-07 08:40:13
问题 I am learning Angular 4 and I am using firebase database.But I am completly lost on how I can make the objects apear on the browser of my application. I currently want to take all the data from users and display them on the browser. import { Component, OnInit } from '@angular/core'; import { AngularFireDatabase, FirebaseListObservable } from 'angularfire2/database'; import * as firebase from 'firebase/app'; @Component({ selector: 'app-about', templateUrl: './about.component.html', styleUrls:

Understanding conflict resolution in firebase

北城余情 提交于 2021-02-07 02:57:35
问题 I'm trying to understand the way the conflict resolution works in firebase for which I need some help. Assuming that I've json object saved in a node in firebase realtime: { "shape": "rectangle", "stroke": 10, "color": "black" } I've defined a test page which reads this data and displays and also listens to the changes happening on node with key in realtime. I've added a provision to update the data which eventually updates the specific key value alone. Sample used case client 1 - loads the