Open jamespanyp64 opened 4 months ago
Hello, @jamespanyp64 👋. Have a few questions to ask you tied to this to see if we can better diagnose the root cause:
Hi, thank you for getting back quickly.
remote notification
and push notification
enabled. The only step we did perform is step 4 and step 6 as we didn't see change All
is prompted.
Hi @Cosmooooo, We're investigating this issue, in the mean time could you try increasing the priority to High and see if this helps
Hi @ashwinkumar6 - Thanks for getting back to us but unfortunately increasing to high priority didn't work for us either. Wondering if there's any update or ETA of fix on the issue?
Hi @jamespanyp64, thanks for checking that. On our side, we tested with RN 0.73 and 0.74 and don't see this issue happening. However, we did find that when testing back to back background messages that the iOS system can throttle the message delivery behavior (which is something we can't control). Please refer this piece of documentation which explains why they do a best effort to deliver it.
In my efforts to improve it, I found that updating the apns-push-type
header value to background
might increase it being delivered to the device. This header is to be set by Pinpoint when pushing the message to APNs but you may test it using Apple's Push Notification console directly. You can find more information of the header value here. Note that this is best efforts to improve the delivery from APNs to the device when testing.
Hi @Samaritan1011001, Thank you for this info. Unfortunately, we have tried to increase priority and using background type, but background listener is still not able to be triggered consistently. At the same time, we don't think background is what we are trying to use, what we are trying to do is have our custom logic (for example, badge count increase) be executed when a normal notification (alert) comes in when app is in background or terminated state. We would like to confirm that we should use Amplify background listener for this purpose and there is no misunderstanding during conversation.
@Cosmooooo Thank you for the use-case info. To increment or set the badge count this way, I would suggest you to use the backend notification payload since iOS does not reliably and consistently invoke the native APIs that onNotificationReceivedInBackground
uses. iOS restrictions as stated here:
However, the system does not automatically launch your app if the user has force-quit it. In that situation, the user must relaunch your app or restart the device before the system attempts to launch your app automatically again.
You may specify the badge count when sending the notification from Pinpoint. When you use the "raw message" on the Pinpoint console or their API, you can provide the badge count in the payload as shown below.
"APNSMessage": {
"aps": {
"alert": {
"title" : "title",
"body" : "body"
},
"badge": 100
}
},
Hi @Samaritan1011001, thanks for your reply! As @Cosmooooo mentioned above, we are trying to have some custom logic executed in onNotificationReceivedInBackground. The basic reason is this: we are implementing a chat function in our app, and thus there's a screen for showing "all the chat rooms I'm in". Currently we need to do a GET against all the rooms to get the latest message which has a bad performance because there are multiple rooms that don't have any new messages at all. Thus we'd like to rely on this amplify background listener as a tool to help us update the rooms with new messages when the app is in background, so that we don't have to do the GET again when the user opens the app. Based on the context above, can you please provide some suggestions on what amplify tool we can use to improve the performance?
Before opening, please confirm:
JavaScript Framework
React Native
Amplify APIs
Push Notifications
Amplify Version
v6
Amplify Categories
notifications
Backend
Amplify CLI
Environment information
Describe the bug
AWS backgroundNotificationListener not triggered at all.
Expected behavior
AWS backgroundNotificationListener should be triggered when the app is on the background or terminated.
Reproduction steps
Code Snippet
index.js
notificationListener.js
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