amplify-android icon indicating copy to clipboard operation
amplify-android copied to clipboard

[Notification] Why are notifications not sent when the app is in the foreground?

Open TBSten opened this issue 11 months ago • 2 comments

Looking inside AWSPinpointPushNotificationsPlugin.handleNotificationReceived(), notifications are not displayed on the device when the app is in Foreground.

In some cases it may appear as if it could not be sent, which can be a source of confusion.

If this is the intention, it should be noted in the comments.

https://github.com/aws-amplify/amplify-android/blob/97ddb8b546c9d9f1807314eff2928cc0ca6afd92/aws-push-notifications-pinpoint/src/main/java/com/amplifyframework/pushnotifications/pinpoint/AWSPinpointPushNotificationsPlugin.kt#L329

TBSten avatar Jan 15 '25 05:01 TBSten

Thank you for posting this - the team will take a look and post updates here.

thisisabhash avatar Jan 15 '25 19:01 thisisabhash

It is intended as the standard behavior for Android notifications is to only display in the background: https://firebase.google.com/docs/cloud-messaging/android/receive.

This behavior is documented here: https://docs.amplify.aws/gen1/android/build-a-backend/push-notifications/record-notifications/#handle-notification-received.

If you want to show notifications while in the foreground, you can modify your extension of the FirebaseMessagingService to fit your needs.

I'll mark this as a feature request to clarify this behavior in code comments.

tylerjroach avatar Jan 21 '25 17:01 tylerjroach