Posts

Showing posts with the label firebase

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(...

How does Firebase Cloud Messaging calculate the amount of notifications sent?

How does Firebase Cloud Messaging calculate the amount of notifications sent? Specifically, does it automatically remove users who disabled notifications? Does it count users who uninstalled the app? I couldn't find any info on the docs. 1 Answer 1 Firebase Cloud Messaging will try to deliver messages to all users that you target. So no matter if the users disabled the notifications on their phone, they will still be counted as messages that were sent. Of course, those users will not actually receive the message, so they will not count as messages that were received/opened. I have currently way more users than the messages that are sent when I select the whole app (1.8k users vs 1.3k users). Where can I trace back the difference? Uninstalls? – XelharK Jul 3 at 15:39 ...

Angular / Firestore - What's the best way to check the User ID in multiple components?

Angular / Firestore - What's the best way to check the User ID in multiple components? I have an 'authservice.ts' file where I try to manage user auth style things. However, in each of my components, I'm always subscribing to the user to get the user ID. The user ID is then used inside my Firestore functions to query data where the user ID is referenced inside collection and document paths. Is there a more 'fluent' way of achieving the same thing? Or is this approach actually suitable? Below are the examples of the auth service and a component file that references the auth service. auth-service.ts ... user: Observable<firebase.User>; ... constructor() { this.user = afAuth.authState; } Any One Of My Components.ts ... private _subscription: Subscription; ... ngOnInit() { this.subscribeToUser(); } subscribeToUser() { this._subscription = this.authService.user.subscribe(user => { if (user) { this.userID = user.uid; th...

Node Js value not showing in notification when testing

Node Js value not showing in notification when testing I am making a notification using firebase cloud functions with node js and my app made on swift this is my payload var payload = { notification: { title: (goOfflineTimePeriod,"Inactive for minutes you are now offline"), body: "Time period for inactive log off can be changed in your settings" though my notification my notification only shows as; "Inactive for minutes you are now offline", "Time period for inactive log off can be changed in your settings" so the variable; goOfflineTimePeriod does not show in the notification I am only new to node js is there a reason why "goOfflineTimePeriod" does not show in the notification? here is my full node js function code; exports.goOfflineAlert = functions.firestore .document('/goneOffline/{uid}') .onCreate((snap, context) => { var db = admin.firestore(); var uid = context.params.uid; const newValu...

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...

angularfire2 collection querying with endAt wont give result

angularfire2 collection querying with endAt wont give result I am trying to querying date range at firebase by using startAt() and endAt() methods.(Angular6) For date picking i use angular material MatDatepicker module. q_startDate; q_endDate; getStartDate(event: MatDatepickerInputEvent<Date>) { this.q_startDate = event.value.toISOString();} I defined q_startDate and q_endDate veriables and pushed data with getStartDate and getEndDate methods. const myCollection = this.afs.collection<objInterface>('collection_name', ref=> { let query: firestore.CollectionReference | firestore.Query = ref; query = query.orderBy('date_field', 'desc'); query = query.startAt(this.q_startDate); query = query.endAt(this.q_endDate); return query; }); In this query when i comment query = query.endAt(this.q_endDate); it works. How can i fix this issue, i want to include query also q_endDate? By click...

In Firestore, how can you do a compound query involving a key in a map without creating an index for every key?

In Firestore, how can you do a compound query involving a key in a map without creating an index for every key? In Firestore, how can you do a compound query involving a key in a map without creating an index for every key? For example, consider a collection which holds blog posts, and each blog post has categories. Post { title: .. ... categories: { cats: true puppies: true } } In order to query posts in a particular category in a paginated way, we would do something like this: let query = db.collection(`/posts`) .where(`categories.${categoryId}`, '==', true) .orderBy('createdAt') .startAfter(lastDate) .limit(5); But it seems that this would require a composite index ( categories.<categoryId> and createdAt ) for every single category. Is there any way around this? categories.<categoryId> createdAt In my case, it isn't feasible to create composite indices for every category since categories are user-gene...

“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...

Firebase deploy errors starting with non-zero exit code (space in project path)

Firebase deploy errors starting with non-zero exit code (space in project path) I was having issues with firebase deploy command recently. After firebase deploy command all others were being deployed except firebase (storage, database etc) So I decided to reinstall firebase to fix this situation but after reinstall my problem got bigger. Now none of them are deployed with the following error: i deploying database, functions Running command: npm --prefix $RESOURCE_DIR run lint npm ERR! path C:UsersfarukGoogle DriveAndroidfirebase1$RESOURCE_DIRpackage.json npm ERR! code ENOENT npm ERR! errno -4058 npm ERR! syscall open npm ERR! enoent ENOENT: no such file or directory, open 'C:UsersfarukGoogle DriveAndroidfirebase1$RESOURCE_DIRpackage.json' npm ERR! enoent This is related to npm not being able to find a file. npm ERR! enoent npm ERR! A complete log of this run can be found in: npm ERR! C:UsersfarukAppDataRoamingnpm-cache_logs2018-01-24T18_21_34_878Z-debug.log Error: functions...