Search code examples
amazon-web-servicesfirebasefirebase-cloud-messagingamazon-sns

whats the benefits of using AWS SNS with firebase cloud messaging(fcm) to send push notifications


I'm trying to integrate fcm for push notifications and we're also using some aws services for development. I want to understand what’s the use of aws sns with fcm as i did some research and found out that we can use fcm to send push notifications without aws sns so what are the advantages of using the aws sns.


Solution

  • SNS provides a few advantages over calling FCM directly:

    • Retries: if the API call to FCM to send the push notification fails for some reason (networking issue, FCM having availability issues, etc.), then SNS will retry the deliveries for you, so as long as you successfully publish the message to SNS, it will be delivered eventually.
    • Latency: publishing a message to SNS is asynchronous from its delivery and therefore is very fast, especially if you're doing this from within AWS. This has the benefit that if you have a blocking process that tries to publish a message to multiple devices, this process may finish a lot faster.
    • Throughput: if you wish to deliver a large number of messages quickly but do not have a lot of server capacity, letting SNS use its larger fleet to do the deliveries for you makes sense as it will result in more notifications getting delivered every second.
    • Broadcasts: using SNS topics, you can make a single API call to fan out a notification to millions of devices. If you wanted to do this yourself, you'd have to make one call to FCM for each device.
    • Device status: SNS will also keep track of which devices' tokens are now invalid and invalidate the associated PlatformEndpoints for you. This removes some metadata that you might otherwise need to keep track of.

    Those are a few things that come to mind!