Posts

Showing posts with the label firebase

Firestore & Swift

Firestore & Swift Currently I'm working on a project which uses Firestore. The problem I am facing is as follows: I want to fill a collectionview with data from Firestore, the data is an image + a label. Once a user clicks on the item (image + label) in the collectionview they go to that categorie. So once they click they will get a new collectionview with the items of that categorie (also just an image + label). Now my question is how do I do this? Cause I can't seem to find related study material for my problem. I have been looking all over Google, YouTube and what not. Most of the tutorials or guides I find are for Firebase Realtime Database (so not Firestore) or are just flat out outdated (pre 2017). Also I wonder what the best practices are, do I make a struct for my categories and items? Looking for all round tips here or good reading material so I can learn how to do this. Thanks in advance. This is way too broad a topic for an answer, an...

Prepare for segue not passing data

Prepare for segue not passing data I'm working on a Swift project using firebase and I have a UICollectionViewController that has all the categories, and I need to pass the category Id to the next view, but It passes an empty string func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { let category = cnameArray[indexPath.row] let catId = category.caId func prepare(for segue: UIStoryboardSegue, sender: Any?){ if segue.identifier == "CatCity" { let cityView = segue.destination as? CityViewController cityView?.catId = catId! } } self.performSegue(withIdentifier: "CatCity", sender: self) } and in my CityViewController I have var catId = String() when I put a break point at the last line of the prepare func it gets hit and the console gets the value correctly while sitting a breakpoint at CityViewController gives me an empty var. and I checked the code and my segue name and...

Firebase database getInstance crashes app

Firebase database getInstance crashes app When running the sample after creating google-service.json, the app crashes when trying to get database reference in SignInActivity mDatabase = FirebaseDatabase.getInstance().getReference(); Crash log 05-21 09:27:27.644 488-488/com.google.firebase.quickstart.database D/AndroidRuntime: Shutting down VM 05-21 09:27:27.644 488-488/com.google.firebase.quickstart.database E/AndroidRuntime: FATAL EXCEPTION: main Process: com.google.firebase.quickstart.database, PID: 488 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.google.firebase.quickstart.database/com.google.firebase.quickstart.database.SignInActivity}: com.google.firebase.database.DatabaseException: Failed to get FirebaseDatabase instance: FirebaseApp object has no DatabaseURL in its FirebaseOptions objec...

Geofire crashes when writing to Firebase

