Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Check if app was launched from a notification or icon?

I am implementing FCM notifications and I have a notification coming from my backend which does not contain any data, just a title. This means that if my app is not running while this notification arrives, and the user opens this notification, my app will be launched with null extras and data in its intent.

Is there a way to differentiate this "empty notification" launch from the normal "user tapped the the app icon" launch of the app so I can take the user to the "notifications" section of the app when needed?

Both cases have null data and extras in their intent.

like image 245
Lucas P. Avatar asked Oct 26 '25 17:10

Lucas P.


1 Answers

  1. When you open app from notification with null data, intent.extras has some keys in image below intent.extras key
  1. When you open app from notification with data, check your key in intent.extras
  2. When you open app from launcher, intent.extras has no key
like image 104
Quan Dang Anh Avatar answered Oct 28 '25 08:10

Quan Dang Anh



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!