Expect invalid device token from Azure Notification Hub (APNS)

Mohamed Koumenji 20 Reputation points
2024-07-04T13:05:07.6833333+00:00

Hello,

I have a Node.js backend server, and I have registered iOS devices with device tokens into ANH. I want to know when I send a notification from my server to a user or multiple users through ANH (with tags), and one of the users has an invalid device token (expired or the user uninstalled the client app), what is the form of the API response body that Azure Notification Hub returns to me? because I want to know which device token exactly is invalid.

Thanks

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.
298 questions
{count} votes

Accepted answer
  1. ajkuma 24,661 Reputation points Microsoft Employee
    2024-07-11T11:45:21.9+00:00

    Mohamed Koumenji, Firstly, apologies for the delayed response.

    Based on my understanding of your issue. When you send a notification through Azure Notification Hub (ANH) and encounter an invalid device token, ANH will not return a response body that directly indicates which specific device token was invalid. Instead, you will receive a detailed error response that includes a tracking ID for the notification message. You can use this tracking ID to look up the notification outcome in the Azure portal, where you will find more information about the failure, including which device token was invalid.

    The typical response codes you might receive are:

    • 200: The notification was sent successfully.
    • 400: There was an invalid request body; the notification could not be sent because the request was malformed.
    • 401: There was an authorization failure; the access key was incorrect.
    • 404: The notification hub was not found.

    For more detailed information on handling errors and troubleshooting, you can refer to the Microsoft Learn documentation on managing notification hubs


    If the answer helped (pointed, you in the right direction) > please click Accept Answer Or please share the requested/more info to help you better.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful