Rahul Mishra
Rahul Mishra

Reputation: 4573

How to send test push notification with custom data from firebase console?

How do we send a test push notification to my android emulator with custom data? I have FCM Token and it should directly come up on my emulator only... I don't want to send a notification to all the app users.

Is there any way to do this from firebase cloud messageing so, I can test with my data.

Upvotes: 8

Views: 6350

Answers (1)

Hussam Kurd
Hussam Kurd

Reputation: 9186

Yes, Sure you can test it through printing the device token

  FCM.getFCMToken().then(token => {
   console.log(token)
  });

Then take the token and go to the cloud messaging section and you just set the FCM token in test message like the picture below:

enter image description here

Update

the new Firebase interface does not provides a direct way to test cloud messaging with data at the moment. However you have two options: either you create a certain subject and subscribe to it like the following code

  FCM.subscribeToTopic("/topics/testTopic");

and then in the target section you can target topic testTopic (This may require time to confirm a new subject)

Or you can do this programming using Firebase admin, you can follow this tutorial: https://medium.com/android-school/test-fcm-notification-with-postman-f91ba08aacc3

Hopefully this answer your question

Upvotes: 8

Related Questions