How to identify whether IOS Push Mobile Device token is invalid or not

S, Selvaraj 31 Reputation points
2024-07-03T11:16:11.0233333+00:00

We're sending Push Notification based on the device token using the SendDirectNotificationAsync() function and we're able to see the bad channel or expired channel errors for IOS devices in Azure Notification Hub Data Metrics.

For Android push Mobile device token, we're getting the ExpiredChannel or BadChannel error from the GetNotificationOutcomeDetailsAsync() function, if the device token is invalid. Similarly for IOS, is there any way to identify the token is invalid?

Azure Notification Hubs
Azure Notification Hubs
An Azure service that is used to send push notifications to all major platforms from the cloud or on-premises environments.
319 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Grmacjon-MSFT 17,886 Reputation points
    2024-07-04T05:24:52.92+00:00

    Hello @S, Selvaraj there isn't a direct equivalent in Azure Notification Hubs for iOS that provides the same level of detail about invalid device tokens as the GetNotificationOutcomeDetailsAsync function does for Android's ExpiredChannel or BadChannel errors. However, there are ways to identify potentially invalid iOS device tokens:

    1. Azure Notification Hub Data Metrics:

    APNS Status Codes:

    • While you won't see specific error messages like "ExpiredChannel" or "BadChannel," Azure Notification Hub data metrics offer insights through APNS Status Codes. Look for the following codes to understand potential token issues:
      • Status Code 8: Indicates an invalid device token.
      • Status Code 34: Suggests a problem with the device token format.
    • Delivery Failures: Monitor the "Delivery Failures" metric for iOS notifications. A significant increase in failures over a period might indicate a problem with a subset of device tokens.

    2. Client-Side Library Error Handling: When using Azure Notification Hub client libraries for iOS, implement proper exception handling for push notification delivery attempts. Libraries might throw specific exceptions for invalid tokens, such as APNServerError with an underlying code of 8 (indicating an invalid token).

    3. App-Level Token Refresh: Consider implementing a mechanism within your iOS app to periodically refresh device tokens. This could involve requesting a new token from Apple Push Notification service (APNs) on app launch or at specific intervals. This helps ensure you have a valid token for future notifications.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.