I cannot send custom data to iOS and need to, but cannot identify the root problem.

I am attempting to implement push notifications with custom data in my application. I am using pushwoosh and corona SDK. Python in powering my server to send rest/POST requests to pushwoosh.

I am currently unable to receive custom data and I cannot determine precisely why. I have posted to coronaSDK forums regarding this issue after spending many hours on Google.

Forum post with additional details: http://forums.coronalabs.com/topic/48026-unable-to-send-custom-data-to-ios-2014/

I am able to receive normal "alerts" via push notifications. I am fairly sure I have all certificates setup correctly.

The python JSON blob to build and send to pushwoosh.

    data = {
    "request":{
        "application":app_code,
        # "applications_group":"GROUP_CODE",
        "auth":api_access_token,
        "notifications":[{
            "send_date":"now",
            "content":msg,
            "ios_root_params":{
                "extra":{"motherfoo":"bar"},
                "aps":{
                    "content-available": "1"
                }                    
            },
            "data":{                     
                # // JSON string or JSON object, will be passed as "u" parameter in the payload
                "custom": {"foo":True, "what":"lol"},
                "extra": {"foo2extra":True, "what":"lol"}
            },  
            "custom": {"topfoo":True},              
            "platforms": [1],
            "devices":[
                device_token
            ],
        }]
    }
}
asked 21 May '14, 01:02
osconfused's gravatar image

osconfused
74

You should put "custom" key to "aps" dictionary, like this:

 {
"request": {
    "auth": "your api key",
    "application": "your app id",
    "notifications": [
        {
            "send_date": "now",
            "ios_root_params": {
                "aps": {
                    "alert":"1111",
                    "custom" : {"asd" : "asd"}
                }
            }
        }
    ]
}
}

I just create sample project with your code and it's working:

May 21 16:07:37 Fectums-iPad Sample[1420] <warning>: onNotification() {"type":"remote","name":"notification","custom":{"asd":"asd"},"sound":"default","alert":"1111","applicationState":"active"} null

May 21 16:07:37 Fectums-iPad Sample[1420] <warning>: Custom data is table: 0x1467dd70 {"asd":"asd"}

permanent link
answered 21 May '14, 09:49
Fectum's gravatar image

Fectum
2604

edited 21 May '14, 10:04

This works! Thanks! Might be worth noting that this also works without having to next inside aps. This is also working for me: "ios_root_params":{ "custom": { "aboolean":False, "astring":"apstop", "anarray":[1,2,3,4,5], "aninteger":55, "afloat":550.556, "adict":{"foo":"bar"}, }, },

(21 May '14, 12:08) osconfused osconfused's gravatar image
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×446
×326
×141

question asked: 21 May '14, 01:02

question was seen: 1,828 times

last updated: 21 May '14, 12:09