How to implement push notification on Nativescript Angular 2


Hi !

I am trying to implement push notification on my app, I have already made the firebase app and I already have the permissions of push notification on the info.plist of my ios platform.

I have the next configuration, that I found it on the next link

var settings = {
// Android settings
senderID: ‘MY APP ID’, // Android: Required setting with the sender/project number
notificationCallbackAndroid: function(message) { // Android: Callback to invoke when a new push is received.

        // iOS settings 
        badge: true, // Enable setting badge through Push Notification 
        sound: true, // Enable playing a sound 
        alert: true, // Enable creating a alert 

        // Callback to invoke, when a push is received on iOS 
        notificationCallbackIOS: function(message) {
            console.log("Callback de notificacion ios ");
    var viewModel = new Observable.Observable({
        registrationId: ""
        // Success callback 
        function(token) {
            // if we're on android device we have the onMessageReceived function to subscribe 
            // for push notifications 
            if(pushPlugin.onMessageReceived) {

            alert('Device registered successfully : ' + token);
            viewModel.set("regId", token);
        // Error Callback 
            alert('Failed !!!!: ' + error);

When I run this on my device it return me this error:

Error Registerin … NSConcreteNotification 0x17044a770 {name = didFailToRegisterForRemoteNotificationsWithError; object = <Push: 0x17402ad60>; userInfo = {
message = " - falta la clave de autorizaci\U00f3n \U201caps-environment\U201d v\U00e1lida para la aplicaci\U00f3n";

Can anyone help me ?

Thanks a lot !


I was able to implement notifications with this plugin:
It was very straight forward. If you have the permissions already setup it will be very easy to implement the plugin


Thanks !

The problem is solved, but now i have a problem to send notifications to all devices, do you know how to send this ? I read that I have to create a topic but the plugin documentation do not say how, can you help me?

Thanks a lot !


I haven’t created any topics yet, I am sending the notification directly to
apps (default settings). Sorry, someone else here might be able to help you


Topics not implemented in firebase plugin for now


@allberto @lukashlobil i put PR for android part Firebase for topics, tested and they works i have it in my fork of firebase plugin :slight_smile: But dont know if Eddy will accept changes :smiley:


Cool !!

I hope he accept, do you tested it on ios or it is only for android?

You raffle!


@allberto only android as i never done plugin for for ios i dont know how to do ios side in js for now :smiley: but if someone take android side he will figure out ios pretty easily i think :slight_smile:


Thanks !

You have motivated me :smiley: I still having a lot of doubts but when I read more I get more involved on this.


@allberto @lukashlobil eddy will do soon ios side and android will be merged only that I will do docs for it :slight_smile: :wink:


yeeeaaahhh !!! the pull is available ! thank you so much markosko. This solves a lot of work.

Markosko rules !


@allberto dont forget to thanks to Eddy too as he did ios part too but probably he didnt bump version at npm so until then u need to manually change sources


Of course, thanks again.
Copying the sources I note that on the index.ts is missing the unregisterForPushNotifications is it only on my copy or in your´s too.



I did only topics not unregister @allberto so probably eddy done that part


hi, have you successfully implemented push on iOS with just this plugin? I’m having the worst time. Do we also have to use the push notification plugin to actually manage the notification? What a nightmare, every single time I try to make push work :smiley:


The nightmare was the administrative stuff with apple ID, plist and such. I have only used the firebase plugin alone and successfully handled the notification in code (just displaying the message and navigating elsewhere). I have yet to figure out why the notification is not displayed when the application is not active


Could you share your code? And does the notification appear as a true push, or are you using something like ‘alert’ to show the message coming in from the Firebase console? That’s where I’m having issues…for me, this doesn’t appear as a true push that appears in both foreground and background.


Hi @lukashlobil, for the background mode you need to add this on your info.plist.


@jen.looper you only need firebase plugin, first you have to get the IOS certificates and firebase info.plist to the project then you need to init firebase and subscribe to the notifications. With this and the background mode you get the dialogs on the device.

(instance) => {
console.log(“firebase.init done”);
(error) => {
console.log("firebase.init error: " + error);
firebase.addOnPushTokenReceivedCallback( (token) => {
console.log("Firebase push token: " + token);
firebase.addOnMessageReceivedCallback( (message) => {

The most important thing is to create the apple certificates and enable this on the info.plist it is really easy to do, opening on xcode the projecto and in capabilities you have to enable push notification, if there an error with your certificate, xcode give you this error.


yep, done all those things, it’s super annoying not to receive my pushes! I’ll keep trying.


Are you testing on a device ? maybe if you try reinstalling firebase and remove the platform :smiley: