-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Removing Endpoint From User #13572
Comments
Hi @julian-dotcom, thank you for opening this issue. We are definitely aware there are some sharp edges to using these APIs and I'll try to explain what's happening under the hood a bit.
An endpoint can be thought of as the combination of a device + notification channel. E.g., all of these would be separate endpoints:
Under the hood, what Amplify is doing on each device when you use a specific channel's APIs is creating a unique endpoint for that device + channel combination. So if you want remove an endpoint from a user, you are actually looking to associate their device + channel combination to... some other user id (e.g.
As mentioned above, an endpoint should be tied to a specific device + channel combination - so as your user signs and an out (and you're calling
If your user is signing in on 15 different devices or reinstalling your app 15 different times - then 15 separate endpoints for your user would be created. However, this should still not be an issue because the Pinpoint service is supposed to automatically mark the least active push channel type endpoint as "inactive" - thus not counting against the 15 maximum. Given the above, could you help us understand better how you are running into the maximum endpoints issue? I am providing some background above but I would still need to understand your particular circumstances to narrow down the source of the issue. |
Wow, thank you for this explanation. I'll check in a bit. |
Unfortunately, this is not working as expected. When a user logs in, this is how I identify the endpoint:
When a user logs out, this is how I attempt to deregister the endpoint:
Unfortunately, this doesn't work as expected, where the following things go wrong:
Thanks and looking forward to the response. |
Hi @julian-dotcom, what I suspect might be happening is the wrong combination of userId, address and optOut values. Can you try the below code? When a user logs in, identify the endpoint: await PushNotification.identifyUser({
userId: userAttributes.sub,
userProfile: {
customProperties: {
locale: [userAttributes.locale],
},
},
options: {
address: deviceToken.token, // make sure there is an deviceToken present here.
optOut: 'NONE'
},
}); When a user logs out, attempt to deregister the endpoint: await PushNotification.identifyUser({
userId: userAttributes.sub,
userProfile: {},
options: {
address: '',
optOut: 'ALL',
},
}); Basing it on this Pinpoint documentation. |
@Samaritan1011001, thank you so much for the suggestion. I tried exactly as you suggested, but the following happens after logging out:
Using your above methodology, by logging in and out 15 times, I hit the threshold and can no longer create endpoints. This really sucks, how come there is no clear way to remove an endpoint from a user? |
@julian-dotcom sorry that did not work. Can you try this slightly different code. In my testing it removed the endpoint from the segment that had a criteria set to the customProperty value. I am assuming it means Pinpoint disassociated the endpoint from that user. After log in , await identifyUser({
userId: 'user1',
userProfile: {customProperties: {testProperty: ['test']}},
}); After log out, await identifyUser({
userId: 'user1',
userProfile: {customProperties: {testProperty: ['test']}},
options: {address: undefined, optOut: 'ALL'},
}); |
@Samaritan1011001, thanks again for your time and energy. Unfortunately, the suggested above also will not work.
I also tried it like this, where I do pass the device token, but to no avail. log in: await PushNotification.identifyUser({
userId: userAttributes.sub,
userProfile: { customProperties: { testProperty: ['test'] } },
options: { address: deviceToken.token, optOut: 'NONE' },
});
} log out: await PushNotification.identifyUser({
userId: sub,
userProfile: { customProperties: { testProperty: ['test'] } },
options: {
address: undefined,
optOut: 'ALL',
},
}); Thanks a lot! Any ideas? |
Just for my understanding, why would your above suggested method work? In one of your comments above, you said that the way to remove an endpoint from a user is to associate the device with another user id:
But what you suggested in your most recent comment is to use the userId in both calls. |
@julian-dotcom, this seems to be a limitation of the Pinpoint service to be able to remove a user from an endpoint. We're reaching out to the Pinpoint team to confirm if this is the case, and will provide an update as soon as we can. |
@julian-dotcom, we appreciate your patience on a response. Unfortunately, we do not currently have an API that allows for the direct removal of a user from an endpoint. The way Pinpoint's system is designed, once a user is attached to an endpoint via the updateEndpoint operation, that endpoint will always have a user associated with it. The only workaround we can suggest is to change the userId field for the endpoint to a different ID or an empty string. This would effectively “remove” the user, but the endpoint would still retain a user association. We understand this may not be an ideal solution, and we apologize for the inconvenience. The Pinpoint team is continuously working to improve their APIs and functionality, and we appreciate you bringing this issue to our attention. Please let us know if you have any other questions or concerns. |
Before opening, please confirm:
JavaScript Framework
React Native
Amplify APIs
Push Notifications
Amplify Version
v6
Amplify Categories
No response
Backend
None
Environment information
Describe the bug
How do we remove an endpoint from a user in push notifications?
Currently, to deregister a user and prevent him from receiving notification, I call this function, where
optOut: 'ALL'
ensures that no more notifications are sent:The issue with this approach is that while it works, you can only have a maximum of 15 endpoints per user. And if a user signs in & out multiple times, the endpoints get cluttered, and you reach a limit very soon.
What's the best approach to remove an endpoint from a user?
Seems like I'm not the only one facing this issue:
Amplify.Auth.signOut()
amplify-flutter#3179Expected behavior
Have function that simply allows you to remove/delete an endpoint on sign out.
Reproduction steps
Documentation.
Code Snippet
// Put your code below this line.
Log output
aws-exports.js
No response
Manual configuration
No response
Additional configuration
No response
Mobile Device
No response
Mobile Operating System
No response
Mobile Browser
No response
Mobile Browser Version
No response
Additional information and screenshots
No response
The text was updated successfully, but these errors were encountered: