-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Ionic 2 Native Push lacks Support for Actions #868
Comments
Since phonegap/phonegap-plugin-push#1378 has been merged I think it can be done easily. Please have a look at last few comments on this discussion on Ionic forum. |
@naveedahmed1 not sure what is there to add. Looks like you just have to send additional data in the payload to display those action buttons. |
@ihadeed I think it's referring to this comment: https://github.com/driftyco/ionic-native/blob/master/src/plugins/push.ts#L47 If you use the |
@ihadeed yes I know for actions we need to send additional data in the payload when sending notification from server, but I am referring to the click handlers for those action buttons. |
Sure I can modify the interface to add the additional data. For now you can override the type by adding As for the callbacks, there's nothing I can do to help you here. The plugin can't access your Ionic 2 code externally. You need to port your callback function to a global variable. For example: window['myCallback'] = () => console.log('User pressed the action button'); then you set the callback to |
@ihadeed can you please reopen and review it again, its seem its still not properly supported. It would be really great if we could register the callback function through push object. For example
|
The plugin expects something like this: { "icon": "snooze", "title": "SNOOZE", "callback": "app.snooze", "foreground": false} The callback is just the name of the function and not the actual callback function. Meaning it should be something like |
What about this:
On clicking EMAIL GUEST button I want to take user to the EmailGuestPage
But if I add it to the callback like this
Clicking EMAIL GUESTS button on notification throws error "Cannot read property 'push' of undefined" Probably this.nav.push is undefined. |
Seems this was inaccessible, I added
And it start working |
You need to use an arrow function instead of a regular function. |
Thanks, I have updated it to:
|
How to do the above code by using typescript in ionic..? |
@naveedahmed1 I'm trying to do exactly what you did. I followed your suggestion, using the let that=this and the arrow function as well. But I still have the error "Cannot read property push of undefined". I'm kind of new to ionic. Can you give me some help, please?
|
@rebearteta remove the
|
From @naveedahmed1 on December 10, 2016 1:44
Hi,
It seems that the current version of push plugin in Ionic Native lacks the support of Actions in push notifications.
I am referring to:
https://github.com/phonegap/phonegap-plugin-push/blob/master/docs/PAYLOAD.md#action-buttons
The action buttons set from server appear perfectly with notification. But when clicked they throw error in console:
Uncaught TypeError: Cannot read property 'Reply' of undefined
(Reply is the function that I want to be called when Reply button is clicked)
The documentation of the plugin suggests that while sending push notification with action buttons we should provide the callback (like they have used in app.emailGuests in the example code).
If there is a way to handle in current version, can anyone please guide how?
If not can it be added?
Copied from original issue: ionic-team/ionic-framework#9579
The text was updated successfully, but these errors were encountered: