0

My app receives FCM and fires local notifications, which open target activities. This works fine if the local notification is clicked when the app is not running.

But, if the local notification is clicked when my app is already running (foreground or background), I don't want to open the target activity but shows an AlertDialog first. So, the activities stack is not changed and the user can continue what he was doing before.

It seems the local notification must have an action, which opens activities. Is there anyway achieve what I wanted above?

jarly
  • 231
  • 1
  • 4
  • 16

1 Answers1

1

I think you have to stop sending push notification when you app is in foreground check if your app is in foreground or by following this link

check android application is in foreground or not?

check this in firebaseMessegingService class before sending PN and manage alert dialog appearance according that

Community
  • 1
  • 1
pkgrover
  • 305
  • 3
  • 9
  • I think this is a good way to go, OP should check before sending local notification if activity which should show alert is running, if so he should send an event or a broadcast or something to let the activity know that it should show alert. – dees91 Jan 03 '17 at 15:58