google-cloud-functions

Value of firebase functions onwrite sometimes is null

情到浓时终转凉″ 提交于 2021-01-29 12:03:44
问题 I'm trying to implement an Android ordering system and I'm using Realtime Database. To send notifications I'm using Firebase Functions in JavaScript. Each user is stored in the database along with their id, token to send the notification, among other data. What I'm trying to do is detect when a user receives an order and send them a notification . The problem appears here. In some cases the notification is sent and in others it is not . Viewing the logs of my "sendNotif" function I see that

How to add new column with metadata value to csv when loading it to bigquery

不打扰是莪最后的温柔 提交于 2021-01-29 11:59:37
问题 I have a daily csv file coming into my bucket on google storage and I built a function that load this csv and append it into a table in BigQuery when it comes in. However, I want to add a new column to the csv with the function execution id (context["id"]) before I load the data to Big query. is that possible? thanks in advance! def TimeTableToBigQuery(data, context): # Getting metadata about the uploaded file, the storage and datetime of insert excution_id = context['event_id'] bucketname =

Is my function not resolving correctly? Also it won't write to firebase to the databse. No errors

情到浓时终转凉″ 提交于 2021-01-29 11:25:19
问题 I have a cloud function that runs with no errors, however, it won't write to the database after Promise.all I've tested this function in a web browser and the data seems to resolve correctly after the Promise.all. When I put this into a cloud function a console.log() after Promise.all shows the original data and not the updated data, as if it's skipping the forEach and resolving right away. I don't get this behavior when the function runs in a browser. On top of that, the data will not write

Sending email through firebase cloud functions

孤街浪徒 提交于 2021-01-29 10:34:41
问题 I have a big query table containing email of the users and i want to send them a newsletter email ( around 500 rows in table) When the function runs it only sends email to 30-35 users after that time out, if i reduce the list to 100 it sends email for the multiple time on one email id Below is my code -: bigQuery.query({ exports.date = functions.https.onRequest((req, res) => { const bigQuery = bigquery({ projectId: 'littleone-150007' }); var someVar = []; var someVar1 =[]; bigQuery.query({

How to complete login only after functions.auth.user().onCreate is finished

◇◆丶佛笑我妖孽 提交于 2021-01-29 09:55:42
问题 I'm using firebase functions and I have a function which add new collection when user is creating. The problem is sometimes user is logged in before function is done, so user is logged in but new collection is not created yet (and then I have error message 'Missing or insufficient permissions. because a rule cannot find that collection'). How can I handle it? Is it possible to finish login user (for example using google provider) only when all stuff from export const createCollection =

Firebase Cloud Function error: Registration token(s) provided to sendToDevice() must be a non-empty string or a non-empty array

北慕城南 提交于 2021-01-29 09:29:31
问题 I want to send a notification to all users who are confirmed guests when the object confirmedGuests is created in the Firebase Realtime Database. So, I first create an array of all the users from confirmedGuests object. Then, I iterate through all these users and push their deviceTokens to an array of deviceTokens. The array allDeviceTokens is expected to be the array of device tokens of all users in confirmedGuests. However, when confirmedGuests object is created, the function returns an

add a property to a created object (Firebase Functions)

北城余情 提交于 2021-01-29 09:19:36
问题 I'm hooking to the creation of objects on a specific collection (orders) I need to add a new property to the object before it's saved, not returning anything, to no avail. I have looked at the documentation at https://firebase.google.com/docs/reference/functions/functions.firestore.DocumentBuilder#writing_data but it's for onUpdate so it doesn't work as i intend it. exports.createOrder = firestore.document('orders/{orderId}').onCreate((snap, context) => { const newOrder = snap.data() console

Is it possible to connect a local Functions emulator to a non-local Firebase Realtime Database?

限于喜欢 提交于 2021-01-29 09:14:48
问题 Due to problems using a Realtime Database emulator for development in Flutter ( see How do I connect to my local Realtime Database emulator in my Flutter app? ), I am now simply using my non-local Realtime Database for development. However, I am also using Cloud Functions, and I have created a Functions emulator. I tried the following to connect to it, based on this StackOverflow-answer: const functions = require("firebase-functions"); const admin = require("firebase-admin"); functions.config

google cloud platform cloud build rebuild cloud function not updated the content

孤人 提交于 2021-01-29 09:13:50
问题 I put the file on Github and connected with Google Cloud Repository. Below is the .yaml file, when I update my index.js file, the Cloud Build rebuilds the Cloud Function, but why the content didn't get updated? Manually setup for Cloud Function works steps: - name: 'gcr.io/cloud-builders/yarn' args: ['install'] dir: 'functions/autodeploy' - name: 'gcr.io/cloud-builders/gcloud' args: ['functions', 'deploy', 'function-1', '--trigger-http', '--runtime', 'nodejs10', '--entry-point', 'firstci']

On authentication triggers I am getting displayName as null

岁酱吖の 提交于 2021-01-29 08:52:07
问题 I want to use users data on authentication trigger. But when I am using them it gives me null. What is wrong with my code? exports.sendWelcomeMessage = functions.auth.user().onCreate((user) => { const name = user.displayName; console.log(name); return null; }) 回答1: I speculate you are creating the user and then setting the display name (eg via 2 calls). onCreate triggers as soon as the user is created, eg createUserWithEmailAndPassword . When you call updateProfile to set the displayName ,