How to Determine Invalid Token Status in Notification Hub Client Responses?

Rayanne 0 Reputation points
2024-07-10T19:12:28.57+00:00

Hi everyone,

I'm working with Azure Notification Hubs and I'm trying to verify the validity of device tokens after sending notifications using SendFcmV1NativeNotificationAsync and SendAppleNativeNotificationAsync.

Based on some forum discussions, it seems that the NotificationOutcome.Results[].Outcome object contains a status code that indicates the result of each send operation. Specifically, a status code of 8 supposedly identifies an invalid token. However, I couldn't find this information in the official Microsoft documentation.

Can anyone confirm if the Outcome status code 8 indeed signifies an invalid token? Additionally, are there other status codes we should be aware of for handling invalid tokens effectively?

Thank you in advance for your help!

Best regards,

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
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Thomas Smith 0 Reputation points
    2024-07-11T08:43:50.8166667+00:00

    Hello,
    Let’s dive into the details regarding the outcome status codes in Azure Notification Hubs.

    Outcome Status Code 8:

    You’re correct that a status code of 8 in the NotificationOutcome.Results[].Outcome indicates an invalid token.

    Specifically, it means that the notification was received by the corresponding push notification service (e.g., APNS for iOS), but the service does not provide further information about what happens to the accepted notification.

    Essentially, the token itself is valid, but there might be issues beyond the initial acceptance (e.g., the app might be uninstalled, the device might be inactive, etc.).

    Other Status Codes:

    While status code 8 is relevant for invalid tokens, there are other outcome status codes you should be aware of:

    0: The notification was successfully delivered to the push notification service.

    1: The notification was dropped due to an error (e.g., invalid payload, incorrect format).

    2: The notification was throttled (rate-limited) by the push notification service.

    3: The notification was expired (not delivered within the time window).

    4: The notification was accepted by the push notification service, but its final delivery status is unknown (no further details).

    5: The notification was dropped due to exceeding the maximum payload size.

    6: The notification was dropped due to exceeding the maximum number of tags.

    7: The notification was dropped due to exceeding the maximum number of registrations.

    8: The notification was accepted by the push notification service, but its final delivery status is unknown (similar to status code 4).

    Handling Invalid Tokens:

    When dealing with invalid tokens, consider the following:

    Regularly clean up invalid tokens from your registration database.

    Implement token validation on your server to identify and remove invalid tokens.

    Monitor the outcome status codes to proactively handle issues.
    https://stackoverflow.com/questions/41941244/does-azure-notificationoutcomestate-completed-mean-the-notification-was-receivedhealthinsurancemarket
    Hope this work for you.
    Best regards,
    Thomas Smith

    0 comments No comments