Ionic Push: onNotification doesn't fire when the notification is received

Hi all,
I succesfully implemented the ionic push notifications using the ionic push service and following the documentation.
At the moment I’m testing the application just on android.
The only problem that I found is that upon receiving a notification this appears in the android notifications drawer but in the application the “onNotification” event isn’t triggered.
The event is triggered just once the notification icon gets double tapped.

I really thought that the onNotification event would be triggered on the exact receive moment. Am I wrong?

This is the code of my register function:

         pushRegister: function () {
            console.log('Ionic Push: Registering user');

            // Register with the Ionic Push service.  All parameters are optional.
            $ionicPush.register({
                canShowAlert: true, //Can pushes show an alert on your screen?
                canSetBadge: true, //Can pushes update app icon badges?
                canPlaySound: true, //Can notifications play a sound?
                canRunActionsOnWake: true, //Can run actions outside the app,
                onNotification: function (notification) {
                    //alert(notification);
                    console.log("IN NOTIFICATION");
                    console.log(notification);
                   
                    return true;
                }
            });
        }
1 Like

I think that I understand everything better now.
When the app is in background the “onNotification” event won’t fire.
That is the expected and only possible behaviour.
My last problem is that I want to play a custom sound upon receiving a notification.
Can someone point me to a working example for the android platform?

1 Like