Ahmad Vatani
Ahmad Vatani

Reputation: 1670

How open Url after Firebase message received in background

When application is in background and Firebase message received I want to open specific url that is in message data. For example i put below key-value in Firebase and i want to open google site after user tap on notification.

key: url
value: http://google.com

what should i do? tnx in advance!

Upvotes: 6

Views: 3876

Answers (1)

Diego Giorgini
Diego Giorgini

Reputation: 12717

In your application you can access the key/value pairs sent from Advanced options > Custom data in the Firebase Notification Web console in these ways:

  • getIntent().getExtras() in the activity that is launched when the user tap the notification.
    I recommend to add this in the activity onResume() method.
  • remoteMessage.getData() in FirebaseMessagingService.onMessageReceived() if the application is already open when the message arrives. (in this case the notification is not shown and instead the onMessageReceived() is invoked.

Upvotes: 3

Related Questions