Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nolim1t/aws-lambda-sns
Explorings using AWS Lambda SNS to push stuff
https://github.com/nolim1t/aws-lambda-sns
Last synced: 2 days ago
JSON representation
Explorings using AWS Lambda SNS to push stuff
- Host: GitHub
- URL: https://github.com/nolim1t/aws-lambda-sns
- Owner: nolim1t
- License: mit
- Created: 2015-09-29T03:38:12.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2015-09-30T01:27:38.000Z (about 9 years ago)
- Last Synced: 2024-04-14T14:30:01.264Z (7 months ago)
- Language: JavaScript
- Size: 164 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# aws-lambda-sns Examples
## About
Explorings using AWS Lambda SNS to push stuff## Disclaimer
It's my first time with lambda. Proceed with caution## Apple's push notification docs
https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Chapters/ApplePushService.html## AWS IAM Policy
Make sure you grant write permissions to the lambda role
```
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "Stmt1443521471000",
"Effect": "Allow",
"Action": [
"sns:CreatePlatformEndpoint",
"sns:Publish"
],
"Resource": [
"arn:aws:sns:*:*:*"
]
}
]
}
```## How it processes stuff
Processes payloads in the following format:```javascript
var lambdapayload = JSON.stringify({
message: 'Hello World',
custom: {
senderid: 'testsenderid',
recipientid: 'testrecipient',
recipientname: 'Test Recipientname',
messageid: 'testmsgid',
devicetoken: 'token',
deviceplatform: 'ios'
}
});
```## To send the above
**Note** You may have to configure your own key and stuff.```javascript
var sns = new AWS.SNS()
var messagepayload = JSON.stringify({
default: 'This is a default message',
lambda: lambdapayload
});
var params = {
Message: messagepayload,
MessageStructure: 'json',
TopicArn: 'YOURARNHERE'
};
sns.publish(params, function(err,data) {
console.log(err);
console.log(data);
});
```