Testing ios push notifications with Xcode 11.4 - link in apns is not working

I'm trying to test push notifications in ios simulator with a new Xcode 11.4 feature.

My app has both NotificationService and NotificationContent extensions to change the message before showing it to the user.

To send a notification to the simulator I'm using terminal command:

xcrun simctl push <simulator_id> <app_bundle_id> push.apns

My push.apns is like this:

{ 
"Simulator Target Bundle": "app_bundle_id", 
 "aps": { 
   "category": "NewOrder", 
   "alert": { 
      "loc-key": "NOTIFICATION_KEY", 
      "loc-args": ["3"] 
    }, 
  "badge": 1, 
  "sound": "default", 
  "types": ["order.created"], 
  "storeId": "4616", 
  "mutable-content": 1, 
  "link": "my-app://orders/3", 
  "thread-id": "OrderThreadId" 
  } 
}

I see the notification on the screen, but it seems that the "link" attribute is not working. When I tab on a push, I expect to see, in this case, the screen of the third order, but I see the main screen of the app.

I'll be appreciated for any help with this. Thanks.

Replies

Why do you think the link attribute is not working? Inside your app you have to detect the push notification in the UNUserNotificationCenterDelegate willPresent, read the payload inside UNNotification, extract the link value (notification.request.content.userInfo["link"]) and act in consequence.