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

Amplify push notifications documentation doesn't include escape hatch (see storage and authentication) #3181

Closed
drmarkpowell opened this issue Aug 22, 2023 · 4 comments
Assignees
Labels
push-notifications Issues related to the Push Notifications category question General question transferred This issue was transferred from another Amplify project

Comments

@drmarkpowell
Copy link

Describe the content issue:
We don't want to use Pinpoint for mobile push, just SNS. We don't do user tracking in our app.

There is not yet any "escape hatch" tutorial for push notifications that provides guidance on how to drop down to the lower level SDK for SNS (topic subscription, device registration, etc.)

URL page where content issue is:
https://docs.amplify.aws/lib/push-notifications/getting-started/q/platform/ios/

@abdallahshaban557 abdallahshaban557 transferred this issue from aws-amplify/docs Aug 25, 2023
@abdallahshaban557 abdallahshaban557 added the transferred This issue was transferred from another Amplify project label Aug 25, 2023
@abdallahshaban557
Copy link

Hello @drmarkpowell - You can use Pinpoint with push notifications without needing to use user tracking. Is there another reason you would want to use SNS other than not wanting to use user tracking from Pinpoint?

@ruisebas ruisebas added push-notifications Issues related to the Push Notifications category bug Something isn't working labels Aug 28, 2023
@ruisebas ruisebas self-assigned this Aug 29, 2023
@ruisebas
Copy link
Member

ruisebas commented Sep 1, 2023

Hi @drmarkpowell! We've added the escape hatch API to the Push Notifications plugin, which was missing in Swift's implementation. It will be available in the next release.

Having said that, the escape hatch will only give you the PinpointClientProtocol instance that the Amplify category uses.
It will not allow you to switch services to SNS.

@ruisebas ruisebas added the pending-community-response Issue is pending response from the issue requestor label Sep 1, 2023
@drmarkpowell
Copy link
Author

drmarkpowell commented Sep 1, 2023

This addition is very welcome!

What is the best documentation to explain what IAM policies are needed for using Pinpoint as a service?

Our application also uses Govcloud where amplify-cli is not working yet, so it's extra difficult for us to understand what's happening under the hood in order for our cyber DevOps folks to assess whether we can use it.

After 2 hours of mostly failures, we were able to tentatively glean that

  • Pinpoint appears to require Analytics (and some of its associated policies)
  • Pinpoint appears to require Lambda (and some of its associated policies)

It would be great to understand what Pinpoint needs to have to operate and thus how we can consider applying it to our use case, which is pretty simple:

  • iOS mobile app can register its device to receive push notifications
  • iOS mobile app can (un)subscribe to and receive push notifications by topic (in the SNS sense of "topic")
  • Python can publish a notification on any given topic to all (subscribed) users

@5d 5d added the question General question label Sep 5, 2023
@ruisebas ruisebas removed the bug Something isn't working label Sep 8, 2023
@ruisebas
Copy link
Member

ruisebas commented Sep 8, 2023

Using Amplify's Push Notifications in your app does automatically record session-related analytics events on every app launch.
A "session" is basically a use of the app, and the event types recorded are these:

  • _session.start: Always recorded.
  • _session.stop: Only recorded if the app was previously run.

To use Amplify's Push Notifications without using the CLI to set up the resources, here's what you have to do:

Create a Pinpoint Project

  1. Sign in to the AWS Management Console and open the Amazon Pinpoint console.
  2. Under the Get started section, enter a name for your project and click the Create a project button.
    • If you already have existing projects, a Manage projects button will be displayed instead. Click it and then click Create a project.
  3. In the Configure features page, click the Configure button under the Push Notifications section.
  4. Select Apple Push Notification service (APNs) and configure it properly by providing the required information.
  5. Click on Save and write down the Project ID.

Create an Identity Pool

  1. Navigate to the Cognito console.
  2. Select Identity pools and then click on the Create Identity pool button.
  3. Check what type of authentication you want to use. If you don't want to sign up/sign in users, you can check only Guest access.
    • If you want to use Authenticated access, then you'd need to configure the identity sources as well, e.g. Cognito User Pool.
  4. Create a new Guest IAM role.
  5. Name your Identity pool.
  6. Click on Create Identity pool and write down the Identity pool ID.

Configure the IAM role for Amplify's Pinpoint usage

  1. Navigate to the IAM console.
  2. Select Roles under Access management.
  3. Search for the Guest IAM role you created and click on it.
  4. Under Permissions policies, click on Add permissions and select the Create inline policy option.
  5. Click on the JSON button and paste the following content, replacing it with your AWS account number and the Pinpoint Project ID:
{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "Statement1",
            "Effect": "Allow",
            "Action": [
                "mobiletargeting:PutEvents",
                "mobiletargeting:UpdateEndpoint"
            ],
            "Resource": "arn:aws:mobiletargeting:*:[AWS ACCOUNT]:apps/[PINPOINT PROJECT ID]*"
        }
    ]
}
  1. Click on Next, write a name for the policy and then click on Create policy.

Set up Amplify's Push Notifications in your Xcode project

  1. Follow the instructions on this page on how to set up your application for Amplify's Push Notifications. You can skip the Set up backend resources section.
  2. Follow the instructions on this page on how to request Push Notifications permissions and how to register the device with Pinpoint.
  3. Finally, create a amplifyconfiguration.json file with the following contents:
{
    "notifications": {
        "plugins": {
            "awsPinpointPushNotificationsPlugin": {
                "appId": "[PINPOINT PROJECT ID]",
                "region": "[REGION]"
            }
        }
    },
    
    "auth": {
        "plugins": {
            "awsCognitoAuthPlugin": {
                "CredentialsProvider": {
                    "CognitoIdentity": {
                        "Default": {
                            "PoolId": "[COGNITO IDENTITY POOL ID]",
                            "Region": "[REGION]"
                        }
                    }
                }
            }
        }
    }
}

That's it 😃! Now you can use Pinpoint to send push notifications to your app users. You can create Segments to target specific users with Campaigns and/or Journeys.

@ruisebas ruisebas added the closing soon This issue will be closed in 7 days unless further comments are made. label Sep 14, 2023
@github-actions github-actions bot removed pending-community-response Issue is pending response from the issue requestor closing soon This issue will be closed in 7 days unless further comments are made. labels Sep 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
push-notifications Issues related to the Push Notifications category question General question transferred This issue was transferred from another Amplify project
Projects
None yet
Development

No branches or pull requests

4 participants