0
votes

I trying to understand how FCM (Push notifications) works... and that is very differ with Web applications...

What I did →

  1. Register new project in Firebase
  2. Added App com.google.firebase.quickstart.fcm and download google-services.json
  3. Built App using google-services.json in Android Studio
  4. Install APK on my device
  5. Go to https://console.firebase.google.com/project/{PROJECT_NAME}/notification and sent new notification
  6. And... nothing happens

So my questions are

  1. As I know here is two ways to send notification: a) use device token and send direct notification, b) subscribe device to topic at client side.
    But
    a) When I try to create New notification in firebase console, here is no field where I will be able to insert device token. Here is Target → Target user if → App → com.google.firebase.quickstart.fcm. So do I need to know device token or I can send notifications to all clients that have my app installed on their devices?
    b) When I trying to send message on weather topic nothing happens. Even if I pressed button Subscribe to weather (In manual you may find Subscribe to News, but actual version button is weather)
  2. Is there any way to check (especially at server side) if my device registered in FCM or not?
  3. What is the most effective way send same contents on big number of devices (for example 50000) with minimum time lag? Try to loop over device tokens (1000 tokens per request) or using topics? Is there any other ways?
  4. Actually my backend is AWS SNS in pair with FCM, so if you can answer about most effective way in case of SNS + FCM that will be brilliant
  5. I don't know... any suggestions? I'm a web developer (REST, etc...) and have zero experience with mobile apps
1

1 Answers

1
votes

1- You will need to store the current device tokens in a database to then loop through each one to send a message.

Topics need to be subscribed to from the client side and have limited use

2 - you should be storing it in a database, sending an FCM will yield an error if it is expired, which you will have to remove and wait for the client to re-send a fresh token

3 - Topics is common practice, have every device listen to a 'global' topic but there is a native delay as FCM is designed for maximum output rather than time sensitivity. for that, you will need external services that specialize in high speed messages.

4 - you can invoke cloud functions to invoke other firebase services, even the rest API and onTrigger listeners on a database are valid

5 - FCM is great, but it's not the best as it was created as a general solution. a combination of different CM services is recommended, especially if you have time-sensitive needs. but they do come at a cost while FCM is free.