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

AWS Pinpoint Campaign testing push notifications with APNS Sandbox does not start working after amplify add notifications #3247

Closed
lawmicha opened this issue Jan 23, 2020 · 3 comments · Fixed by #3669
Assignees
Labels
bug Something isn't working notifications Issues tied to the notifications category

Comments

@lawmicha
Copy link
Member

Describe the bug
When I enable APNS push notifications with key certificate via amplify add notifications, it appears to be enabled, however when I try to create a campaign and send a test message to my endpointId, it fails with Channel Disabled. The endpoint is set up with a device token for APNS sandbox. When I check settings, push notification is enabled. I checked the amplify-cli code and it looks like it's hitting updateApnsChannel. When using AWS Console to add the key certificate, it then works (device receives the notification) when I send test messages or launch the campaign.

Amplify CLI Version
4.12.0

To Reproduce

  1. amplify add analytics and amplify push
  2. amplify add notifications
 amplify notifications add
? Choose the push notification channel to enable. APNS
? Choose authentication method used for APNs Key
? The bundle id used for APNs Tokens:  <Your App's BundleID like com.yourname.projectname>
? The team id used for APNs Tokens:  XXXXXXXXX
? The key id used for APNs Tokens:  ABCDEXXXXX
? The key file path (.p8):  AuthKey_ABCDEXXXXX.p8
✔ The APNS channel has been successfully enabled.
  1. Make sure an app is registers for push notifications and then registers the token with APNS, and registers an endpoint with device token and APNS Sandbox with pinpoint.
  2. Make sure that single endpoint is picked up when choosing a segment when creating a campaign. Try sending a notification using Test message to the endpointId (can be printed out from pinpoint sdk logs), and fails with some message (AWS Console sometimes isn't very verbose, may be easier to test using AWS CLI but I don't have that set up)
  3. amplify console analytics and go to the Settings/Push Notifications/Edit, and under APNS re-add the key certificate
  4. Try creating a campaign/test message and it works!

I suspect that going through the console, it may be making calls to both update-apns-sandbox-channel and update-apns-channel

Expected behavior
amplify add notifications should allow us to specify apns sandbox or apns production since the key is used for both channels when Pinpoint sends authorization data to APNS. If I have to go to AWS Pinpoint Console to enable calls for APNS Sandbox, that kind of defeats the purpose of using amplify CLI for this step in the development. I think a solution could be by default; make a request to pinpoint to update both apns sandbox and production since that's what the key is used for. And ask Choose APNS environment: [Production|Sandbox|Both] and Both could be the default

Additional context
Some assumptions i've made

  • AWS Console/Pinpoint console/Enable notifications/APNS/Add key flow adds it to both APNS sandbox and production. I've only tested that my app starts receiving notifications after using the console, and amplify-cli call doesn't enable it for me since i'm using APNS sandbox.
  • Have not verified with AWS CLI to directly call update APNS sandbox and tested that notifications start working after that. Just know that using amplify add notifications results in not working
@yuth yuth added notifications Issues tied to the notifications category pending-triage Issue is pending triage labels Jan 23, 2020
@SwaySway SwaySway self-assigned this Jan 23, 2020
@SwaySway SwaySway added this to Josue bugs in Issue tracking Jan 23, 2020
@kaustavghosh06 kaustavghosh06 moved this from Josue bugs to Weimin bugs in Issue tracking Feb 10, 2020
@lawmicha
Copy link
Member Author

The P8 file, even when generating through apple's developer site indicates it's for both development and production
some related info: https://stackoverflow.com/questions/39672297/how-to-use-apples-new-p8-certificate-for-apns-in-firebase-console

which is why i think if we are registering the p8 file via Amplify CLi, we should simply call both update-apns-sandbox-channel and update-apns-channel. There will never be an option to register different p8 files for development vs production and so it won't make much sense to provide that as an option for the developer and may cause some confusion, plus more work on the developer to have to register it twice.

In terms of error handling, what if one update call fails and the other one succeeds? should we simply convey to the developer that the entire operation failed with the error from pinpoint service and prompt them to try again or open an issue with the repo?

@kaustavghosh06 kaustavghosh06 added bug Something isn't working and removed pending-triage Issue is pending triage labels Feb 17, 2020
UnleashedMind pushed a commit to UnleashedMind/amplify-cli that referenced this issue Mar 13, 2020
APNS Sandbox channel will be enabled/disabled when regular APNS channel is enabled/disabled

fix aws-amplify#3247
@UnleashedMind UnleashedMind moved this from Weimin to Akshay in Issue tracking Mar 16, 2020
@UnleashedMind UnleashedMind moved this from Akshay to Kaustav in Issue tracking Mar 16, 2020
@UnleashedMind UnleashedMind moved this from Kaustav to Edward in Issue tracking Mar 16, 2020
@UnleashedMind UnleashedMind moved this from Edward to Work-In-Progress in Issue tracking Mar 16, 2020
@lawmicha
Copy link
Member Author

thanks for the PR - updating docs aws-amplify/docs#1275

UnleashedMind added a commit that referenced this issue Mar 20, 2020
APNS Sandbox channel will be enabled/disabled when regular APNS channel is enabled/disabled

fix #3247

Co-authored-by: Zhou <zhoweimi@186590ce137f.ant.amazon.com>
@UnleashedMind UnleashedMind moved this from Work-In-Progress to Merged/Closed in Issue tracking Mar 23, 2020
@github-actions
Copy link

This issue has been automatically locked since there hasn't been any recent activity after it was closed. Please open a new issue for related bugs.

Looking for a help forum? We recommend joining the Amplify Community Discord server *-help channels for those types of questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 26, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working notifications Issues tied to the notifications category
Projects
No open projects
Issue tracking
Merged/Closed
Development

Successfully merging a pull request may close this issue.

5 participants