Posts

Showing posts with the label Firebase

Add Field Separately To Firestore Document

Answer : Build a DocumentReference to the document you want to update, then use the update() method on the DocumentReference to indicate only the fields to be added or changed. Pass it an object with only properties that match the fields to add or change.

After Upload A File In Android Firebase Storage How Get The File Download Url? GetDownloadUrl() Not Working

Answer : I had Found 2 solution for my issue. Firebase Google Documentation : //add file on Firebase and got Download Link filePath.putFile(imageUri).continueWithTask(new Continuation<UploadTask.TaskSnapshot, Task<Uri>>() { @Override public Task<Uri> then(@NonNull Task<UploadTask.TaskSnapshot> task) throws Exception { if (!task.isSuccessful()){ throw task.getException(); } return filePath.getDownloadUrl(); } }).addOnCompleteListener(new OnCompleteListener<Uri>() { @Override public void onComplete(@NonNull Task<Uri> task) { if (task.isSuccessful()){ Uri downUri = task.getResult(); Log.d(TAG, "onComplete: Url: "+ downUri.toString()); } } }); Another solution! It's more easy and small than google Firebase documentation and I'll use it: filePath.putFile(imageUri).addOnSuccessListener(new OnSuccessListener<UploadTask.Task...

Android Project, Change Firebase Account

Answer : Follow the below steps, to switch firebase account Go to your firebase console, and select the project you want to shift Select the icon besides the project name on top right. Select Permissions from the flyout. You've reached the IAM & Admin page of firebase. Click on +Add button on top. Enter the email ID of the account to transfer the project to. In the dropdown, Select a role > Project > Owner. Click add Check mail in the email added above. Accept the invite, and go to IAM & Admin page of the transferred project. Use remove button to delete the previous user Hope this helps. 1- Yes, it's possible and you can follow this tutorial to do so. 2- If you want to simply switch projects, generate a new JSON on the console and remove the old one. If you want to migrate your database, it's possible, just check this question. 3- Both answers are "yes" so, try them out.

Can I Cleanly Delete Firebase CLI Project?

Answer : You should delete firebase.json and .firebaserc if it exists. Once those files are deleted you should be good to go. I am using the following command npm uninstall firebase and npm uninstall angularfire2 it works for me

Can You Get The Timestamp From A Firebase Realtime Database Key?

Answer : As I said in my comment, you should not rely on decoding the timestamp from the generated id. Instead of that, you should simply store it in a property in your Firebase. That said, it turns out to be fairly easy to get the timestamp back: // DO NOT USE THIS CODE IN PRODUCTION AS IT DEPENDS ON AN INTERNAL // IMPLEMENTATION DETAIL OF FIREBASE var PUSH_CHARS = "-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz"; function decode(id) { id = id.substring(0,8); var timestamp = 0; for (var i=0; i < id.length; i++) { var c = id.charAt(i); timestamp = timestamp * 64 + PUSH_CHARS.indexOf(c); } return timestamp; } var key = prompt("Enter Firebase push ID"); if (key) { var timestamp = decode(key); console.log(timestamp+"\n"+new Date(timestamp)); alert(timestamp+"\n"+new Date(timestamp)); } I'll repeat my comment, just in case somebody thinks it is a good idea to use this code for anything e...

Can't Run Firebase Test Lab Tests Using Gcloud And Service Account: 403, Does Not Have Storage.objects.create

