Skip to content

Instantly share code, notes, and snippets.

@shinoda-ak
Created May 1, 2017 08:28
Show Gist options
  • Save shinoda-ak/4c998f6ffa3f9ed716d6758329a17498 to your computer and use it in GitHub Desktop.
Save shinoda-ak/4c998f6ffa3f9ed716d6758329a17498 to your computer and use it in GitHub Desktop.
Firebase Instance ID token to AWS SNS target ARN
// Firebase Instance ID token to SNS target ARN
'use strict';
const AWS = require('aws-sdk');
const sns = new AWS.SNS({
apiVersion: '2010-03-31',
region: 'MY_SNS_REGION'
});
if (process.argv.length < 3) {
console.log('Usage: node add-endpoint.js FIREBASE_INSTACE_ID_TOKEN');
process.exit();
}
const PLATFORM_APP_ARN = 'MY_PLATFORM_APPLICATION_ARN';
const FCM_INSTANCE_ID_TOKEN = process.argv[2];
const params = {
PlatformApplicationArn: PLATFORM_APP_ARN,
Token: FCM_INSTANCE_ID_TOKEN,
CustomUserData: 'From Node.js on ' + process.platform
};
sns.createPlatformEndpoint(params, function(err, data) {
if (err) console.log(err, err.stack); // an error occurred
else console.log(data.EndpointArn || data);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment