Kirit Vaghela
Posts: 0
Joined: Tue Aug 27, 2013 11:23 am

Push notification, When?

Hello
I want to store codedata.aps.alert/code in localStorage whether the app is running or not.

When user click on notification than I want to open a page that fetch latest info using REST service. I'm sending some id as message and this id is passed to the sevice as request parameter.

Please help me.

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

Push notification, When?

Hi Kirit,

On Push Notification event, add Run JavaScript action with the following code:
codelocalStorage.setItem("pushData", data.aps.alert);/code
Then you can use localStorage "pushData" variable in Rest services mappings.

To make the app navigate to another page when a message is received, add Navigate To Page action.

Please note that if iOS app works in the Background, then on the Push Notification click app opens, but the actions aren't executed. It is a known bug. We're working on it. On Android everything works properly.

Daniel Kerr
Posts: 0
Joined: Wed Aug 21, 2013 1:31 pm

Push notification, When?

Hi Folks,

I just encountered this iOS bug with background notifications not executing when the app opens. Any chance of a workaround or update in general?

Thx.

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

Push notification, When?

Hello! It's going to be fixed in the next release (early November). This happens because push notification message is added to the pendingNotifications queue, when you launch application by tapping on notification message, when application is inactive. So this issue can be solved in two ways:
1) Manually add 'resume' event handler with next code:
prePushNotification.getPendingNotifications(function(status) {
var notifications = status.notifications;
for (var i = 0; i < notifications&#46;length; ++i) {
&#47;&#47; Notification handling - use handler defined by user when application is in active mode&#46;
&#47;&#47; User can define another behavior in this case&#46;
PushNotification&#46;notificationCallback(notifications);
}
});/pre
2) Add code specified in item 1 to the code generation module, like this:
predocument&#46;addEventListener("deviceready", function() {
$(document)&#46;unbind('pushregistrationfail pushregistrationsuccess push-notification resume ')&#46;bind({
&#47;&#47; &#46;&#46;&#46; other events
"resume": function() {
PushNotification&#46;getPendingNotifications(function(status) {
var notifications = status&#46;notifications;
for (var i = 0; i < notifications&#46;length; ++i) {
PushNotification&#46;notificationCallback(notifications);
}
})
},
});/pre

Corinne
Posts: 0
Joined: Thu Sep 19, 2013 2:43 pm

Push notification, When?

Android.
To receive push data on launch from gcm notification.
Push Notification events have to be in the start up screen though right?
Otherwise they are not captured if App is not running..?

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

Push notification, When?

Hello!
[quote:]Push Notification events have to be in the start up screen[/quote] No
To see that you can download source code for Eclipse project and check that.

Return to “Issues”