iOS Push Notification custom format

You can add Title, Subtitle, body and many other keys as

{
  "aps": {
    "alert": {
      "title": "Hey!🙂 Checkout my custom notification",
      "subtitle": "Custom notification subtitle",
      "body": "Description of custom notification"
    },
    "sound": "default",
    "category": "CustomPush",
    "badge": 1,
    "mutable-content": 1
  },
  "Employee": {
    "Name": "John Doe",
    "Designation": "Manager"
  }
} 

Where Employee is custom payload where you can set your own data as required


You are not allowed to put custom tags inside aps tag. Here's what documentations says about it:

Providers can specify custom payload values outside the Apple-reserved aps namespace. Custom values must use the JSON structured and primitive types: dictionary (object), array, string, number, and Boolean.

So in your case you should do something like:

{
    "aps": {
        "alert": "Hello World",
        "sound": "default"
    },
    "Person": {
        "Address": "this is a test address",
        "Name": "First Name",
        "Number": "023232323233"
    }
}

Therefore you can read your custom payload with looking for it's key in main JSON, rather than in "aps":

NSLog(@"%@",notification['Person']['Address']);

Above will output:

this is a test address

You could find more about custom payloads, along with some examples in Apple docs.

Regards, HrisTo