"cordova-plugin-firebase" this is the plugin that you need to install .
https://firebase.google.com/docs/android/setup
in firebase you need to create separate apps for both ios and android
you can use above code in a controller or a service .
if you want to send notifications to a specific user then you need to keep this firebase token in backend or api
if you are going to send broadcast messages then no need to keep this tokens