Page 1 of 2

Notification User Click

Posted: Thu Mar 06, 2014 7:55 am
by Mahmoud Zeid

Hi,
I followed the steps in the tutorials to send a notification message, and I could send a notification to my device successfully, but still a small issue. I want to open the app on a page that displays the text of the notification when the user clicks the notification on the device. I tried the "Push Notification" event on the Start Screen and I added the following JS on the Handler:

alert (data.aps.alert);

However when I click the notification on my device, the app opens on the start screen but the notification message is not shown.

Please Advise


Notification User Click

Posted: Thu Mar 06, 2014 8:24 am
by Nikita

Hello,

Does the alert execute at all? Or just an empty message is seen?


Notification User Click

Posted: Thu Mar 06, 2014 2:37 pm
by Mahmoud Zeid

Thanks Nikita for your reply.

No the alert did not execute at all.


Notification User Click

Posted: Thu Mar 06, 2014 3:00 pm
by Nikita

Hi,

And at this moment is the application running or not?


Notification User Click

Posted: Thu Mar 06, 2014 3:02 pm
by Mahmoud Zeid

The application runs normally, the start screen opens, however the message is not executed


Notification User Click

Posted: Thu Mar 06, 2014 6:55 pm
by Maryna Brodina

Hello!
It's a bug. We have already fixed it on our test environment. I'll check if there is any workaround and let you know.


Notification User Click

Posted: Fri Mar 07, 2014 6:12 am
by Mahmoud Zeid

Thanks for you, I'm waiting for your reply


Notification User Click

Posted: Fri Mar 07, 2014 3:18 pm
by Maryna Brodina

Hello!

For Android in editor Sources - ANDROID - - com.phonegap.plugins.pushnotifications -PushNotifications.java replace 210-211 lines with the following preString jsStatement = "(function() { " + "var jsStatement = " + json.toString() + "; "
+ "PushNotification.notificationCallback(jsStatement); " + "}) ();";/preFor iOS #{application.name}/#{application.name}/CordovaLibPlugins/org.apache.cordova.plugins.PushNotification/PushNotification.m replace 89-93 lines with preif (error != nil){
jsStatement = [NSString stringWithFormat:@"PushNotification.notificationCallback({error: %@});",[error localizedDescription]];
}else{
jsStatement = [NSString stringWithFormat:@"PushNotification.notificationCallback(%@);", [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding]];
}/pre


Notification User Click

Posted: Mon Mar 10, 2014 6:23 am
by Mahmoud Zeid

Hi,

I tried the above solution, now the notification did not work at all (i.e I didn't receive any notification on the device)

Please Advise


Notification User Click

Posted: Mon Mar 10, 2014 6:50 pm
by Glenn Townsend

Hi, I have tried the code change (on Android only) by Maryna and found it worked great for me.