How to use Ionic+Capacitor to register Push Notifications via Amazon SNS

How to use Ionic+Capacitor to register Push Notifications via Amazon SNS

Any guide on how to properly use ionic and capacitor to acquire tokens for SNS? I’ve seen the PushNotifications plugin but I’m not sure what “register” does? Do i have to setup my firebase and apn if im only using Amazon SNS?

Any guide/tips or overview steps will be useful.

Thanks

1 Like

Hey,

Did you make any progress here?

I am facing the exact same challenge soon.

Best,
Felix

I briefly looked over the SNS documentation for mobile push notifications and it looks like you still have to use FCM/APN in conjunction with it.

If you are using FCM for both Android and iOS, then a basic flow would be to get the FCM token on the device using the Push Notification Capacitor plugin, send it to your backend to register with SNS which in turn returns an EndpointArn. You then use that endpoint to send a notification to that specific device.

TBH, I don’t see the advantage of using SNS for push notifications. Maybe it simplifies the backend slightly?

Yeah, its a long process but I roughly went over it here: Ionic+Capacitor Push Notifications via Amazon SNS - Stack Overflow Goodluck!

1 Like

To use Ionic with Capacitor to register push notifications via Amazon SNS, you’ll need to integrate the Capacitor Push Notifications plugin and set up the necessary configurations for Amazon SNS. Below are the general steps to achieve this:

  1. Set up Amazon SNS:
  • Log in to the AWS Management Console and navigate to Amazon SNS.
  • Create an SNS topic to which you will subscribe your mobile app.
  • Create an IAM role that grants permission to publish to the SNS topic.
  • Obtain the AWS Access Key ID and Secret Access Key for your IAM role.
  1. Set up Capacitor Push Notifications Plugin:
  • Install the Capacitor Push Notifications plugin in your Ionic project if you haven’t already done so:

bashCopy code

npm install @capacitor/push-notifications
npx cap sync
  • Follow the official documentation for the plugin for platform-specific configurations and setup.
  1. iOS Configuration:
  • On the AWS SNS console, create an iOS platform application and provide the necessary information, such as the bundle identifier and APNs certificates.
  • Download the APNs certificate from Apple Developer and upload it to Amazon SNS.
  1. Android Configuration:
  • On the AWS SNS console, create an Android platform application and provide the necessary information, such as the Firebase Cloud Messaging (FCM) Server Key.
  1. Implement Push Notification Registration:
  • In your Ionic app, use the Capacitor Push Notifications plugin to request permission from the user to receive push notifications.
  • After obtaining permission, register your device with Amazon SNS by calling the register() method of the plugin. This will return a token unique to the device.
  • Send the device token to your backend server and subscribe it to the SNS topic you created earlier.
  1. Handle Push Notifications:
  • Implement the handling of push notifications in your Ionic app. When a push notification is received, the pushNotificationReceived event of the Capacitor Push Notifications plugin will be triggered. You can then handle the notification as desired, e.g., show a notification or update app data.
  1. Test Push Notifications:
  • Test push notifications on both iOS and Android devices to ensure everything is working as expected.
1 Like

What is the benefit of using AWS SNS if Firebase does all of this, and, to use SNS you have to set up Firebase?