How to get access to custom field in apple push notification?

You must Login before you can answer or comment on any questions.

Hello, friends,

Generally push notification contains 3 standart properties: alert, badge and sound. I need to transfer some application data, which should not be shown as alert. For this purpose push notification has ability to create custom fields/properties in notification body.

Our server sends next message to apple push notification service: {acme = aszcxz, aps ={alert = hi}}

Application written using native objective c language receives this notification with custom message successfully.

However, titanium version does not receive any custom field: 1. If application is closed only alert with 'hi' text is shown. 2. Body of event callback looks like: {data={alert=hi;};source=[object NetworkModule]; type=remote;}.

Is there any way to deal with custom property of push notification in titanium js code?

Thanks for your help, Jakovas.

1 Answer

You should look into Urban Airship....they let you send a million messages a month for free. They even give you the code to implement with Titanium.

Then, in their tool, you simply plug in your payload such as:

{"aps": {"badge": 1,"alert": "This is my special message!", "mycustomvar1": "123456","mycustomvar2": "some text", "myspecialtext": "This is the best!", "url": "http://www.mywebsite.com"}}

As long as the payload is under 256 bytes you are good to send whatever additional data to the device you want.

Your Answer

Think you can help? Login to answer this question!