How to send a push notification to a specific device with Firebase and Capacitor

There is a helpful guide for sending push notifications with Capacitor and Firebase, but it only describes how to send global notifications to an app. Is there a way to get a device id with Capacitor, so that you can send a notification to that device with the Firebase Server SDK?

You need the device token provided by Capacitor’s Push Notifications plugin (following the guide you mentioned):

  // On succcess, we should be able to receive notifications
    (token: PushNotificationToken) => {
      alert('Push registration success, token: ' + token.value);

You can use that token value to target specific devices. To test notifications on a specific device head over to your Firebase project’s Cloud Messaging page, click on “Send your first message” if you haven’t already done so and click “Send test message”.

Enter the token value that was given to you before, and click on ‘Test’.


If everything was set up correctly, you will get a notification on your device. I have personally test notifications this way on Android and it works as expected. You could extend notifications functionality later on by implementing Cloud Functions based on specific events triggered in your database.


Is it possible to use this between users? user to user ?

Do you mean p2p, without need connect to server?

yes but maybe with if can with be server what I want is to send a notification when one user texts and the other is offline.

soryy, it’s hard for me to understand what you want. can you give much more information? do you provide text messaging service?

In my app there is a chat section like instagram so i want to notification send when user send message :smiley:
Zafer send message to Jhon
Jhon is offline so
Jhon recieve notification “there is a message from Zafer”

Read about push notification. You need to use push service like google firebase (FCM).

Hello @zaferkalyoncu53 did you find a way to do so. Can you please help me I am also stuck?

What is the problem?

@ghostriderus I was trying to implement chat notifications. As capacitor push-notifications don’t have a reply action in it so I was using this local notifications plugin. How can I achieve it? Means send local notifications from one device to another. Or is there any other method to do so. Thanks!

Load from server by app itself or use push service like firebase.

1 Like