Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Expo Push Notification Detection

how can i detect when coming notification and make some changes when app is closed...

I'm using expo-notifications https://docs.expo.io/versions/latest/sdk/notifications/

like image 274
Sahak Stepanyan Avatar asked Nov 24 '25 18:11

Sahak Stepanyan


1 Answers

Your app is not notified when it is closed/backgrounded, until the user interacts with it.

From the Expo 38 release notes:

If the notification is triggered while the app is in background,

  • it’s presented immediately

  • the application is not informed of this

If the notification is triggered while the app is in foreground,

  • the application not only receives immediate information about this, but…

  • it can also decide at runtime whether to display a heads-up alert or play a sound! (For more information see the Notification Handler documentation.)

From the Notifications overview, there are 2 listeners:

addNotificationReceivedListener - This listener is fired whenever a notification is received while the app is foregrounded

addNotificationResponseReceivedListener - This listener is fired whenever a user taps on or interacts with a notification (works when app is foregrounded, backgrounded, or killed)

The Notifications SDK is a good reference as well.

like image 149
Greg T Avatar answered Nov 26 '25 08:11

Greg T



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!