Notification Hubs: There is an error "Notification payload is too large" error occurs when sending a test push notification

Yevhen Volynets 0 Reputation points
2023-10-13T12:38:24.1866667+00:00

When I try to send test push notifications to Apple devices, I got an error "Failed to send test message. Notification payload is too large. Actual length 6138 and MAX ALLOWED 4096". I'm using test payload provided by Azure:
{"aps":{"alert":"Notification Hub test notification"}}

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

1 answer

Sort by: Most helpful
  1. Grmacjon-MSFT 16,771 Reputation points
    2023-10-18T07:08:11.2733333+00:00

    Hello @Yevhen Volynets , thanks for the question.

    The error message you’re seeing is due to the size of the notification payload exceeding the maximum limit allowed by the Apple Push Notification service (APNs). The maximum payload size for APNs is 4096 bytes

    The payload you’re using {"aps":{"alert":"Notification Hub test notification"}} seems to be well within the limit. However, the error message indicates that the actual length of your payload is 6138 bytes, which exceeds the limit.

    To fix this, you need to reduce your actual notification payload size to be less than 4096 bytes. Here are some tips:

    1. Check your payload: Ensure that there are no additional data being added to your payload inadvertently which might be causing it to exceed the size limit
    2. Reduce the size of your payload: If your payload does indeed exceed the limit, you’ll need to reduce its size. This might involve removing unnecessary data or optimizing the structure of your payload

    Remember, it’s important that your payload is correctly formatted for APNs. For example, your payload should be in this format: {"aps": {"alert": "Your Message"}}

    Hope that helps.

    -Grace