Push notification from AWS Rules

Ionic brains! Help me out with this…

I need to use push notifications in my mobile app. My case is this - data comes from a Thing (which has a deviceId) and arrives at AWS IoT. The data triggers a rule to generate a push notification. The push notification will go to the user’s phone, i.e. the person who owns the Thing. The Thing itself doesn’t know anything about it’s owner, so neither will the incoming packet. What is the best practice for joining the dots between the IoT rule and the identifier (the app’s token?) that is used to direct the push notification to that specific phone.

My initial thinking was using the IoT Rule to publish to a Topic including the /deviceId/ of the Thing. Then in the mobile app, subscribe to a topic for each deviceId, since the owner does know which devices they own.

How would you architect this? Keen to hear some good options! Thanks all.

Before the tumble weeds become deafening, I’ll share my own research on this question. There are hundreds of ways to achieve this, but from my research, the easiest seems to be using the OneSignal Ionic plugin and accessing it with the API to link it up to the AWS backend.

The glue that sticks it all together is using the external_user_id parameter to link the user at log-in to the OneSignal service. The vital thing is that you are using your own custom identifier which will be known to the app and the back-end. That way, when something happens in the backend that you need to push, you find the corresponding user Id for the resource, push with the OneSignal API, and OneSignal will understand your audience selection.

Whether you use Lambda or PinPoint & SQS in AWS is down to your ability to not use a different service for everything you do, for no rational reason. So, I’m undecided. You will also need to use Firebase for the Android etc.

It’s actually not that hard in the end. Just a lot of moving parts to consider. Have fun. Hope this helps someone else.