Open MensurRasic opened 7 months ago
To add more context to this ticket, here is to operations we do that lead to the bug.
We want to push a notification to a user based on a lambda trigger.
The lambda get the userID who inserted the new object in dynamoDB that triggered the lambda.
Then we get the user endpoints with the function PINPOINT.getUserEndpoints.
When the app is opened for the first time, the lambda function works great, but when we kill the appm suddently the lambda throws the following error : NotFoundException: Resource not found
But, we can still send and receive notification through the pinpoint test messaging console.
Hello @MensurRasic, and thank you for providing detailed context and reproduction steps. Just to get further details on reproducing the issue, are you closing down the app before any events are flushed from the buffer?
@MensurRasic, can you clarify if you're using authenticated or unauthenticated users? In the event of unauthenticated users, it's possible that Push Notifications still work because of an endpoint being tied to the device token... but the killing of the app then causes the user to be incorrect once it's rebooted.
@cwomack In my scenario I was using an authenticated user.. And the user session was still there even after closing/re-opening the app. I was not able to retrieve user endpoints after the second time I kill the app. But here are my findings and alternative I took.
Observation
I setup a lambda function with a trigger to be executed each time a new item was inserted into MessageTable to push a notification to a user. To push a notification, I was using the function SendUsersMessages but it was throwing the error NotFoundException: Resource not found
.
So I decided to retrieve endpoints before sending the notification using the pinpoint function GetUserEndpoints, in order to get all the user endpoints and send the user a notification on all his devices... But unfortunately, there seem to be a problem with those pinpoint functions to retrieve endpoints by passing the userID. As mentioned, after the second time I was killing the mobile app, the function GetUserEndpoints
was throwing the error NotFoundException: Resource not found
...
So I took the endpointID that was working initially on the first run (before killing the app twice) and I was able to push notification to endpoints using the AWS Pinpoint console. So I was wondering how it was possible for the device to receive those notifications from the pinpoint console but the function GetUserEndpoints
was not able to retrieve the endpoints...
So I wrote another function, but this time I was using SendMessages function.. and it was working 100% of the time even when GetUserEndpoints
was throwing the error...
Alternative
Since SendMessages
was working all the time, I am now storing the endpointID in the DynamoDB each time the user authenticate using the lambda function post authentication and I am sending notifications only on the last device the user is authenticated...
The alternative is working great on iOS and Android... but the pinpoint functions mentioned above are clearly buggy and not working properly as suggested by the documentation.
Hopefully this can give you a more insight on the bug.
@MensurRasic, we are looking into this again after thinking it may be related to what's reported on the v6 side within #13174. Not sure if you've had the chance to upgrade to v6, but curious if you're seeing the same behavior still in v6 that is reported in that issue. Would love to get any additional context or confirmation from you if so!
Before opening, please confirm:
JavaScript Framework
React Native
Amplify APIs
Analytics
Amplify Categories
analytics, notifications
Environment information
Describe the bug
I have a react native app using amplify analytics/notifications to push notifications to users. But there seems to be a bug where pinpoint delete constantly user endpoints without any specific logic when I open the app and kill it instantly.
This is impacting our user experience since we cannot be consistent with our logic regarding push notifications. I reproduced this bug and everytime I kill the app, reopen it, the user endpoints are deleted for further new notifications.
Expected behavior
Pinpoint shouldn't be deleting user endpoints when the user close the react-native app.
Reproduction steps
Code Snippet
Log output
aws-exports.js
No response
Manual configuration
No response
Additional configuration
No response
Mobile Device
iPhone 8, iPhone XR, iPhone 14 pro
Mobile Operating System
No response
Mobile Browser
No response
Mobile Browser Version
No response
Additional information and screenshots
No response