Skip to content
This repository has been archived by the owner on Nov 6, 2019. It is now read-only.

push notifications #12

Open
edzillion opened this issue Aug 10, 2018 · 2 comments
Open

push notifications #12

edzillion opened this issue Aug 10, 2018 · 2 comments
Labels
enhancement New feature or request

Comments

@edzillion
Copy link
Contributor

edzillion commented Aug 10, 2018

Amazon offers a push notif service that should do the job. Some thinking about what users should be notified needs to be done before we can implement this fully

related to: CirclesUBI/circles-api#32

@edzillion edzillion added the enhancement New feature or request label Aug 10, 2018
@edzillion
Copy link
Contributor Author

Looked into the various options and settled on Amazon SNS; which gives us fairly straightforward implementation of push messages to android / ios.

SNS requires that each client be registered with a deviceId. For the moment I am using Expo.Constants.deviceId but this will be changed to a native implementation later. I originally built a very basic express server to test this device registration, but then realised it could be done in the confirmUser lambda with a bit of work.

  • infrastructure-provisioning/circles-sns repo holds the terraform build for the SNS resources, as well as a test server (which I will remove now).
  • circles-sns repo holds the code for this test server. This is now redundant as I have moved things to lambda but could be used for an sns microservice in future if that was the route we take.
  • circles-lambdas contains the confirmUser() function which calls the sns function to register a device endpoint (so that we can message this user later):
var sns = new AWS.SNS({apiVersion: '2010-03-31'})
exports.handler = (event, context, callback) => {
  var snsParams = {
    PlatformApplicationArn: process.env.ANDROID_ARN,
    Token: event.request.userAttributes.deviceId
  }

  sns.createPlatformEndpoint(snsParams, function (err, data) {
    if (err) console.log(err, err.stack)
    else console.log(data)
  })
}
  • I have added a custom field to the Cognito User Pool called 'deviceId' which is pulled out of the request and used to set the Token param.

This is as far as I have gotten, obviously we need a db table to associate userNames with these endpoints.

@edzillion
Copy link
Contributor Author

The previous sns registration stuff was moved from the FE to the circles-api. We need to extend this somewhat and need a full notification api to simplify messaging to the various platforms etc, and on the frontend we will need a way to interpret these messages.

we could either go for this popular package https://github.com/zo0r/react-native-push-notification

tutorial here: https://medium.com/@thexap/show-push-notifications-on-react-native-app-a613a5a2c159

Or we could use amplify (perhaps with a redux saga to queue events etc):

https://aws-amplify.github.io/docs/js/push-notifications

related to: CirclesUBI/circles-api#32

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant