Can a server configured with one Firebase project send notifications to an individual user of an app in a different project? - firebase-cloud-messaging

I am using Firebase with React Native. There are two different projects with one Android app under each project.
My backend server is configured to receive/store the FCM token of every individual app user. Right now, the same backend server caters to both apps. The FCM json config file for the backend server is based on one of the aforementioned two projects.
Can the backend send notifications to an user of either of the two apps, as long as it has their FCM token?

You can do this so long as it comes from the respective apps FCM credentials, this prevents abuse and FCM hijacking. this does not mean that you need cloud functions on multiple projects as you can manually instantiate new admin-sdk modules to connect and send FCM messages as needed.
Initiate Multiple Apps: https://firebase.google.com/docs/admin/setup#initialize-multiple-apps
A side note to consider: You may also be interested in registering the FCM if your app has multiple projects as only the default app is registered with normal behaviour.
FirebaseMessaging.getInstance(firebaseApp) for secondary app supposed to be public but it's private?

Related

Exposed Firebase Cloud Messaging Server Keys

I had used fcm to send notification in my app using api.after some days google send this and removed my app from play store.please help me.
I have tried everywhere not getting exact answer.
Put FCM Key in untrusted environment is a security issue, Any hackers are possible to send message to any user by using FCM key.
FCM key shouldn't exists in your public app like downloaded to your instance, Store in local storage, Hardcode inside application etc.
FCM key should only exists in trusted environment like your server, cloud functions etc.
You can also see this Do I need to protect my firebase Server Key?.

i want to remove the sign up flow from hosted ui but wish to keep it in my application where I am using the SDK. how can i do it

I am using AWS Cognito I want to remove the signup flow from hosted UI as I wish to do some application-level stuff during signup.(I can't do such stuff in pre-signup lambda). I tried changing the policy as advised by other links, but that causes trouble for the creating users through sdk (error : Users cant be created in this userpool).
Note: I can use AdminCreateUser function in the SDK but that changes my Userflow.
Please advice how to remove signup link from Hosted UI but allow it using SDK
You need to setup two different App Clients. In the console, there is a section called App Client Settings, at the top of the App Client Settings you will have Identity Providers you have configured, like Google, Facebook and Cognito User Pool.
At the moment you probably have one app client with all Identity Providers selected. In the hosted UI url, there is a parameter called client_id. Similarly in your SDK you specify a clientid to connect to.
You can setup two independent App Clients, with different identity providers and different client Ids. In you hosted UI client you can disable 'Cognito User Pool'.

Best Approach for Push Notifications for both IOS and Android

I am building the backend for our company's mobile app and we need to send notifications to users from API based on some events. I need some advice on how I can implement this. I am looking for a platform where I can send notifications for both IOS and Android. I recently came across Firebase and got some info that the mobile-app will send a device token to the server, then we will handle the push notification using this token. My assumption here is, I need to save this device token for all the users in a database and send the notification as necessary. Is this the best approach or are there any other good approaches for this? I am pretty sure there will a lot of solutions where I do not have to handle this myself (in database)
I was also looking into Azure Notification Hub for this, but the cons I felt here is that my UI guy (outsourced) is developing the application in React Native and I have not seen any good examples of React Native using Azure Notification Hub.
I am expecting around 1000 users for my application and I am developing my backend in ASP.NET WebAPI. Mostly I will have 2 types of notification
Push notification to specific user.
Push Notification regarding new installations to all the users
Well, according to my experience the best way and the easiest way is using firebase. You will have a lots of option there. In fact according to their comment, whether you're a beginner, intermediate or advanced React Native developer you can be up and running with React Native Firebase in no time.
https://www.npmjs.com/package/react-native-firebase
For more information and adding a project:
https://rnfirebase.io
Firebase getting start:
https://github.com/invertase/react-native-firebase-starter
How does it work?
Firebase Cloud Messaging architecture diagram
An FCM implementation includes two main components for sending and receiving:
A trusted environment such as Cloud Functions for Firebase or an app server on which to build, target, and send messages.
An iOS, Android, or web (JavaScript) client app that receives messages.
You can send messages via the Admin SDK or the HTTP and XMPP APIs. For testing or for sending marketing or engagement messages with powerful built-in targeting and analytics, you can also use the Notifications composer.
last comment copy-right: https://firebase.google.com/docs/cloud-messaging/

Sending Push Notification To All People Who Have Enabled Notifications For My Progressive Web App

I am in the process of developing a new site and have decided to add progressive web app capabilities to the site. I have set it all up correctly and I can send push notifications to devices with whom I know the endpoint via FCM with a cURL command.
My question is how do you send one to all users who have enabled notifications on my site without knowing a list of all users unique endpoints.
If you are using the Firebase Cloud Messaging Web SDK you should be able to get the Firebase token and subscribe that token a topic using the server side API and then you can message the topic.
NOTE: This requires the use of the Firebase Web SDK to work. This is not supported with the raw Web Push API.

One XMPP connection for more than one GCM/FCM app

I have a bunch of FCM projects and I'd like to use the same XMPP connection to send messages for all those projects. The FCM docs say that each connection needs to authenticate with the app id and server key, meaning I can use one XMPP connection for one project only. Is there any way around this?
I'm not sure what the question is here. Just use the corresponding Sender ID and Server Key from your Firebase Project. However, do note of the connection limitation mentioned in the docs you linked:
For each sender ID, FCM allows 1000 connections in parallel.
I don't really see any issue here, so long as you're using the same Firebase Project for FCM on all of your apps, you're good to go.
Unfortunately, if you have multiple projects, the only workaround I can only see that you can do is for you to use only a single project for your FCM processes.