Search code examples
iphonepush-notificationios-simulatorosx-mavericks

Push Notifications in Mavericks iOS Simulator


I can't find anything about this, and I have never done anything with push notifications (but I know vaguely how they work). In Mavericks, now that OS X can receive push notifications from various things like websites, can iPhone Simulator receive push notifications? I've found plenty of answers from mid-2013 and earlier saying "no", but all of them are outdated because Mavericks was just recently released with its new push features.

I'm about to start working on an app for a school project that should use push notifications unless I want to be cheap and just poll the server. I understand that you NEED an iOS developer account to use push notifications, but it would make my life a lot easier if I could test on my computer.


Solution

  • Yeahhh!! With the release of XCode 11.4, Now it is possible to receive Push notification in Simulator too. Apple's latest release says,

    Simulator supports simulating remote push notifications, including background content fetch notifications.

    In Simulator, drag and drop an APNs file onto the target simulator. The file must be a JSON file with a valid Apple Push Notification Service payload, including the “aps” key.

    It must also contain a top-level “Simulator Target Bundle” with a string value matching the target application‘s bundle identifier.

    Reference Link: https://developer.apple.com/documentation/xcode_release_notes/xcode_11_4_beta_release_notes

    Example payload file,

    {
        "Simulator Target Bundle": "com.yourOrganization.appName",
        "aps": {
            "alert": "This is a test notification!",
            "badge": 5,
            "sound": "default"
        }
    }
    

    @note: mention your application's Bundle Identifier in "Simulator Target Bundle" in the above Payload.

    Dragging and dropping above json file onto the target simulator will present the notification and set the badge.