logo
Tags down

shadow

Reduce numbers of request Firebase


By : ali
Date : October 01 2020, 12:00 AM
seems to work fine Firestore pricing is based on document (object) reads: https://cloud.google.com/firestore/pricing with a minimum charge of one document for every query, even if there are no results.
Since documents contain the key/value pair fields (https://cloud.google.com/firestore/docs/data-model) you should only get charged per document, not per field.
code :


Share : facebook icon twitter icon

Firebase server side auth with HTTP POST request using the firebase secret


By : mukharom
Date : March 29 2020, 07:55 AM
To fix the issue you can do The URL cannot parse json. It's just a string of text. Simply include the token directly.
code :
curl -X https://INSTANCE.firebaseio.com/users/jack.json?auth=zXRLa7lybhJ21ZYqpXuqkT6YAYyySAGJ10lXInKy  // not { auth: '...' }
var token = tokenGenerator.createToken({"app_user_id": 1234, "isModerator": true });
".read": "auth.isModerator === true"

Firebase Function HTTP Trigger - Error: could not handle the request - Firebase Not Defined


By : the_noisies
Date : March 29 2020, 07:55 AM
seems to work fine You're not importing any module named firebase. Instead you import the Firebase Admin SDK as admin. So you'll want to use admin.database().
code :
const functions = require('firebase-functions')
const admin = require('firebase-admin') // name used here
admin.initializeApp(functions.config().firebase)

module.exports = (event) => {
  event.grabAwards = functions.https.onRequest((request, response) => {
    admin.database().ref('/awards/{pushId}').once('value') // must match name used here
      .then(function(snapshot) {
        var awards = snapshot.val();
        res.status(200).send(awards);
      }).catch(error => {
        this.errorMessage = 'Error - ' + error.message
      });
  })
}

How to compare the phone contacts numbers with the Firebase registered numbers?


By : Lord Furyan
Date : March 29 2020, 07:55 AM
this will help I am trying to display the phonebook contacts' numbers in a RecyclerView but only those are registered in the Firebase database where the contacts numbers are the key. , Assuming that you have declared 2 lists that look like this:
code :
List<String> phoneBookList = new ArrayList<>();
List<String> finalList = new ArrayList<>();
Firebase-root
  |
  --- firebaseDatabasePhoneNumbers
            |
            --- firebaseDatabasePhoneNumberKeyOne
            |       |
            |       --- //details
            |
            --- firebaseDatabasePhoneNumberKeyTwo
                    |
                    --- //details
DatabaseReference rootRef = FirebaseDatabase.getInstance().getReference();
DatabaseReference firebaseDatabasePhoneNumbersRef = rootRef.child("firebaseDatabasePhoneNumbers");
ValueEventListener valueEventListener = new ValueEventListener() {
    @Override
    public void onDataChange(DataSnapshot dataSnapshot) {
        List<String> firebaseDatabaseList = new ArrayList<>();
        for(DataSnapshot ds : dataSnapshot.getChildren()) {
            String firebaseDatabasePhoneNumber = ds.getKey();
            firebaseDatabaseList.add(firebaseDatabasePhoneNumber);
        }

        for(String phoneBookNumber : phoneBookList) {
            if (firebaseDatabaseList.contains(phoneBookNumber)) {
                finalList.add(phoneBookNumber);
            }
        }

        //Do what you need to do with the finalList
    }

    @Override
    public void onCancelled(DatabaseError databaseError) {}
};
firebaseDatabasePhoneNumbersRef.addListenerForSingleValueEvent(valueEventListener);

Submit User Inputted Numbers to be Run through a firebase function which adds the numbers and displays the result to the


By : echolist
Date : March 29 2020, 07:55 AM
hope this fix your issue This is not an exactly correct answer but at least a good path to make an calculations out of Angular application. Im using Angular 7+ in this example. In Angular 4+ or 6+ do not use angularfire2 library it's an old version of @angular/fire library.
Firebase have a nice tool named Firebase Functions you can use them to make calculations out of your application. More about them: https://firebase.google.com/docs/functions/.
code :
import * as functions from 'firebase-functions';
import * as admin from 'firebase-admin';

// This is example of how to make an simple callable function.
export const getUsers = functions.https.onCall((data, context) => {
    return caseAdmin(data, context, getUsersList)
})
// this function will return users list if a user who call a function is an admin.
async function getUsersList() {
    try {
        const usersList = await admin.auth().listUsers()
        return usersList.users
    } catch (err) {
        console.log(err)
        return { code: 'admin/get-users-list', message: "Some thing goes wrong." }
    }
}
// This function check are user have an isAdmin field in his token. To assign that kind of field to user token read about custom claims.
export function caseAdmin(data: any, context: functions.https.CallableContext, callback: any){
    switch (isAuth(context)) {
        case 'isAdmin':
            return callback(data)
        case 'isEditor':
            return { code: 'admin/set-admin-error', message: 'Access denied! Only admin can add admin.' }
        case 'user':
            return { code: 'admin/set-admin-error', message: 'Access denied!' }
        case 'unknown':
            return { code: 'admin/set-admin-error', message: "Access denied!" }
        default:
            return { code: 'admin/set-admin-error', message: 'Unknown problem.' }
    }
}
// this function check are user is authenticated and what role he have.
export function isAuth(context: functions.https.CallableContext) {
    if (context && context.auth && context.auth.token.isAdmin) {
        return 'isAdmin'
    } else if (context && context.auth && context.auth.token.isEditor) {
        return 'isEditor'
    } else if (context && context.auth) {
        return 'user'
    } else {
        return 'unknown'
    }
}
export class AdminService {

  constructor(private fc: AngularFireFunctions) {
     // bellow line only for local texting so you can run functions localy
    // this.fc.functions.useFunctionsEmulator('http://localhost:5000') 
  }

  // Asignning what function you want to use.
  getUsersList() {
    const usersList = this.fc.httpsCallable('getUsers')
// empty object but function no need any. Context is sended automatically you can decide are user need to be authenticated or not are he have to be an admin or not. Best way to assign users role is by functions using custom claims.
    return usersList({})
  }
}
import * as functions from 'firebase-functions';

export const getUsers = functions.https.onCall((data, context) => {
    return { message: "Hello message from onCall function"}
})
users$: Observable<any>

constructor(private fc: AngularFireFunctions) {
    // this.fc.functions.useFunctionsEmulator('http://localhost:5000')
  }

  onButtonClickGetUsers() {
    const usersList = this.fc.httpsCallable('getUsers')
    this.users$ = usersList({}) // here observable are making https requests to onCall functions so you get response Observable<{ message: "..."}>
  }
<div *ngIf="users$ | async as user"> {{ user.message }} </div>
<button (click)="onButtonClickGetUsers()">Get Users</button>

Cloud Functions for Firebase - Getting Network error even though I'm making outbound http request for firebase-admin fun


By : Mohammedshafi
Date : March 29 2020, 07:55 AM
around this issue That warning message appears for all functions when executing on the Spark plan. It's just a warning - you can ignore it if you're not doing any outbound networking on your own.
We're looking into getting that message changed or removed so that it's less confusing.
Related Posts Related Posts :
  • WebAssembly dynamic module unloading
  • Call SWS Via Sabre Red Workspace From Native API Bridge Application
  • How to set query timeout when using Presto CLI?
  • What's the difference between agent.add() and conv.ask() on dialogflow
  • Pymodbus - Read input register of Energy meter over rs485 on uart of raspberry pi3
  • Execute bash script on a dataproc cluster from a composer
  • Gremlin: select vertex based on comparison of two property values
  • How do you createRef in Suave Fable?
  • I am having trouble building Azerothcore on Windows 10 Home, VS 2017
  • Why is testcafe-docker.sh ignoring app-init-delay parameter?
  • DynamoDB Adjacency List Pattern
  • Is there a way for my aplication to detect beacons in Powerapps?
  • "Initialize interactive with Project" is missing for .Net Core Projects in Visual Studio 2019
  • Cosmos db Order by on 'computed field'
  • let a rpm to automatically install centos-release-scl-rh
  • What is the "Stage" folder inside MarkLogic Installed Directory? How does MarkLogic use this folder?
  • Implement requestHooks in cucumber/testCafe
  • Jhipster: How can I only generate a back-end microservice application
  • Building a database of average speed from two cameras using cloudant entries
  • Move file from inbound adapter after publish subscribe flow
  • Is there enough of a difference between WebSphere 8.5.5 on Linux vs Windows to warrant testing our application in WebSph
  • Wait some seconds before agent's reply
  • Is there a Apache Beam + Cloud Bigtable connector in Golang?
  • How I can convert ampl file to cplex?
  • Is there a description of the mecab (Japanese word parser) algorithm?
  • CALL SYMPUT a character operand was found in the %EVAL function
  • Problem 1 Write the PRETTY-PRINT procedure, which takes one argument (a generalized list), and prints it using the follo
  • How to get the merchant, where a NFC-enabled pass is used?
  • Determine RFC caller?
  • Does appium-dotnet-driver support .net core 2.x?
  • Error:Internal error: (java.lang.ClassNotFoundException) com.google.wireless.android.sdk.stats.IntellijIndexingStats$Ind
  • RxJS do not throw error while mapping even when underlying observable throws error
  • What is the difference between last and publishLast operator in rxJS?
  • Displaying Select Box from enum data
  • How to disable and hide the pagination footer for react-table?
  • Airflow 1.10.3 SubDag can only run 1 task in parallel even the concurrency is 8
  • Red Hat Fuse ESB Community vs Enterprise edition
  • Map subtask_id to TaskManager in Flink
  • Why do we need semaphores on single cpu?
  • appRole defined in AzureAD application not being included for guest user of type "External Azure Active Directory&q
  • Angular material mat menu styling issue
  • OctoberCMS from input to databse
  • cloud function with pub sub trigger does not work across regions
  • Eventlistener for paper-dropdown-menu in Lit-html
  • Combining the elements of array and reformatting the output
  • How do i generate Agent Credentials for Bosch IoT Permissions?
  • Unable to interact with the ledger (invoke and query only happening on world state (couchdb))
  • Kentico 12 MVC - Customize BizForm response
  • AutoHotkey: list all open windows
  • Docompose tag by its content/text
  • Make concat_lines_of( ) work for rawstring
  • Naming steps as Tasks vs Statuses in Process Design
  • Why is a true value rendered as "value"?
  • JSON Validate check based on response from arrayElement
  • Is it posible to have multiple grapesjs instances on the same page?
  • How to show commands being executed in fish shell function
  • How group patterns are evaluated/joined in SPARQL
  • Understanding mariadb deadlock
  • SaveOptions field not being honored..is my solution correct?
  • How does one easily install Nvidia drivers for Google's container-optimized OS?
  • shadow
    Privacy Policy - Terms - Contact Us © 35dp-dentalpractice.co.uk