Geofire crashes when writing to Firebase I am writing a program to upload a LatLng data of the user to Firebase. It works by clicking a button btnAddPickUpLocation and it uploads to database. The user details and Uid has been initiated in other part of the codes and there is no issues with it. The Lat Lng is currently hardcoded so it is not due to this variable source. It returns perfectly when i set a Toast to return the Uid and it does not crash when i comment out mGeofire.setLocation(Uid, new GeoLocation(37.7853889, -122.4056973)); mGeofire.setLocation(Uid, new GeoLocation(37.7853889, -122.4056973)); Any idea what is wrong with this statement? The relevant codes are as follows. RelativeLayout contentView = findViewById(R.id.contentView); btnAddPickUpLocation = contentView.findViewById(R.id.btnAddPickUpLocation); btnAddPickUpLocation.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { //AddPickUpLocation(Fireb...

ngModel displays identical values for different fields

ngModel displays identical values for different fields This is an Angular 5 and Firestore project. I am using a form with [(ngModel)] to update a document in the database. The update is successful. But the way [(ngModel)] displays document field values in the input boxes themselves is incorrect, e.g. the placeholders are wrong. Each input box is displaying the same field value, when they should be different. For example [(ngModel)] [(ngModel)] In the db, my doc looks like this document field1: document title field2: google field3: https://www.google.com But my input boxes show this input box 1 displays https://www.google.com input box 1 https://www.google.com input box 2 displays https://www.google.com input box 2 https://www.google.com input box 3 displays https://www.google.com input box 3 https://www.google.com Here is the HTML <ng-container *ngFor="let x of xyz | async"> update {{x.field1}} #...

Error: In adding Firebase Storage dependency to Android Studio Project?

Image
Error: In adding Firebase Storage dependency to Android Studio Project? I have created a Firestore Project in Android Studio. In which I have Firebase Authorization implemented and that is working absolutely fine. I am able to push documents to Firestore Database. But now, I am trying to add functionality using which I can store media/images to Firebase Storage but when I am adding this dependency to app's build.gradle file, I am getting this error: Dependency added: implementation 'com.google.firebase:firebase-storage:16.0.1' This is the error that I am getting: Could not find firebase-common.jar (com.google.firebase:firebase-common:16.0.0). Searched in the following locations:https://jcenter.bintray.com/com/google/firebase/firebase-common/16.0.0/firebase-common-16.0.0.jar FYI, In my project I already have this kind of configuration: classpath 'com.android.tools.build:gradle:3.1.3' And apply plugin: 'com.google.gms.google-services' I can not find what is go...

Ionic 3 and firebase when download an audio it gives an error

Image
Ionic 3 and firebase when download an audio it gives an error when i try to download an audio from firebase storage it gives me an error . here is my .ts file import { FirebaseProvider } from './../../providers/firebase/firebase'; import { Component } from '@angular/core'; import { NavController } from 'ionic-angular'; import { FirebaseListObservable } from 'angularfire2/database'; import { FileTransfer, FileUploadOptions, FileTransferObject } from '@ionic- native/file-transfer'; import { File } from '@ionic-native/file'; import { NativeAudio } from '@ionic-native/native-audio'; @Component({ selector: 'page-home', templateUrl: 'home.html' }) export class HomePage { constructor(private transfer: FileTransfer,private file: File,private nativeAudio: NativeAudio) { const fileTransfer: FileTransferObject = this.transfer.create(); this.download(); this.nativeAudio.preloadSimple('uniqueId1', this.file.dataD...

Firebase Hosting for a client in Denmark by a group of developers in India

Image
Firebase Hosting for a client in Denmark by a group of developers in India I am working on an application for a client in Denmark, using the firebase Hosting, Firestore and Cloud functions from among the features of firebase. While creating a project on the console i selected the location as Denmark as well, so my doubt here is once i Deploy the app to my client's system where will the server be location, will all the features work as expected. If not what configurations are required? 1 Answer 1 First of all, you need to read this carefully. Even if you selected Denmark, it does not determine the location of your data for Firebase features. I recommend you to take a look at this link for Firestore region. In the case of Cloud Function region, it is helpful to look at this link and this link. By clicking "Post Your Answer", you acknowledge tha...

Firebase Auth: can't instantiate AuthCredential

Image
Firebase Auth: can't instantiate AuthCredential I am trying to make a Master User module, which user can delete other users. I read from other questions, that if you want to delete a user, You must logged in as that user. And then, I realize that you could sign in with credential information stored by firebase auth. (for references, I use google, facebook and email method). I also store a User entity in my Firebase Database which correspond to Firebase Auth. Here is my User class : public class User { // variables. private String appId; private String email; private String name; private String description; private String photoUrl; private boolean isAdmin; private boolean isSuspended; private boolean isDeleted; private AuthCredential credential; // all those getters and setters go here. } Notice that I store a AuthCredential instance in my user, which I set for the first time when I sign up this ...

How to retrieve the list of data under 1 child in Firebase Database in Android Studio

How to retrieve the list of data under 1 child in Firebase Database in Android Studio Data stored in firebase: 29-06-2018(date) -AAAA -25142(jobno) -Park station(address) -BMW(model) -BBBB -85142(jobno) -Base station(address) -Ford(model) Here I want all the children under -BBBB. Don't want to loop through AAAA. How to get directly the child of BBBB. I'm having data (date, BBBB). Just want to get jobno, address, model of BBBB. Please suggest me a solution. My code is here DatabaseReference database = FirebaseDatabase.getInstance().getReference(); DatabaseReference pwd = database.child("29-06-2018").child("BBBB"); pwd.addValueEventListener(new ValueEventListener() { @Override public void onDataChange(DataSnapshot dataSnapshot) { for (DataSnapshot ds : dataSnapshot.getChildren()) { String a = ds.child(...

Firestore query subcollections

Firestore query subcollections I thought I read that you can query subcollections with the new Firebase Firestore, but I don't see any examples. For example I have my Firestore setup in the following way: How would I be able to query "Find all dances where songName == 'X'" 6 Answers 6 This is a feature which does not yet exist. It's called a "collection group query" and would allow you query all songs regardless of which dance contained them. This is something we intend to support but don't have a concrete timeline on when it's coming. The alternative structure at this point is to make songs a top-level collection and make which dance the song is a part of a property of the song. It would be MUCH better if the Firestore dev team implemented subcollection queries ASAP. After all, 'more powerful queries' is one of the majo...

How to use two apps in one Firebase project for push notifications

Image
How to use two apps in one Firebase project for push notifications I have created one project(TravellerProject) in Firebase developer console... i've added an Android App(UserApp) and i've taken Server key and i used that server key for push notification in to my App Admin site... now i have a new App(DriverApp) related to first App(UserApp)... both are same domain so i didn't created new Project, instead i added one more App in the same project(TravellerProject) with different SHA-1 key... and i was trying to use push notifications for new App(DriverApp). can i use same Server Key for both or i've to create new Server key...? same key for both will do – Jinesh Malavia Jun 29 at 8:53 2 Answers 2 Its really simple. Just open firebase ac...

I am not getting FCM message probably FirebaseMessagingService is not running

I am not getting FCM message probably FirebaseMessagingService is not running I am using FCM for notification. Due to some issue, i am not getting notification when i am sending using FCM Cloud console. <service android:name=".MyInstanceIDService" android:exported="true"> <intent-filter> <action android:name="com.google.firebase.MESSAGING_EVENT" /> </intent-filter> </service> <service android:name=".MyMessagingService"> <intent-filter> <action android:name="com.google.firebase.INSTANCE_ID_EVENT" /> </intent-filter> </service> This is my both classes. public class MyInstanceIDService extends FirebaseInstanceIdService { private static final String TAG = "MyInstanceIDService"; @Override public void onTokenRefresh() { String refreshedToken = FirebaseInstanceId.getInstance...

FCM seldom Fails on Android device

FCM seldom Fails on Android device I've built an application to send instant message via FCM to Android devices by Json WebRequest. The application works fine but it seldom fail when the application posts to FCM server, and then may continuously fail for a while. FCM returns the same fail message below but I have no idea what's happening: {"multicast_id":6888830314994897268,"success":0,"failure":1,"canonical_ids":0,"results":[{"message_id":null}]} I found this documentation says that: For Android there is a limit of 100 messages that can be stored without collapsing. If the limit is reached, all stored messages are discarded. When the device is back online, it receives a special message indicating that the limit was reached. The app can then handle the situation properly, typically by requesting a full sync from the app server. But my Android devices do receive all of the messages the server sent when it is p...

Firebase retrieving multiple objects in multiple nodes

Image
Firebase retrieving multiple objects in multiple nodes I am trying to read data from a firebase realTime database in android (For some reason FireBase sorts the location data and then the VideoEntry but I think it's correct anyway...according to the json generated) In case you needed this is how I add the nodes: submitVideoButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { String locationName = locationInput.getText().toString(); double lat = Double.parseDouble(latInput.getText().toString()); double lon = Double.parseDouble(longInput.getText().toString()); String userid = mFirebaseUser.getEmail().substring(0, mFirebaseUser.getEmail().indexOf("@")); String cleanUserId = userid.replaceAll("W", ""); updateUserInfo(cleanUserId, mFirebaseUser.getEmail(), "...

Retrieving json file from Firebase Storage

Retrieving json file from Firebase Storage I would like to be able to get a json file from Firebase Storage to work with. I don't need to push it back. Does Firebase Storage can give me that and if so, how can I do it with Angular? If not, does the Firebase database is a better choice? I already downloaded firebase and angularfire2. I tried getDownloadURL and getMetadata, but don't know how to get the info inside. Thanks for your help! 1 Answer 1 I'd suggest you use the realtime database, I suspect that it will be simpler for you to pick up. The realtime database already stores all of it's information as JSON, so you could simply query the database and get your JSON data... but if you used the Storage portion of Firebase then you'd have to jump through some hoops to actually read the file you get and parse out the data. Check out this documentation for examples of how to query th...