Skip to content

User keeps receiving Pinpoint push notifications after Amplify.Auth.signOut() #3179

Open
@dJani97

Description

@dJani97

Description

We use Pinpoint to send push notifications, and to help with that we use the Amplify.Notifications.Push.identifyUser() method.

But it seems like after a user logs out, the endpoint associated with their current device does not get deleted and they keep receiving push notifications. This is not desired and could be a security concern.

I looked at the docs but couldn't find any information on how and when a pinpoint endpoint gets unregistered. Could you help me with that?

Expected behaviour

  • Amplify.Auth.signOut() is called
  • possibly another method is called, eg. Amplify.Notifications.Push.unassociateUser()
  • the user stops receiving push notifications on this particular device

Additional details

Here is how the client identifies the user with Pinpoint:

Future<void> registerUserWithPinpoint(Profile profile) async {
  final user = await Amplify.Auth.getCurrentUser();
  await Amplify.Notifications.Push.identifyUser(
    userId: user.userId,
    userProfile: AWSPinpointUserProfile(email: profile.email, name: profile.name),
  );
}

And here is how the server targets the client:

async function sendNotification(payload) {
  const sendNotificationInput = {
    ApplicationId: process.env.ANALYTICS_APP_NOTIFICATIONS_ID,
    SendUsersMessageRequest: {
      MessageConfiguration: {
        GCMMessage: {
          Title: payload.title,
          Body: payload.message,
          Data: { data: JSON.stringify(payload) },
          Priority: 'high',
        },
        APNSMessage: {
          Title: payload.title,
          Body: payload.message,
          Data: { data: JSON.stringify(payload) },
          Priority: '10',
        },
      },
      Users: {
        [payload.userId]: {},
      },
    },
  }
  return pinpointClient.send(
    new SendUsersMessagesCommand(sendNotificationInput),
  )
}

Categories

  • Analytics
  • API (REST)
  • API (GraphQL)
  • Auth
  • Authenticator
  • DataStore
  • Notifications (Push)
  • Storage

Steps to Reproduce

  • add plugins: AmplifyAuthCognito, AmplifyAPI, AmplifyAnalyticsPinpoint, AmplifyPushNotificationsPinpoint
  • configure amplify
  • sign in with Amplify.Auth.signIn()
  • associate the endpoint with a user: Amplify.Notifications.Push.identifyUser()
  • sign out with Amplify.Auth.signOut()
  • (backend): send a push notification for the user by userID

Screenshots

No response

Platforms

  • iOS
  • Android
  • Web
  • macOS
  • Windows
  • Linux

Flutter Version

3.10.4

Amplify Flutter Version

1.1.1

Deployment Method

Amplify CLI

Schema

No response

Metadata

Metadata

Assignees

Labels

DocumentationImprovements or fixes to public documentation (docs.amplify.aws, pub.dev, readmes).feature-requestA request for a new feature or an enhancement to an existing API or category.good first issueGood for newcomerspush notifications

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions