Posts

Showing posts with the label firebase-database

Firebase “User is missing a constructor with no arguments”

Firebase “User is missing a constructor with no arguments” I am trying to retrieve my user details from the /User/ tree i have in Firebase. I have the following User object : public class User { private String name; private String email; private FirebaseUser firebaseUser; private String lastOnline; private LatLng latLng; private ArrayList<SwapLocation> locations; public User(){ } public String getName(){ if(firebaseUser.getDisplayName() != null && !firebaseUser.getDisplayName().equals("")) return firebaseUser.getDisplayName(); if(name != null && !name.equals("")) return name; return ""; } public void setName(String name){ this.name = name; } public String getEmail(){ if(firebaseUser.getEmail() != null && firebaseUser.getEmail().equals("")) return firebaseUser.getEmail(); if(email != nul...

Swift - Firebase how to get only childs values without parent

Swift - Firebase how to get only childs values without parent In the database i has a child cities with the name of "cities" under it and each city has multiple areas contains the coordinations I went through every child under "cities" to find the closest location and got the city name using ref.child("cities").observe() : ref.child("cities").observe() for child in snapshot.children { let childSnap = child as! DataSnapshot if let dicionary = childSnap.value as? [String: AnyObject]{ var latitude1 = dicionary["latitude"] as! Double var longitude1 = dicionary["longitude"] as! Double var altitude1 = dicionary["altitude"] as! Double lets say the closest city is "city 2" and place it in a variable called selectedCity. So I repeat and add it to ref.child("cities").child(selectedCity) : ref.child("cities").child(selectedCity) ref.child("cities").child(...

React, Firebase: Access values of JSON and also get key value

React, Firebase: Access values of JSON and also get key value I am beginner working with firebase, react. I am able to get the required data from firebase based on userEmail. But I am very confused in accessing the data. firebase.database().ref('/users').orderByChild('email').equalTo(userEmail).on('value', data => { console.log('data: ', data); }) I get the following output: data: Object { "-Lhdfgkjd6fn3AA-": Object { "email": "t5@gmail.com", "favQuote": "this is it", "firstName": "t5", "lastName": "l5", }, } Please help me how to access all values ("-Lhdfgkjd6fn3AA-" , firstname, lastname, email and favQuote) into variables like: data.firstName, data.lastName, data.key, etc . Thank you. You can get the value using: data.-Lhdfgkjd6fn3AA-.email – NullPoint...

Javascript execution order when pulling Firebase data

Javascript execution order when pulling Firebase data After I authenticate to Firebase with Google auth, I get this console.log output and the JavaScript seems to bounce around in execution order. Here's my console output and the javascript code. console.log Why does "controller is: Pellet_Pirate_1" display at the log end rather than at the beginning where the code executes to pull this value from Firebase? My "GLOBAL CONTROLLER" and other logs of the contr global variable should be valued as well... I am trying to use contr as a global variable and it is defined at the top of my script tag contr contr Any help would be greatly appreciated... I've banged my head on this one for many hours now! console.log <script type="text/javascript"> var contr = undefined; function PelletPirate() { this.userPic = document.getElementById('user-pic'); this.userName = document.getElementById('user-name'); this.signInButton = d...

AngularFireDatabase Does not retrieve data

AngularFireDatabase Does not retrieve data Whenever I use afDB.list('/path') method, I get the following: console.log(this.items); and I have this example as my firebase database: listings file surprisingly, editing the data works perfectly fine (e.g. remove(), push(),... etc.), but I can't seem to be able to retrieve it; however, I can access it. I thought it might be a rules issue, yet, my rules are fine: firebase Rules this is the portion of the code that I'm having trouble with: import { Component } from '@angular/core'; import { NavController } from 'ionic-angular'; import { AngularFireAuth } from 'angularfire2/auth'; import { FirebaseProvider } from '../../providers/firebase/firebase'; import { AngularFireDatabase } from 'angularfire2/database'; import { Observable } from 'rxjs/Observable'; import * as firebase from 'firebase/app'; //import { ListingDetailsPage } from '../listing-details/listing-details...

“Warning: Can't call setState (or forceUpdate) on an unmounted component” after updating firebase database

“Warning: Can't call setState (or forceUpdate) on an unmounted component” after updating firebase database I'm trying to update some data to my firebase database on form submit, but when I click submit I get the following warning: Warning: Can't call setState (or forceUpdate) on an unmounted component. This is a no-op, but it indicates a memory leak in your application. To fix, cancel all subscriptions and asynchronous tasks in the componentWillUnmount method. Below is the code that gets executed on submit. If I remove the update code the warning goes away but I need to save the data how can I fix this? handleRewardFormSubmit = event => { event.preventDefault(); const self = this; let points = 0; const memberId = this.state.selectedMember; const groupID = this.state.groupid; const selectedPoints = Number(this.state.selectedPoints); const memberRef = database .ref("members") .child...

How to insert and fetch data using Firebase

How to insert and fetch data using Firebase I Created a Chat Box using Php and MQL. It is working fine. But now I need to change the database to firebase. How can I insert and fetch data into firebase? By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

How to handle seen/unseen chat messages in React/Firebase chat app? [on hold]

How to handle seen/unseen chat messages in React/Firebase chat app? [on hold] I’m trying to handle seen and unseen message status in one-to-one chat app using React and Firebase realtime database. Can I store for every send message in the database, seen: false value and when the receiver mount the component (message), to make again request to the database and change the value of “seen” to “true”? Are too many database requests can be an issue here? Many good questions generate some degree of opinion based on expert experience, but answers to this question will tend to be almost entirely based on opinions, rather than facts, references, or specific expertise. If this question can be reworded to fit the rules in the help center, please edit the question. 1 Answer 1 Is it a good practice to store for every send message in the database, seen: false value and when the receiver mount the component (mess...

read a users UID from Firebase

Image
read a users UID from Firebase I'm trying to read in uid into a var but for some reason it does not work. My database is: if (user) { // User is signed in! var uid = user.uid; var refreshToken = user.refreshToken; firebase.database().ref().child("owners").orderByChild("uid").equalTo(uid).on('value', function (snapshot) { snapshot.forEach(function(childSnapshot) { var controller=childSnapshot.val().name; console.log('controller is: ' + controller); }); }); my console.log statement never shows to the console. Any help would be appreciated as the really has me stumped right now. Can you place a console.log before snapshot.forEach(function(childSnapshot) to see if the code is getting to your inner function? – RyanNerd Jul 1 at 7:09 console.log snapsho...