Search code examples
amazon-web-servicespush-notificationaws-sdkamazon-sns

How to register "user id" reference for each SNS platform endpoint?


I'm configuring an SNS application and it's already registering platform endpoints for each device, and since I'm looking for a direct push notification capability for each user device, what's the better way to manage this relationship user <-> device?

I searched for the platform endpoint property UserId which first seem like a key for this relationship, but apparently, it's exclusively for Baidu platform, is that accurate? Keeping user's ids in CustomData also seems to be a bad decision given the lack of a method like listPlatformEndpointsByCustomData.

If so, I'm wondering if I'll need to persist all platform endpoint ARNs created at my user's entity and if it's reasonable.


Solution

  • The recommended approach is to have a 1:1 or 1:N User ID to Platform Application Endpoint ARN mapping in your database somewhere. As you highlighted, there is not a built-in solution for querying this type of data in SNS and therefore best handled in the application layer.