Search code examples
ios7ios8apple-push-notificationsapple-watch

Can I send an APN Alert Dictionary to both iOS 7 and iOS 8?


With iOS 8, there came the ability to send an the 'alert' key in the APN dictionary as either a string containing the alert text or a dictionary with the alert text in its 'body' key. See Apple docs. In iOS 7, the 'alert' key had to be a string containing the alert text.

My question is: If I want to take advantage of iOS 8 features in the 'alert' dictionary when sending remote notifications (specifically the 'title' key for the Apple Watch), will it continue to work with iOS 7? That is, is APNS aware that a device is running iOS 7 or 8 and send it the appropriate data? Or does my server have to know the device is running iOS 7 and send it a payload with an 'alert' string while sending devices running iOS 8 an 'alert' dictionary?

Does that make sense? Thanks!


Solution

  • It works. Tested with following payload on iOS 7.1.2:

    {
        "aps":{
            "alert": {
                "body": "alert body",
                "title": "alert title"
            },
            "sound": "default",
            "badge": 1
        }
    }
    

    (Btw. I don't see any notice about being iOS8-only in the doc.)