Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handling click event on notification in iOS #712

Open
coolvasanth opened this issue Sep 20, 2017 · 0 comments
Open

Handling click event on notification in iOS #712

coolvasanth opened this issue Sep 20, 2017 · 0 comments

Comments

@coolvasanth
Copy link

coolvasanth commented Sep 20, 2017

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant