1

I'm testing notifications in XCode 12.2. It is very easy to test alert style notifications. You just drag them onto your app in simulator and the payload shows up in:

func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable: Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) { notificationsDispatcher.process(userInfo) completionHandler(.newData) }

Now, when testing silent notifications I can get the silent notification to fire after setting "Background fetch" in background modes. I then get into:

func application(_ application: UIApplication, performFetchWithCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
    debugPrint("hello silence ")
}

This is fine if i want the app to do something unrelated to the data in the payload. How do I see the actual apns payload data?

I'm trying to access this payload example that i'm using:

{
  "aps": {
    "category": "tasks",
    "content-available": 1,
    "thread-id": "tasks"
  },
  "resource": {
    "resourceType": null,
    "additionalProperties": {
      "taskIds": [
        "xxx"
      ],
      "classification": "xxx",
      "status": "xxx"
    }
  }
}

1 Answer 1

1

Simulating silent push notifications currently does not work if the content-available flag is set since it calls the wrong delegate method.

If you try with an actual device and send a real push notification, it should call the application(:didReceiveRemoteNotification:fetchCompletionHandler:) delegate and you can access the payload. There are also some forum posts about this, like https://developer.apple.com/forums/thread/652649.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.