Kevin McGuire
Posts: 0
Joined: Mon May 12, 2014 2:20 am

I have push notifications working, now how do I handle them in the app? Can the user view the push message and clear th

I followed push notifications tutorial and have it working but how do I handle these notifications with the app? I just want to add something simple where the user can view the push notification and then the badge clears. I'm a newbie so I need a step by step. :)

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

I have push notifications working, now how do I handle them in the app? Can the user view the push message and clear th

Hi Kevin,

On 'Push notification' event the message is available in a variable data.aps.alert.

Here is an example of clearing badge: https://getsatisfaction.com/apperyio/...

Kevin McGuire
Posts: 0
Joined: Mon May 12, 2014 2:20 am

I have push notifications working, now how do I handle them in the app? Can the user view the push message and clear th

Hi Katya,

I placed the following on Device Ready Event:

var pushNotification = window.plugins.pushNotification;
pushNotification.setApplicationIconBadgeNumber(successHandler, 0);

Nothing happens, it does not clear the badge. I tried to follow the multiple links in other threads but the only other code I tried kept removing the device from the push database when the app closed. That cleared the badge but I couldn't receive any push message.

Kevin

Evgene Karachevtsev
Posts: 12
Joined: Mon Apr 28, 2014 1:12 pm

I have push notifications working, now how do I handle them in the app? Can the user view the push message and clear th

Hello Kevin,

Apparently this bug will be fixed in the next release. Now, as a workaround you can change your library version to v1.2
http://docs.appery.io/documentation/a...

Kevin McGuire
Posts: 0
Joined: Mon May 12, 2014 2:20 am

I have push notifications working, now how do I handle them in the app? Can the user view the push message and clear th

My library version is currently set to v1.2 so I don't think that is the problem.

Kevin McGuire
Posts: 0
Joined: Mon May 12, 2014 2:20 am

I have push notifications working, now how do I handle them in the app? Can the user view the push message and clear th

Uh, no...As I said, I'm a newbie so step by step would be best. I have no idea how to define that as an empty function. Where can I get help with that? I have everything working.... I just want to be able to view the push notification in the app and clear the badge.

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

I have push notifications working, now how do I handle them in the app? Can the user view the push message and clear th

Hi Kevin,

Add this code before:
prevar successHandler = function(){
//your code here
}/pre

Kevin McGuire
Posts: 0
Joined: Mon May 12, 2014 2:20 am

I have push notifications working, now how do I handle them in the app? Can the user view the push message and clear th

Thank you for helping. When I put the following code in, not only will it not clear a previous badge but it will not receive any push notifications.

var successHandler = function(){
var pushNotification = window.plugins.pushNotification;
pushNotification.setApplicationIconBadgeNumber(successHandler, 0);
};

On the Appery.io push side the push notification attempt results in an error:

Description: An error response packet was received from the APNS server: APNS: [1] Invalid token
Devices count: 1

Any further suggestions?

Thanks!

Kevin

Evgene Karachevtsev
Posts: 12
Joined: Mon Apr 28, 2014 1:12 pm

I have push notifications working, now how do I handle them in the app? Can the user view the push message and clear th

Hello Kevin,

Let's try using this code:

codevar successHandler = function(){
//just empty
};
var pushNotification = window.plugins.pushNotification;
pushNotification.setApplicationIconBadgeNumber(successHandler, 0); /code

Return to “Issues”