Comments (6)
I did something close to this: @vparpoil
- Set up pinpoint notifications in the project + ensure test messaging is working for iOS and android
- I use appsync in my project - By attaching a resolver to a field you can send the resulting data from a mutation to lambda.
- Once the data is in lambda you can generate the push notifications
var AWS = require('aws-sdk');
exports.handler = (event, context, callback) => {
const pinpoint = new AWS.Pinpoint({ apiVersion: '2016-12-01', region: process.env.PINPOINT_REGION });
let whoSent;
let whoReceive;
let content = "tap to view message";
event && event.Records && event.Records.forEach((record) => {
console.log('Stream record: ', JSON.stringify(record, null, 2));
if (record.eventName == 'INSERT') {
whoSent = record.dynamodb.NewImage.senderUserId.S;
whoReceive = record.dynamodb.NewImage.receiverUserId.S;
content = record.dynamodb.NewImage.content.S;
}
});
// console.log(`executing push notification with content: ${content}, & receiver ${whoReceive}`);
const sendMessagesParams = {
ApplicationId: process.env.PINPOINT_APP_ID,
SendUsersMessageRequest: {
Users: {
[whoReceive]: {}
},
MessageConfiguration: {
APNSMessage: {
Action: 'OPEN_APP',
Title: 'You have a new message',
SilentPush: false,
Body: content
},
GCMMessage: {
Action: 'OPEN_APP',
Title: 'You have a new message',
SilentPush: false,
Body: content
}
}
}
};
pinpoint.sendUsersMessages(sendMessagesParams, (err, data) => {
// console.log('sendUsersMessages returned');
if (err) {
// console.log('AN ERROR OCCURED');
console.log(err, err.stack); // an error occurred
callback(null, 'error')
}
else {
// console.log('SEND MESSAGES SUCCEEDED');
// console.log(JSON.stringify(data)); // successful response
callback(null, 'success')
}
});
};
Does that make sense?
from docs.
I would like to send a push notification to certain users from a server programmaticaly. I feel like it's not yet supported (see here, push notifs are not listed). Is this being working on ?
Thanks a lot!
from docs.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
from docs.
@vparpoil Are you still looking for a solution to send push notifications programatically?
I've implemented them in my project and could detail my approach if you would like.
from docs.
@bernhardt1 I'm interested in how you did. I ended up using Google Firebase Cloud Messaging system, I would be happy to know other approaches
from docs.
Hello! We have launched a new version of
https://docs.amplify.aws/lib/push-notifications/getting-started/ for React Native, Swift, Android, and Flutter. You can follow this tutorial to learn more about programatically sending push notifications from your backend.
from docs.
Related Issues (20)
- Dropdown menu error when run locally HOT 1
- "Build settings" and "Environment variables" not accessible in console for Gen 1 App after Gen 2 update
- handling "CONFIRM_SIGN_IN_WITH_NEW_PASSWORD_REQUIRED" with aws-amplify/auth
- [missing-page] HOT 1
- Add troubleshooting section for micro-frontend support
- Add troubleshooting section for UnexpectedSignInInterruptionException errors with Safari
- Where is the content about `cron jobs` on Amplify Gen2's documentation? HOT 1
- Monorepo documentation is incomplete/unclear HOT 3
- Confirm Sign Docs are Missing
- mistake monorepo root path
- How to use Amplify datastore in Ionic/Capacitor project?
- Fix S3 bucket policy example to prevent "action does not apply to any resources in statement" error
- Gen 2 Quickstart guide: having to refresh browser to see updates HOT 1
- Event Bridge example with L2 Rule construct instead of L1 Cfn HOT 3
- Gen 2 Quickstart guide: missing `npm install` when setting up local environment HOT 1
- Gen 2 Quickstart guide: add section on deleting app
- Update improper text regarding cacheControl changes in v6
- Default name for GRAPHQL_ENDPOINT is incorrect
- Migrating DataStore to Gen 2
- Amplify Gen 2 Angular Documentation needs updates
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from docs.