Closed seokjeatuiti closed 8 months ago
Hello, @seokjeatuiti 👋. Can you clarify what version of Android you're using and if you're seeing this on both physical devices and emulators? I wasn't able to reproduce this on more recent versions of Android, so if you could also provide your frontend code that's reproducing this issue it would be appreciated! I think we need to know where you're calling the Push Notification API's in the notification lifecycle/state of the app.
@cwomack
Thank you for answer! We have provided answers for each item you asked.
Can you clarify what version of Android you're using and if you're seeing this on both physical devices and emulators?
Yes it's happening on both physical device and emulator.
I wasn't able to reproduce this on more recent versions of Android, so if you could also provide your frontend code that's reproducing this issue it would be appreciated!
When notifications were being cut off, the settings were as follows. For reference, We provide both OTP for general users and USER_SRP_AUTH authentication methods for employees.
import { Amplify } from '@aws-amplify/core';
import awsConfig from './aws-exports';
import { Auth, Notifications, Analytics } from 'aws-amplify';
Amplify.configure({
...awsConfig,
Auth: {
authenticationFlowType: 'USER_SRP_AUTH',
},
Analytics: {
disabled: false
},
});
Notifications.Push.enable();
};
I was suspicious that Analytics might be causing a problem with the endpoint, so I added Analytics.disable()
, notifications started coming in fine from then on. I referred to this document.
Amplify.configure({
...awsConfig,
Auth: {
authenticationFlowType: 'USER_SRP_AUTH',
},
// Analytics: {
// disabled: false
// },
});
Analytics.disable();
Notifications.Push.enable();
};
The identifyUser part is as follows.
optOut
is not separately specified in the v5 official document, but when this part was excluded at first, there was a problem with the endpoint being created as optOut: All
.
export const updatePushToken = async (userId: string) => {
const token = await AsyncStorage.getItem('pinpointToken');
if (token) {
try {
const userProfile: AWSPinpointUserInfo = {
optOut: 'NONE',
};
await Notifications.Push.identifyUser(userId, userProfile);
} catch (e) {
console.error('updateEndpoint ERR', e);
}
}
};
I think we need to know where you're calling the Push Notification API's in the notification lifecycle/state of the app
We are sending notifications using pinpoint SDK through Lambda. There doesn't seem to be any particular problem in this part.
const AWS = require('aws-sdk');
const pinpoint = new AWS.Pinpoint({ region: 'us-west-2' });
...
const defaultMessage = {
Action: 'OPEN_APP',
Body: message,
SilentPush: false,
Title: senderName || '{Service Name}',
Data: {
conversationID,
},
};
const sendMessagesParams = {
ApplicationId: projectId,
SendUsersMessageRequest: {
Users: notifiedUsers,
MessageConfiguration: {
DefaultPushNotificationMessage: {
...defaultMessage,
},
APNSMessage: {
Badge: 1,
Priority: '10',
Sound: 'default',
ThreadId: senderId,
},
GCMMessage: {
Priority: 'high',
Sound: 'default',
},
},
},
};
await new Promise((resolve, reject) => {
pinpoint.sendUsersMessages(
sendMessagesParams,
(sendMessagesErr, sendMessagesData) => {
if (sendMessagesErr) {
reject(sendMessagesErr);
}
if (sendMessagesData) {
resolve(sendMessagesData);
}
},
);
});
}
By the way, this is an old post, but I experienced a similar problem once in the past, and registered an issue at that time. Please note.
Hello, I am encountering the same problem. Here are the CloudWatch logs:
2024-03-29T16:30:45.379Z 6a9370ac-fa6e-5925-8e45-2e2c148de650 INFO recipientResult { 'f1c91d2a-1236-408e-9d89-823185a51140': { DeliveryStatus: 'PERMANENT_FAILURE', StatusCode: 410, StatusMessage: '{"errorMessage":"Unregistered or expired token","channelType":"GCM","pushProviderStatusCode":"200","pushProviderError":"NotRegistered","pushProviderResponse":"{\\"multicast_id\\":\\"2421628289060879526\\",\\"success\\":0,\\"failure\\":1,\\"canonical_ids\\":0,\\"results\\":[{\\"error\\":\\"NotRegistered\\"}]}"}', Address: 'e5J1QAnFTPC0UmggiGi2qr:APA91bH3bGv5G4AsKWX6uPqiH7_uSEe0y_SxDBLDl09r8XehJUaX9Pl3RcIGoZZ6D-pWX3qVAhykeNgCFMuF6Mosy9qL20TzBiP8zXN6zbHj88iO64TGjBTWWBu4dTFqgwOj6c--kys9' }, '5b13560a-f123-42d5-a58d-d04768d9246c': { DeliveryStatus: 'PERMANENT_FAILURE', StatusCode: 410, StatusMessage: '{"errorMessage":"Unregistered or expired token","channelType":"GCM","pushProviderStatusCode":"200","pushProviderError":"NotRegistered","pushProviderResponse":"{\\"multicast_id\\":\\"6799976235612541133\\",\\"success\\":0,\\"failure\\":1,\\"canonical_ids\\":0,\\"results\\":[{\\"error\\":\\"NotRegistered\\"}]}"}', Address: 'eOZAYcL7SdaJiEyflrezSi:APA91bEsxIdFA0Gxk64sZ-m9L_5LZkbmn-mmQhAu4tC1tXZ4QGm-KSDZjosqeJg-qXvXJn4Y1inNdc9ygzZTImZN50OWkvJ0udQjLHwWC7J_BOB7DeIwQvjvo9aIjOsmPWLTYbFxtB86' }, '35124492-4045-4a64-99fb-cb2774b05a00': { DeliveryStatus: 'PERMANENT_FAILURE', StatusCode: 410, StatusMessage: '{"errorMessage":"Unregistered or expired token","channelType":"GCM","pushProviderStatusCode":"200","pushProviderError":"NotRegistered","pushProviderResponse":"{\\"multicast_id\\":\\"1526660718498104442\\",\\"success\\":0,\\"failure\\":1,\\"canonical_ids\\":0,\\"results\\":[{\\"error\\":\\"NotRegistered\\"}]}"}', Address: 'eC-us18cQxaLZHJ__m7bEz:APA91bHaV6Y9P1aqo34fxgnyCnOun_13F0w4h2sE8VtDnieZMaj2srZbqwtkkuLTt72sF0F5o9_ebzH9Qn6JdnNdDUJzOoBIm3jtNBf3fElFYOpVrZoEzRnSBc2HpY2VWljOESD0YMZv' }, 'cc0b8944-2ccf-4fa0-8ca2-e36c4986a7cc': { DeliveryStatus: 'PERMANENT_FAILURE', StatusCode: 410, StatusMessage: '{"errorMessage":"Unregistered or expired token","channelType":"GCM","pushProviderStatusCode":"200","pushProviderError":"NotRegistered","pushProviderResponse":"{\\"multicast_id\\":\\"3866949699306559810\\",\\"success\\":0,\\"failure\\":1,\\"canonical_ids\\":0,\\"results\\":[{\\"error\\":\\"NotRegistered\\"}]}"}', Address: 'ejd8IArJSy2-WLmp1IzxEw:APA91bGpOcYzg8QsGqFvTq0-hec_wDh-XIb5hP9Btq5Og1Y-_vO1NtxlWIzD6va-wUiBODwrIoK6oa9-_hl84cJiaMLzGeVCIeU-zAtuuzrioqlb4n06kRHJQDLrr9gt3GiOjTXczVl6' } }
@seokjeatuiti, is the token address in the error messages is the same one that you are using to send from the Firebase console? Any chance you can you share a couple of failures from the same device if possible? Curious to see if the errors are all showing the same address (or if anything changes).
@cwomack, Every time I started a new test, I deleted all endpoints using cli to ensure a clean experiment. Of course, since the token address newly created on the device was used during the Firebase Console test, it is unlikely that the token address in the two environments changed or was altered before or after the test.
The gist of what I posted was that the endpoint would be deleted after sending 1-2 messages, and that PERMANENT_FAILURE would be displayed when looking up the endpoint information through cli. It's not a problem with the token address. Fortunately, nothing special has happened since adding Analytics.disable()
(Please refer to the above).
In my opinion, this problem appears to have been caused by anomalous use of the Analytics module that does not match the version. I don't think we need to spend any more time on this issue. Therefore, I will close the ticket. Anyway, thank you.
Before opening, please confirm:
JavaScript Framework
React Native
Amplify APIs
Push Notifications
Amplify Version
v5
Amplify Categories
notifications
Backend
Amplify CLI
Environment information
Describe the bug
There is an issue where notifications keep disconnecting on several Android devices. What's a little strange is that notifications come well when the app is in the background, but once the app is in terminated state, only about 5-6 notifications come and then no more.
Once we reactivate or reinstall the app, it comes and goes a few more times and then disconnects again. Sometimes it comes without interruption, but it doesn't last long.
When I check the pinpoint endpoints using aws cli, they all show as active, but when I test them with send-users-messages, the error below occurs. If I send a test message through the firebase console, it comes in fine.
Expected behavior
Notifications should come continuously.
Reproduction steps
N/A
Code Snippet
Log output
aws-exports.js
Manual configuration
No response
Additional configuration
No response
Mobile Device
Galaxy S23+, Galaxy A53 5G, Pixel2 (API 33, Emulator)
Mobile Operating System
No response
Mobile Browser
No response
Mobile Browser Version
No response
Additional information and screenshots
No response