Answer : You should be able to use a service account created in the Google Cloud Console. Did your service account have the required project Editor role? (as noted in this doc: https://firebase.google.com/docs/test-lab/continuous) After lots of clicking through the Firebase console and the Google Cloud Console, reading SO, asking for help on Slack, and more trial and error than I care to admit, I discovered that the Firebase console has a service account page: https://console.firebase.google.com/u/0/project/project-name-12345/settings/serviceaccounts/adminsdk That is different from the service accounts page in the Google Cloud Console https://console.cloud.google.com/iam-admin/serviceaccounts/project?project-name-12345 It turns out you want the Firebase service account, you can not create one via the cloud console. Super, super annoying. This is the list of the roles that I put in to my service account : Firebase - Firebase admin ( I think this is overkill. I might upd...

Angular 6 - Getting Download URL For Firebase Storage File After Uploading

Answer : You should add a finalize() to the pipe, something like: this.task.snapshotChanges().pipe( finalize(() => { this.downloadURL = this.ref.getDownloadURL(); // <-- Here the downloadURL is available. }) ).subscribe(); In the finalize() step, the downloadURL is available, so u can grab him from the ref asynchronously. --UPDATE You said you are using Angular 6, so I assume you are using the last version of firebase. They change getDownloadURL() to Observable from Task, So to get the actual URL you just have to subscribe. this.task.snapshotChanges().pipe( finalize(() => { this.ref.getDownloadURL().subscribe(url => { console.log(url); // <-- do what ever you want with the url.. }); }) ).subscribe();

Android Studio ML Kit Cannot Load OCR Module

Answer : The solution was to update Google Play Services app. I did not consider this as an option at first as I would have expected an API 29 emulator to have an up-to-date Google Play Services installed. I signed into Google Play on the emulator, searched Google Play Services, uninstalled it (there was no "update" option), and installed it again. It still says that the installed version is 19.4.20 though the text recognition started working as expected. Here are some relevant logs: W/DynamiteModule: Local module descriptor class for com.google.android.gms.vision.dynamite.ocr not found. I/DynamiteModule: Considering local module com.google.android.gms.vision.dynamite.ocr:0 and remote module com.google.android.gms.vision.dynamite.ocr:0 D/TextNativeHandle: Cannot load feature, fall back to load dynamite module. I/DynamiteModule: Considering local module com.google.android.gms.vision.ocr:0 and remote module com.google.android.gms.vision.ocr:1 I/DynamiteModule: Selected re...

Configured The Default Firebase App __FIRAPP_DEFAULT

Image
Answer : In my particular workflow, when adding firebase dependencies, the tutorial code and flutter warnings never prompted to modify the AppDelegate.m file. It wasn't until I dialed back and added cloud_firestore did I get prompted with this warning: 6.3.0 - [Firebase/Core][I-COR000003] The default Firebase app has not yet been configured. Add [FIRApp configure]; (FirebaseApp.configure() in Swift) to your application initialization. Read more: [https://firebase.google.com/docs/ios/setup#initialize_firebase_in_your_app]. open xc workspace >> open ios/Runner.xcworkspace open AppDelegate.m in AppDelegate.m add the following line: import Firebase; in AppDelegate.m add the following snippet to your application did finish method [FIRApp configure]; Here is what mine looked like in the end: This worked for me: https://medium.com/vector-com-mm/how-to-fix-ios-crash-during-the-start-firebase-configure-f3477df3154 In AppDelegate.swift change the order of GeneratedPl...

Can't Build Release APK For Flutter

Answer : Turns out, the best way to handle this is to make the following change in android/app/build.gradle : android { compileSdkVersion 26 buildToolsVersion '26.0.3' lintOptions { disable 'InvalidPackage' } defaultConfig { applicationId "com.example.app" minSdkVersion 16 targetSdkVersion 26 versionCode 1 versionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } signingConfigs { release { keyAlias keystoreProperties['keyAlias'] keyPassword keystoreProperties['keyPassword'] storeFile file(keystoreProperties['storeFile']) storePassword keystoreProperties['storePassword'] } } // This is the main section that I've updated // to get the release APK to build buildTypes { release { profi...

Android Studio - Get Firebase Token From GetIdToken

Answer : Your second approach is close, you just need to use <GetTokenResult> instead of <UploadTask.TaskSnapshot> as that is for uploading images using Firebase Storage. Try this: user.getIdToken(true).addOnSuccessListener(new OnSuccessListener<GetTokenResult>() { @Override public void onSuccess(GetTokenResult result) { String idToken = result.getToken(); //Do whatever Log.d(TAG, "GetTokenResult result = " + idToken); } });

Can Firestore Update Multiple Documents Matching A Condition, Using One Query?

Answer : Updating a document in Cloud Firestore requires knowings its ID. Cloud Firestore does not support the equivalent of SQL's update queries. You will always have to do this in two steps: Run a query with your conditions to determine the document IDs Update the documents with individual updates, or with one or more batched writes. Note that you only need the document ID from step 1. So you could run a query that only returns the IDs. This is not possible in the client-side SDKs, but can be done through the REST API and Admin SDKs as shown here: How to get a list of document IDs in a collection Cloud Firestore? Frank's answer is actually a great one and does solve the issue. But for those in a hurry maybe this snippet might help you: const updateAllFromCollection = async (collectionName) => { const firebase = require('firebase-admin') const collection = firebase.firestore().collection(collectionName) const newDocumentBody = { ...

Could Not Get GOOGLE_APP_ID In Google Services File From Build Environment

Image
Answer : This worked for me: When install Crashlytic with Firebase, for multiple scheme, you can have error Could not get GOOGLE_APP_ID in Google Services file from build environment . You can fix it by: In Build Settings , add a user define for file name in User Defined : In Build Phases , tap plus button, New Run Script Phase above your Crashlytic build phase, and type this code to the text field. Remember to rename %YOUR_CUSTOM_PATH_TO_FOLDER% to your path to Plist files: GOOGLE_SERVICE_INFO_PLIST_FROM="${PROJECT_DIR}/%YOUR_CUSTOM_PATH_TO_FOLDER%/${FIREBASE_CONFIG_FILE}.plist" BUILD_APP_DIR="${BUILT_PRODUCTS_DIR}/${FULL_PRODUCT_NAME}" GOOGLE_SERVICE_INFO_PLIST_TO="${BUILD_APP_DIR}/GoogleService-Info.plist" cp "${GOOGLE_SERVICE_INFO_PLIST_FROM}" "${GOOGLE_SERVICE_INFO_PLIST_TO}" I had this in my "Build Phases" and it's works "${PODS_ROOT}/FirebaseCrashlytics/run" "${PODS_ROOT}/FirebaseCrashlytics/uploa...

Android Firebase Phone Auth Not Receiving SMS Second Time

Answer : In my case, I have my number on Phone numbers for testing (optional) Removing it from there, firebase started sending SMS Code to my number. Spark Plan offer 10k phone auth per month. So that you can test and deploy your app without paying a penny. In case someone is not getting the concept or reason of not sent sms again then please go through on my below details. I have been confused for very long time that why I didn't get sms for second time, third and so on.. First Read the original documentation: onVerificationCompleted(PhoneAuthCredential) This method is called in two situations: Instant verification: in some cases the phone number can be instantly verified without needing to send or enter a verification code. Auto-retrieval: on some devices, Google Play services can automatically detect the incoming verification SMS and perform verification without user action. (This capability might be unavailable with some carriers.) ...

Can You Call Out To FFMPEG In A Firebase Cloud Function

Answer : ffmpeg is not preinstalled (pretty much just ImageMagick); to see exactly what's installed check out the Dockerfile here: https://github.com/GoogleCloudPlatform/nodejs-docker/blob/master/runtime-image/Dockerfile. However, you can upload arbitrary binaries when you upload your code using gcloud beta functions deploy because everything in the current directory (except node_modules ) is uploaded. Note: you only have disk write access at /tmp/ . Option 1: use ffmpeg-static npm module ffmpeg-static is an npm module that builds the correct ffmpeg binary based on the current system during npm install . Since Cloud Functions builds your code in the cloud, it'll build the correct ffmpeg binary. https://github.com/eugeneware/ffmpeg-static You can see it in action in the Cloud Functions for Firebase examples repo. const ffmpeg = require('fluent-ffmpeg'); const ffmpeg_static = require('ffmpeg-static'); var cmd = ffmpeg('/tmp/video.avi') ....