Is APNs device token sent to iOS?

Hi,

When a push notification is received from APNs to iOS within the iPhone, how does iOS know which app to provide the notification payload to?

Is device token also handed over by the APNs to the iOS, and used by iOS to know the right app to which the notification payload belongs?

Apple developer information reg. Push Notifications only indicate that that Device token is included by the app server in its request to APNs, and is used by the APNs to identify the correct device to forward the notification to. It does not mention if the APNs also forwards the device token to iOS, and is used by iOS to identify the target app.

https://developer.apple.com/documentation/usernotifications/registering_your_app_with_apns

Thanks in advance! /Isaac

Replies

When a push notification is received from APNs to iOS within the iPhone, how does iOS know which app to provide the notification payload to?

iOS knows which app, by the apns-topic value; either explicitly defined in the push request, or implicitly through the certificate your push server uses when it connects to APNs. The push server must be authorized to send a push to that app either by a certificate, or an authorization (JWT) token which must be generated by the same developer team which created the app.

  • Thank you for the response @Gualtier Malde. Does this mean that Device Token is not sent to the iOS device by APNs? Apple mentions in its documentation that Device token identifies the exact device - app combination for which the notification is intended. In that case, does only APNs use device token to identify the device, and hands over the notification to the device. And iOS determines the app not from the device token but the apns-topic?

  • @Gualtier Malde can you please answer the above query. Thanks in advance!

  • @Gualtier Malde Can you please confirm if the device token is sent to the phone together with the notification payload?

Add a Comment

Yes, the device Token is sent to the device. Is it passed to your app after the app registers for push notifications by calling UIApplication.registerForRemoteNotifications. The OS will call back into your app passing the device token as the second parameter to the callback application(_:didRegisterForRemoteNotificationsWithDeviceToken:).

https://developer.apple.com/documentation/uikit/uiapplicationdelegate/1622958-application https://developer.apple.com/documentation/usernotifications/registering_your_app_with_apns

  • Thank you @provbar. These Apple references talk about the device token being sent to the device when an app registers for Push notification. The app in the device can then send the device token to server, which uses it subsequently to send a Push message to the device using APNs.

    My question however is: whether the device token is sent to the device when the server sends the push notification, so that iOS can identify which application to forward the incoming PUSH message to?

Add a Comment