Skip to content
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

Amazon SNS support #711

Closed
wants to merge 5 commits into from
Closed

Amazon SNS support #711

wants to merge 5 commits into from

Conversation

rogerhu
Copy link
Contributor

@rogerhu rogerhu commented Feb 28, 2016

TODOS:

  • GCM payload code is shared with GCM.js. To instantiate though you need to supply a GCM key. For Amazon SNS, we don't need to do it.
  • Modify Promise chain to grab all the Amazon ARN's per device token (right now it is looping 1 to 1)
  • Chunking the GCM token delivery (may reuse the GCM .js code if possible) - Amazon SNS doesn't look like it allows bulk deliveries.
  • Test coverage
  • Document how this works:
if (process.env.SNS_ENABLE) {

    pushConfig =  { pushTypes : { android: {ARN : YOUR-ANDROID_ARN-HERE},
                                 ios: {ARN: YOUR-IOS_ARN-HERE}, production: false, bundleId: "beta.parseplatform.yourappname"}
                                 },
                   accessKey: process.env.SNS_ACCESS_KEY,
                   secretKey: process.env.SNS_SECRET_ACCESS_KEY,
                   region: "us-west-2"
                 };

    var SNSPushAdapter = require('parse-server/lib/Adapters/Push/SNSPushAdapter');
    var snsPushAdapter = new SNSPushAdapter(pushConfig);
    pushConfig['adapter'] = snsPushAdapter;
}

a. Adding Platform endpoints to AWS console
b. Add IAM roles for platform
c. CloudSearch logs debugging

The worst part of adding was figuring out AWS SNS JSON encoding:

http://bit.ly/215rLnq

@flovilmart
Copy link
Contributor

for the payload, you could create a static function in GCM.js so you won't need instantiation.

@facebook-github-bot
Copy link

@rogerhu updated the pull request.

@facebook-github-bot
Copy link

@rogerhu updated the pull request.

@facebook-github-bot
Copy link

@rogerhu updated the pull request.

@rogerhu rogerhu changed the title WIP - Amazon SNS support Amazon SNS support Feb 28, 2016
@facebook-github-bot
Copy link

@rogerhu updated the pull request.

@facebook-github-bot
Copy link

@rogerhu updated the pull request.

@facebook-github-bot
Copy link

@rogerhu updated the pull request.

@facebook-github-bot
Copy link

@rogerhu updated the pull request.

@facebook-github-bot
Copy link

@rogerhu updated the pull request.

var self = this;

// Exchange the device token for the Amazon resource ID
for (let device of devices) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use

let promises = devices.map((device) => {
   return this.exchangeTokenPromise(device, pushType);
});

@codecov-io
Copy link

Current coverage is 91.33%

Merging #711 into master will decrease coverage by -0.59% as of 0d20824

@@            master    #711   diff @@
======================================
  Files           91      92     +1
  Stmts         5736    5826    +90
  Branches      1043    1058    +15
  Methods          0       0       
======================================
+ Hit           5273    5321    +48
- Partial         11      12     +1
- Missed         452     493    +41

Review entire Coverage Diff as of 0d20824

Powered by Codecov. Updated on successful CI builds.

@nitrag
Copy link

nitrag commented Mar 14, 2016

Is this ready to go?

I don't see a SNS Access key/secret in AWS control panel and it only limits you to two of these types of keys. What about using process.env.AWS_ACCESS_KEY and process.env.AWS_ACCESS_SECRET just like S3 Adapter?

Is all of this supposed to be included? or just the name portion?

android: {ARN : "arn:aws:sns:us-east-1:xxxxxxxx:app/GCM/name"

@rogerhu Would you mind updating the Wiki with examples/docs on how to set this up in AWS?

@facebook-github-bot
Copy link

@rogerhu updated the pull request.

@rogerhu
Copy link
Contributor Author

rogerhu commented Mar 14, 2016

You have to grant Identity Access Management (IAM) permissions to a user/role. You then generate an AWS key from there.

@nitrag
Copy link

nitrag commented Mar 14, 2016

@rogerhu

Can't do this:

var SNSPushAdapter = require('parse-server').SNSPushAdapter;

Error: Cannot find module 'parse-server'

@rogerhu
Copy link
Contributor Author

rogerhu commented Mar 14, 2016

Is there somewhere that says you can?

require('parse-server/lib/Adapters/Push/SNSPushAdapter') assuming this branch is pulled in.

@nitrag
Copy link

nitrag commented Mar 14, 2016

I'm trying to test and starting to realize it's harder than I thought.

What's your package.js look like? I've got a folder called
parse-parse-server in my parse-example root. I've cloned your
parse-server#apn branch there and ran npm install. Then I'm trying to "npm
install" in my parse-example folder with your dependency in package.js but
it's failing.

On Mon, Mar 14, 2016 at 4:23 PM, Roger Hu [email protected] wrote:

Is there somewhere that says you can?

require('parse-server/lib/Adapters/Push/SNSPushAdapter') assuming this
branch is pulled in.


Reply to this email directly or view it on GitHub
#711 (comment)
.

@rogerhu
Copy link
Contributor Author

rogerhu commented Mar 14, 2016

You can go to your parse-server-example and do:

npm link parse-server ../parse-server

Or edit dependencies for parse-server-example in package.json to reference the parse server locally:

 "dependencies": {

   "parse-server": "file:../parse-server"
 },

To force reinstall, npm install parse-server

@nitrag
Copy link

nitrag commented Mar 14, 2016

Is the .babelrc needed in your parse-server?

How do I install these prereq's?

@nitrag
Copy link

nitrag commented Mar 15, 2016

@flovilmart What's the ETA on merging this? Thanks!

@nitrag
Copy link

nitrag commented Mar 17, 2016

@rogerhu can you fix branch conflicts? I'm hoping to start using SNS ASAP. Thanks for your work!

@rogerhu rogerhu force-pushed the sns branch 2 times, most recently from 05989a6 to c25001a Compare March 17, 2016 21:45
@facebook-github-bot
Copy link

@rogerhu updated the pull request.

1 similar comment
@facebook-github-bot
Copy link

@rogerhu updated the pull request.

@rogerhu
Copy link
Contributor Author

rogerhu commented Mar 21, 2016

Finally got to pass again =)

@gfosco
Copy link
Contributor

gfosco commented Mar 21, 2016

This is very cool.. but like #971, I'd really like to see this as a separate module instead of part of the core server. 971 became https://www.npmjs.com/package/parse-server-sendgrid-adapter, and this could be parse-server-sns-adapter.

@rogerhu
Copy link
Contributor Author

rogerhu commented Mar 22, 2016

I have changes to APNS and GCM that would need to be added...you guys OK if I break out as a separate PR and then fork the rest into a separate adapter module?

@gfosco
Copy link
Contributor

gfosco commented Mar 22, 2016

Yeah, break out the changes you'd like to make in a PR. I was going to counter that they don't need to be made, but, it does es6-ify things which I think we want, so go for it. I'll close this one, you can submit a PR and make your separate module for SNS. Thanks. 👍

@gfosco gfosco closed this Mar 22, 2016
@rogerhu
Copy link
Contributor Author

rogerhu commented Mar 23, 2016

To be clear some of the changes need to be made to leverage the APNS/GCM payload creation. https://github.com/ParsePlatform/parse-server/pull/1158/files

@rogerhu
Copy link
Contributor Author

rogerhu commented Mar 26, 2016

Final plugin has been moved here and successfully tested. Updated docs too:

https://github.com/parse-server-modules/parse-server-sns-adapter

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants