-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Question] How to send data for broadcastMessage API? #26
Comments
Hi @alimustofa, You can use Then you just send a single message to the const SNS = require('sns-mobile');
const SNS_KEY_ID = process.env['SNS_KEY_ID'];
const SNS_ACCESS_KEY = process.env['SNS_ACCESS_KEY'];
const ANDROID_ARN = process.env['SNS_ANDROID_ARN'];
const androidApp = new SNS({
platform: SNS.SUPPORTED_PLATFORMS.ANDROID,
region: 'eu-west-1',
apiVersion: '2010-03-31',
accessKeyId: SNS_KEY_ID,
secretAccessKey: SNS_ACCESS_KEY,
platformApplicationArn: ANDROID_ARN,
//sandbox: true (This is required for targetting (iOS) APNS_SANDBOX only)
});
const BROADCAST_TOPIC = 'SOME_TOPIC_ID_FROM_SNS_DASHBOARD';
exports.registerUser = function (deviceId, callback) {
// first register the user
androidApp.addUser(deviceId, {}, function(err, endpointArn) {
if(err) {
callback(err);
} else {
// now subscribe the user to the broadcast topic (like a channel)
androidApp.subscribe(endpointArn, BROADCAST_TOPIC, callback);
}
});
};
exports.sendBroadcastMessage = function (msg, callback) {
// every user will get this message
androidApp.publishToTopic(BROADCAST_TOPIC, msg, callback);
}; You can read about the |
If you have any further problems you can reopen this @alimustofa |
But is it possible use broadcastMessage? Can I modify msg format to add custom data from broadcastMessage API? |
Ooops, solved @evanshortiss |
Hi @evanshortiss, I am using broadcastMessage to publish news, but I want to send some data to the mobile device (for example id). Is it possible?
Please help me, thanks
The text was updated successfully, but these errors were encountered: