Ahmad Alkhouly
Posts: 0
Joined: Wed Apr 09, 2014 12:39 pm

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

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

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

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

Hi Ahmad,

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

Ahmad Alkhouly
Posts: 0
Joined: Wed Apr 09, 2014 12:39 pm

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

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

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

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

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.

Ahmad Alkhouly
Posts: 0
Joined: Wed Apr 09, 2014 12:39 pm

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

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

Ahmad Alkhouly
Posts: 0
Joined: Wed Apr 09, 2014 12:39 pm

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

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

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

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

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.

Ahmad Alkhouly
Posts: 0
Joined: Wed Apr 09, 2014 12:39 pm

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

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.

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

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

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".

Return to “Issues”