0

I was able to make the FCM work in my test application from this link: Firebase Cloud Messaging with Ionic app

I am able to receive the message whether my app is open or closed. I was wondering if there is a way to just receive the message if my app is open on a specific UI (based from UI-sref). Is this possible?

Community
  • 1
  • 1
leo c
  • 663
  • 3
  • 8
  • 19
  • means you want to display notification on different possition – android_jain Feb 16 '17 at 11:10
  • actually, i was thinking of using this message to trigger an http request to my server. i really don't want to do the http call if the user is not in the specific ui because there is no use to update the data if the user is not in the UI. – leo c Feb 16 '17 at 11:12

1 Answers1

0

In short, yes. However, not from the console, only with data notifications:

  • If you use "Notification" notifications, like the ones you send from the web console, you do not handle these yourself (the OS displays them), so in that case, no.
  • However, if you use an http client to send "data" notifications, you receive these in your app's FirebaseMessagingService. In here, you can check which activity you are in (in however way you like), and then decide what to do with the notification.

To clarify, you can send both types of notification with an http client as long as you include both objects in the request you post: { "notification":{...} "data":{ ...}, "to": "/topics/your_topic" }

Saik Caskey
  • 500
  • 4
  • 18