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

Making push notifications work #49

Open
thomasorten opened this issue Feb 21, 2018 · 8 comments
Open

Making push notifications work #49

thomasorten opened this issue Feb 21, 2018 · 8 comments

Comments

@thomasorten
Copy link

Hi!
I'm trying to make push notifications work on the backend.
I see functions PlatformCreate in http/platform.go and core/platform.go, which takes an app, cert and key.
But I don't see these being called from anywhere. Would calling PlatformCreate e.g. on app creation create the necessary endpoints for SNS? Upon using terraform to set up the project with aws, I see a topic endpoint-state-change, but no platforms/applications in SNS. Or would there be a manual way of adding a platform and connections through the AWS console (not so familiar with sns)?

@xla
Copy link
Member

xla commented Feb 21, 2018

Hej!

Ideally the platform creation should be wired up in the SNAAS Console together with the other admin tasks, which is doable but currently not planned due to time constraints. If done tho, it would allow to create platforms per app for android, ios and ios sandbox and it shouldn't require to touch AWS at all besides a successful terraform run.

You have couple of options here:

  • Add platform handling to the Console
  • build a small binary which calls http.PlatformCreate with input from the command line
  • create Applications manually in SNS and insert the appropriate records into Postgres directly

Let me know if I can be of help with going further, or something is still unclear. Of course always happy to welcome contributions in form of PRs or documentation.

@thomasorten
Copy link
Author

Hi again,
Thanks for the response.
After the terraform run, only one topic is created in SNS.
Say I wanted to create a sandbox platform, here I pass the cert and key, and I do get a response back. The code:

handler.PlatformCreate( core.PlatformCreate( platforms, sns.AppCreateAPNS(snsAPI, "arn:aws:sns:eu-central-1:xxxxxx:endpoint-state-change"), sns.AppCreateAPNSSandbox(snsAPI, "arn:aws:sns:eu-central-1:xxxxxx:endpoint-state-change"), sns.AppCreateGCM(snsAPI, "arn:aws:sns:eu-central-1:xxxxxx:endpoint-state-change"), ), ),

Returns:

{"active":false,"arn":"arn:aws:sns:eu-central-1:xxxxxxx:app/APNS/test-1","deleted":false,"ecosystem":2,"id":"131350915914400267","name":"test-1","scheme":"http","created_at":"2018-02-22T21:41:06.845299Z","updated_at":"2018-02-22T21:41:06.845299Z"}

Still it seems no messages are delivered. Again, I'm not that familiar with SNS, but I have enabled logging to cloudwatch. Something else I need to be aware of?

Thanks again.

@xla
Copy link
Member

xla commented Mar 6, 2018

Hej @thomasorten how did go about the cert and private key of the app? Before you can configure SNS properly you need to setup those for your iOS app. The response indicates that the creds you passed to SNS couldn't be used when communicating to APNS (from SNS).

@thomasorten
Copy link
Author

Ah, ok. Basically passed the data from the console like such:

-d '{"name": "test-1", "ecosystem": 2, "scheme": "http", "key": "-----BEGIN PRIVATE KEY-----\xxx\n-----END PRIVATE KEY-----" , "cert": "-----BEGIN CERTIFICATE-----\xxx\n-----END CERTIFICATE-----" }'

What should be the correct response?

@thomasorten
Copy link
Author

The application is created, but there appears no connections to the platform endpoint is made. Devices are registered in the DB.

@xla
Copy link
Member

xla commented Mar 6, 2018

My answer was confusing. The response indicates that the platform was created, in order for it to be picked up by SIMS it needs to be activated. A bool that can be flipped in the DB.

@thomasorten
Copy link
Author

Ok I'll try that, thanks.

@thomasorten
Copy link
Author

Still trying to figure this out.. Must be something I'm missing..

Applications are set as production=true in DB.

When I publish a post, nothing appears in the SQS queue (object-state-change*).
Creating a connection though, does put a message in flight under connection-state-change, then later under connection-state-change-dlq.

I can create applications through PlatformCreate, and they do appear with certificates.

In DB, endpoint_arn under "devices" table of the app is empty.
Only one topic in SNS - endpoint-state-change..

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

No branches or pull requests

2 participants