Handling click event on notification in iOS:Phonegap-Pushplugin

Expected behavior: Trigger an event after clicking on the notification.
Actual behavior:

pushObject.on('notification').subscribe((notification: any) => {

is getting triggered as soon as the notification arrives when the app is in the foreground.

Client side code is as below:

const options: PushOptions = {
ios: {
alert: 'true',
badge: true,
sound: 'false'
},

};

const pushObject: PushObject = this.push.init(options);

pushObject.on('notification').subscribe((notification: any) => console.log('Received a notification', notification));

pushObject.on('registration').subscribe((registration: any) => console.log('Device registered', registration));

pushObject.on('error').subscribe(error => console.error('Error with Push plugin', error));

Server side payload example:

{
    "aps": {
        "alert": "Testing.. (15)",
        "badge": 1,
        "sound": "default",
        "content-available": 1
    }
}

Explanation of problem: When the app is in foreground as soon as the notification is received

pushObject.on('notification').subscribe((notification: any) => {

The method is getting invoked. It is not waiting for the user to click the notification.In my app, I will navigate to a certain page depending on the payload data in the notification.

Now because of this immediate triggering of the function, though the user is in middle of some page he will be immediately redirected to some page after receiving notification.

I want user to click on the notification and only after that

pushObject.on('notification').subscribe((notification: any) => {

method should be triggered. Thanks in advance.