Skip to content

Handling click event on notification in iOS #712

@coolvasanth

Description

@coolvasanth

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 app is in foreground.

My platform details:
Cordova CLI: 7.0.1
Ionic Framework Version: 2.3.0
Ionic CLI Version: 2.2.2
Ionic App Lib Version: 2.2.1
Ionic App Scripts Version: 1.2.2
ios-deploy version: 1.9.1
ios-sim version: 5.0.13
OS: macOS Sierra
Node Version: v7.7.4
Xcode version: Xcode 8.3.3 Build version 8E3004b

client side code:

`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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions