Page 1 of 1

IOS PushNotification attach extra one value using api. the store it in local variable.

Posted: Sun Jun 22, 2014 12:20 pm
by Ahmad Alkhouly

Hello,

please can you help me solve my issue; as explained below...

I need to attach nodeid (integer value) while sending push notification from my server to devices...

using this code: if its in right way.

curl -X POST -H "X-Appery-Push-API-Key:MY-API-KEY" -H "Content-Type: application/json" -d '{"payload":{"message" : "Message-body", "badge" : "2"},"status": "sent","node":"51553"}' https://api.appery.io/rest/push/msg

the push message is sent successfully and my ios apps can received it.

is that ok to transfer extra value with PushNotification API ?

SO

when user press over pushed message on his iphone;

i- it will open my app; if the app where closed.

OR

ii- show an alarm dialog box with the pushed notification message and "go" button, if apps were opened.

SO

at case (i) how to get the value of "nodeid" (the extra piece of information inserted into push code above), then store it into local storage variable. ?

also how to do same after press "go" button at case (ii)?

then in above 2 cases makes an event to navigate to page.

Thank you very much for help and regards


IOS PushNotification attach extra one value using api. the store it in local variable.

Posted: Mon Jun 23, 2014 7:27 am
by Kateryna Grynko

Hi Ahmad,

Unfortunately, you can't send any extra data this way.
If the app is not running you don't receive a notification.


IOS PushNotification attach extra one value using api. the store it in local variable.

Posted: Mon Jun 23, 2014 9:25 am
by Ahmad Alkhouly

are there a simple way to receive an extra data and store it into local variable or database ? using PunshNotification API.


IOS PushNotification attach extra one value using api. the store it in local variable.

Posted: Mon Jun 23, 2014 6:20 pm
by Evgene Karachevtsev

Hello Ahmad,

The plugin which is used to push messages in Appery.io allows you to allocate only message and badge (for IOS). You can either transfer all the data in the text message, or to connect another plugin to push that will be more suitable to your requirements.


IOS PushNotification attach extra one value using api. the store it in local variable.

Posted: Mon Jun 23, 2014 8:48 pm
by Ahmad Alkhouly

Thank you very much for help,
I get it, but seems to be hard to me


IOS PushNotification attach extra one value using api. the store it in local variable.

Posted: Tue Jun 24, 2014 9:40 am
by Ahmad Alkhouly

Thank you very much for help

Can I use check method like this below ?

pushNotification.getApplicationIconBadgeNumber( function(badgeNumber) {

Code: Select all

 // when open the app, looking if there are new badge, so  go to page 'BreakingNews' 

 if(badgeNumber  0) Appery.navigateTo('BreakingNews', {}); 

});

Iam testing this code but its not working (My Libraries version is 1.2), @ device ready event

is this code is wrong way?

Thank you very much and regards


IOS PushNotification attach extra one value using api. the store it in local variable.

Posted: Tue Jun 24, 2014 5:35 pm
by Evgene Karachevtsev

Hello Ahmad,

Here is the link to this plugin on github: https://github.com/mgcrea/cordova-pus...
It seems to be right. You only need to add

code// After device ready, create a local alias
var pushNotification = window.plugins.pushNotification;/code

at the beginning.


IOS PushNotification attach extra one value using api. the store it in local variable.

Posted: Thu Jun 26, 2014 9:29 am
by Ahmad Alkhouly

Thank you very much for help,

I found it already fully installed in my IOS "source" (Thanks for Appery Team)...

but for sorry, its only open the application (from background or start it if was closed)

when a new push notification received from apn server.

after open the application, do not do any actions related to "DeviceReady" Event.

regards.


IOS PushNotification attach extra one value using api. the store it in local variable.

Posted: Thu Jun 26, 2014 2:39 pm
by Evgene Karachevtsev

Hello Ahmad,

I meant that you need to initialize a variable pushNotification i.e. the code should be like this:

codevar pushNotification = window.plugins.pushNotification;
pushNotification.getApplicationIconbadgenumber( function(badgeNumber) {

// when open the app, looking if there are new badge, so go to page 'BreakingNews'

if(badgeNumber > 0) Appery.navigateTo('BreakingNews', {});
});/code

And since this event handler should be called each time you receive a notification, you need to use an event "Push notification".