I've two android apps that share same project in firebase infrastructure
When i was preparing the firebase infrastructue to run the second one i decided for creating a second app in the same firebase project as the first one... this was a decision made basically because i hated the firebase "switch between projects" tools.
both apps ran great for over a year being hosted as same project although not sharing real resources
BUT NOW I RUN INTO A PROBLEM
I added FCM into the apps and i cant find a way to send messages to topics in a specific app...
firebase let me only choose between send message to specific app or specific topic...
both apps have same topics names and now if any user has both of them installed at the phone i cant imagine how firebase will behave when i send a notification to a topic the user has two different apps subscribed to.
does anyone know how to solve this?
You can't stop the message from going to both apps. But what you can do is put something in the message to say which app it was intended to go to. The app can then choose to ignore messages it's not supposed to handle.
Related
I've been through the other threads on this issue and haven't found a solution. My case may be unusual.
I have just inherited a production mobile app (Ionic/Angular) that is available on Google Play Store and Apple App Store. I didn't have to create a new google-services.json or a new GoogleService-Info.plist file. I have access to the Firebase Console. I did have to replace the .p8 key for iOS in order to get APNs to play nicely.
I can send a single notification to a single FCM token for Android and iOS with no problem. But when our production system sends notifications they are often multiple duplicates. Additionally, we routinely send (for those subscribed) multiple but different notifications to the same device(s). For example, a user who is subscribed to topics A and B will normally get a single notification for each subscription. But right now, they'll get 3 of the same notification from A but only 1 from B (B, in this example, seems to behave normally). NOTE: the particular topic is irrlevant. The only thing that seems to matter in this case is that the first one will multiply and second is received only once.
Our server logs show only a single instance of sending any given notification despite multiples being received by devices.
I first suspected, and still do, that somehow during the "transition" of the project, somewhere in FB and Apple, there is a dangling reference to the original certs/keys/projects. I don't see how I can confirm/reject that idea. I also doubt it's the case. I need any and all suggestions because I'm out of ideas! Thanks in advance.
I have two Android applications; for the time being, let them be "A" and "B", and they both connect up with different firebase projects. My main objective here is to send notifications to app "B" whenever any changes are being made in the firestore of app "A" so that the user of app "B" would check up on the changes that are being made and evaluate them accordingly.
I have an idea of how Firebase Cloud Messaging works, and I am successfully sending and receiving notifications between different android devices that use the same android application. But when sending notifications between two different applications present on two different devices, I have no idea what shall I do, and I am currently stuck here for the past week. So I will be grateful to those who can help me get an idea of how can I achieve this.
You can add multiple apps to one Firebase project:
You can add app B to Firebase project A and use project A for FCM messages.
Look here :
https://firebase.google.com/docs/projects/multiprojects
I am new with FCM and I am still discovering its possibilities.
I wonder if it is the right tools to do what I want:
I would like to send a notification to all my users, to inform them about new informations for example.
The difficulty is that I want to target all the users of different apps (like 10 apps), and some of them may have more than one of my app installed.
So I do not want a user to have the same notification displayed multiple times (if he installed more than one of my app).
Is it something possible with Firebase?
Thank you
Yes you can! To achieve this, i recomand you using Google Cloud Messaging not FCM. which it's an earlier version. Here is a tutorial on how you can migrate from FCM to GCM.
To achieve this, all your 10 apps must use Firebase and all your users must be Firebase registered users. To send a notification to all devices, would mean then to select all the registration ids from that database, add them in an array and pass them further to GCM.
Note also, that strating with GCM 3.0 it's now possible to send a notification to all devices thanks to topics support. The app must suscribe to one or more topics and the server can send notifications to that topic without specifying individual devices. You can see here Topic Messaging.
Unfortunately, there is no way in which, with a single line of code, to send a notification to all of your users from all your apps. You can only send a notification to all your users that belong only to a single app. If you want that all of yours to get the same message, then you need to consider sending that particular message again, to all users that belong to each app. In this case, if a users is using more then one of your apps, will receieve that message for each app separately.
I have created one project in my Firebase Account. In this project, I have added two android apps.
Now, while sending push notification through Firebase console, I see the option of selecting my individual app as shown below
But, while sending notification through Postman, I don't know how can I send notification to only a particular app?
Should I create two individual project for both my apps, so that the server key is different?
But, I feel there should be a way to send notification without creating multiple projects for multiple apps.
Sending notifications to user segments is not available programatically i.e. not available when using the API.
A workaround you could use is Topics Messaging, creating a topic for the specific app and subscribe the corresponding users.
I see that apps like facebook for example are getting push notifications in real time. When someone writes a message to me from a pc ill get the message to my android device as push notification just a second later even when my facebook app is not running.
Im wondering how it works because for my app i need a quite similar behaviour. There is also a messaging and an alert mechanism between server and client but i cant imagine how i could implement it so that i can get real time updates from the server to the client even when the app is not started.
Does someone know?
Yes, use Sync Adapter with GCM (Google Cloud Messaging) :
http://developer.android.com/training/sync-adapters/index.html
Read the tutorial i provided, you will at least know what to use.
And check this SO question, it has good answers (especially the accepted one) :
Sync data between Android App and webserver