Can't create Firebase Cloud Messages From Console - firebase

For some reason, I don't see the ability for me to create FCMs from the Firebase console. It's not a browser issue as I tried on multiple browsers. It's not a permissions issue either since I am the owner of the project.
I tried implementing cloud functions to send FCMs and ever since when I go into the Cloud Messaging panel of the Firebase console I can no longer see the option to create messages.
Any insight would help!
Update--This is the error I'm getting from the JavaScript console:

Related

How to Fix Permission Issues in Firebase Cloud Functions (Nextjs Experimental Hosting)

I have an issue related to Firestore, Hosting, and Cloud functions. I deployed a Nextjs application using the just-released experimental web framework support. I'm using Nextjs's Image API, and as expected, the Firebase CLI creates a cloud function for the project. Everything works fine at the start, but when I try to open a page in the application that reads some data from Firestore, it redirects to an auth page, which is unexpected.
Even when I auth with my Google account (since that's the logged-in user to the application), it returns a forbidden error and logs me out.
When I go back and try again, it returns a different error (most likely because I was logged out automatically).
I tried doing some research, and some people suggested adding an allUsers principal permission to Cloud functions, but that didn't work (Error: Principals of type allUsers and allAuthenticatedUsers cannot be added to this resource), and that's even insecure permission. Only authenticated users should be able to read data from the page as already configured in my Firestore security rules. So it's unclear what I need to do since Firebase created the Cloud function automatically or if this is related to my security rules and cloud functions.
What could be wrong? Everything works fine in my existing deployment setup to Netlify (where Edge functions are created automatically using their Nextjs plugin). I'm only trying to test the new Firebase web framework hosting features. Please let me know if you'd need me to provide some more context or debug files to better help you help me.
Thank you!
The message “ App requesting permission to access your google account “ pops up if the function runs in any region other than us-central1.
Currently, Firebase Hosting does not support Cloud Functions in any other regions, Except us-central1.
You can refer to this StackOverflow thread.

React native firebase push notifications using expo permission

Can anyone help me to resolve this warning?
I am trying to send push notification using expo in React native.
I also tried to change permission from Notification to Permission but no luck.
warning when trying to access device token for send notification
Are you doing the managed flow or bare workflows?
I didn't get this exact message, but I got many that are similar. (I'm using a Managed flow). Likely culprit is a gap in your Firebase Cloud Messaging setup.
Be sure to review all the instructions expo here: https://docs.expo.dev/push-notifications/using-fcm/
I also added a response to an existing SO documenting some of my stumbling blocks which may be affecting you as well. That is here: Exception occurred while executing exported method getDevicePushTokenAsync on module ExpoPushTokenManager

Unable to call Firebase function from React.js application

I have a React.js application powered by a number of Firebase functions and real time database standing behind them. It has been working without any issue for the past 2-3 months and now I am getting a warning on the functions logs which says that:
#firebase/database: FIREBASE WARNING: {"code":"app/invalid-credential","message":"Credential implementation provided to initializeApp() via the \"credential\" property failed to fetch a valid Google OAuth2 access token with the following error: \"Failed to parse access token response: Error: Server responded with status 404.\"."}
The way I initialize firebase from my React.js application looks like this:
I have double-checked everything standing behind process.env and it seems to be as expected. The website written in React.js in hosted under the Firebase hosting.
And this is how Firebase functions connect to Admin SDK:
I am not sure what would be the issue here. Nothing has changes in the code base from our side. Not sure if Firebase changed something internally that we need to consider.
What solved the issue for me was to go to the google cloud console (where Firebase functions are also available). Then I opened one of the failing cloud functions and I navigated to
My_Function_Name/Edit/RUNTIME, BUILD AND CONNECTIONS SETTINGS/RUNTIME SERVICE ACCOUNT/
And then I noticed there that for all of my functions it was selected App Engine Default Service Account instead of Firebase Admin SDK. I never explicitly set the runtime to this option. So, when I brought it back to Firebase Admin SDK the error was gone I was able to use the application once again.

Firebase cloud messaging shows There was an error loading targeting options

I used Firebase cloud messaging to send the notification to the users but from last one week i am getting this error while targetting the App
There was an error loading targeting options.
I have same problem. Interesting thing, that message was shown when I switch to topic, play with it and when I returned back got that message.
So, I save as draft my notification, because I don't want to lose my filled data. Reload page or open again and now it is work as expected.

How to do logging with firebase and google cloud?

I'm using simply console.log('some flag', someObject) on Google Cloud and functions.logger.log('some flag', someObject) on firebase functions.
The problem is that both Firebase's admin panel logs page and Google Cloud's logs page makes this hard to read. Logs are getting split into lines. If my log had line breaks, then each line will be displayed as a separate log. Moreover, Google Clodu clearly has some kind of racing conditions when it comes to recording logs, as my logs are often displayed in the wrong order.
An obvious solution would be console.log('some flag', JSON.stringify(someObject)), but this makes logs hard to read in a different way. Now I have to copy the stringified object and JSON.parse it somewhere in browser console to make it readable.
What is the right way of writing logs in Firebase and Google Cloud?
The Cloud Functions logger SDK provides a standard interface that has a similar api to console.log statements and supports other log levels. You can use this SDK to log events with structured data, enabling easier analysis and monitoring.
The logger SDK supports log entries as part of a wildcard import. For example:
const functions = require("firebase-functions");
functions.logger.log("Hello from info. Here's an object:", someObj);
For Firebase Cloud Functions is better to use functions:logger to write logs and for reading logs use the command
firebase functions:log from CLI

Resources