I'm trying to figure out how can I send a message to many FCM clients, from Lambda, using SNS service.
All resources I found are referring to creating an SNS Application Endpoint for desired device token, but I don't understand this approach. If I have thousands of devices, and their tokens can change (I have a mechanism of announcing new tokens and saving them into DynamoDB already developed), should I update them in the SNS endpoints "database" as well, all the time?
The only example I found is to do it like this:
var AWS = require('aws-sdk');
const sns = new AWS.SNS()
...
const params = {
PlatformApplicationArn: '<Platform Arn>',
Token: '<FCM Token>'
};
const endpointData = await sns.createPlatformEndpoint(params).promise();
const paramsMessage = {
Message: snsPayload,
TargetArn: endpointData.EndpointArn
};
await sns.publish(paramsMessage).promise();
And after that, how can I publish a message for more FCM tokens at once?
I know that I can call Firebase API directly and not to use SNS at all, but I'm curious if it is not intended to use for this scenario, or Am I missing something?