Nothing happens after receiving notification in iOS

I have a application which has push notification functionality and i am receiving notification successfully in both android and ios using cordova-plugin-fcm.

this is my code where i receive notification.


                  //Notification was received on device tray and tapped by the user.
                  //Notification was received in foreground. Maybe the user needs to be notified.
                  alert("Notification received in foreground"); // this alert is generated
                  let alert1 = this.alertCtrl.create({      /// whereas this alert controller is not generated
                  title: 'You have got a new Notification.',
                  message: data.notificationDescription,
                  buttons: [
                      text: 'Ignore',
                      role: 'cancel',
                      handler: () => {
                        console.log('Cancel clicked');
                      text: 'View',
                      handler: () => {
              console.log('onNotification callback successfully registered: ' + msg);
              console.log('Error registering onNotification callback: ' + err);


As you can see i have created a function which handles notification data after receiving notification if user wants to view that particular notification.

    alert("inside handle notification");   /// this alert is not being generated so it means it doesn't come to this function
      alert("if data.isShowDetail is set");
    else if(data.isRedirect){
      else if(data.redirectScreen == 1){
        //Home Page
      else if(data.redirectScreen == 2) {
      alert("inside last condition");

What is the issue here or is there any other way to handle notification like the way i want?

Your post is quite confusing.
What is working?
What isn’t working?

I have written in comment that
alert("Notification received in foreground");
this alert is generated after notification received and when app is opened.
but after clicking ok that alert Controller is not being created to handle that notification.
And that way i can’t send notification data the notification handler function when user clicks View button from alert controller.

Also that function is not called when app is closed and when i open the application.

I have written comments where it’s necessary.

So your real problem is not that “nothing happens” as you stated in the title but that the alertCtrl you try to present doesn’t present. Everything else is unrelevant for now. Correct?

Replace the alert() with a console.log that doesn’t pause the program’s execution.
Check that all data for the alertCtrl is present.

What “that function”? onNotification? On which platform? Pushes received are handled differently depending on the OS you are testing on.

I was talking about this.handleNotification(data); function.
which is called from view button in alertController.

I have placed that function’s code in last.

If the alertController is not opened, noone can push the “view button” there and so the function can not be called. Right?

If you meant with the “app is in background when notification is received, nothing happens where I open it” then the handleNotification() is only called when data.wasTapped is true. Is it? Add a console.log to your code inside and before that if to debug.

PS: I would suggest you concentrate on one of these two issues (alertCtrl not working, background notification not handled when entering app) in this thread and opening a new one for the second issue - this is mighty confusing, especially if you don’t quote correctly what you are answering to.