notnoop / java-apns

Java Apple Push Notification Service Provider
notnoop.github.com/java-apns
BSD 3-Clause "New" or "Revised" License
1.79k stars 656 forks source link

Custom fields not arriving #363

Open geophile opened 5 years ago

geophile commented 5 years ago

I am using PayloadBuilder to create a notification, and everything works:

        PayloadBuilder builder = APNS.newPayload().alertTitle(title)
        push(deviceToken, builder.build());

I recently added custom fields:

        builder.customFields(customFields);

The notification arrives on my iPhone without the custom fields, which is not what I expected.

To debug, I printed builder.build() output on the sending side. Here it is, formatted and sanitized:

{"fooId":"6b76a0ae-edd3-4b83-8e0f-48c2501ea31f",
 "aps":{
     "alert":{"title":"TITLE","body":"BODY"}}}

Here is what is received by App.handleNotification (aps is the dictionary received by handleNotification)::

aps = {Swift.Dictionary<Swift.String, AnyObject>} 1 key/value pair
 [0] = "alert" -> 2 key/value pairs
  key = {Swift.String} "alert"
  object = {__NSDictionaryI * | 0x280e05dc0} 2 key/value pairs
   [0] = "title" -> "TITLE"
   [1] = "body" -> "BODY"

The custom field is missing. What am I doing wrong? Or si this a bug?