How to fetch FCM registration token from ionic app?


i want to send notification to specific device in my ionic app. For that i need FCM registration id to be fetched from device and send it to my server for further use. I cant find any help on this. its a major and essential task for any app i dont know why i cant get any help on this topic.


Hi @Belani,

i assume you are using $ionicPush to register the users device? If so, then you will receive the token from $ionicPush.register() and could send this to your server. Example:

$ionicPush.register().then(function (token) {
     // do something with your 'token' and also save the token with $ionicPush

This use case is a bit limited because every “device” would create a unique token and you would have to manage them properly.

If you are already using some authentication process, then you could connect it to $ionicAuth/$ionicUser. By using this method you could also define your own “identifiers” for user selection.

In my current project i am creating a Companion App for an already existing Web Application. So in this case it would be nice to identify the user (and their device/devices) the same way i am identifying them in my WebApp (f.e. by some email-id or UUID). Luckily, $ionicAuth does provide custom auth. So your mobile app can make use of ionic’s Auth and User services with your existing authentication process. See Custom Auth Documentation for more details. This way i was able to set an external_id for every user and with this external_id i can then send pushes.

Phew…that escalated quickly. Sorry for that wall of text. :slight_smile:


i tried it but didnt get anything. i think the register process will insert id in my apps.ionic project. i checked it but cant find anything. here are screenshots.