Send AWS SNS notification to Android phone from AWS Lambda Node.js

Viewed 1192

I want to send AWS SNS to an android device endpoint from ASW lambda node.js but I keep having this error: "com.amazonaws.mobileconnectors.lamdainvoker.LambdaFunctionException:Unhandled"

the code is basically similar examples I saw here on stackoverflow:

config = require("./config.js").config;

var token = "1234567898123456789";

var AWS = require('aws-sdk');

AWS.config.update({accessKeyId: config.AWSAccessKeyId, secretAccessKey: 
config.AWSSecretKey});
AWS.config.update({region: config.AWSRegion});

var sns = new AWS.SNS();

var params = 
{'PlatformApplicationArn':config["AWSTargetARN"],'Token':token};

var message = 'Test';
var subject = 'Stuff';

sns.createPlatformEndpoint(params,function(err,EndPointResult)
{
var client_arn = EndPointResult["EndpointArn"];

sns.publish({
TargetArn: client_arn,
Message: message,
Subject: subject},
    function(err,data){
    if (err)
    {
        console.log("Error sending a message "+err);
    }
    else
    {
        console.log("Sent message: "+data.MessageId);

    }
});
});

The lambda function policy is set to; "Effect": "Allow" "sns: *" on the android applicationARN. So I'm guessing this is not a Role policy issue. Any help is appreciated. Thanks.

1 Answers
Related