Skip to content

Unable to send priority 10 due to validation check #172

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
MarmolDevApps opened this issue Feb 10, 2025 · 12 comments · Fixed by #173
Closed

Unable to send priority 10 due to validation check #172

MarmolDevApps opened this issue Feb 10, 2025 · 12 comments · Fixed by #173

Comments

@MarmolDevApps
Copy link

MarmolDevApps commented Feb 10, 2025

I'm unable to send priority 10 in the request because of the following validation on line 71 of notification/index.js file

if (this.priority !== 10) {
    headers['apns-priority'] = this.priority;
  }

This check prevents sending the priority when it is 10, as it only sets the apns-priority header when the priority is different from 10. However, the server accepts priority 10, and I need to find a way to send this value correctly.

I am implementing the new broadcast functionality and need to send updates with priority 10.

Thanks for the quick support.

Copy link

Thanks for opening this issue!

@dplewis
Copy link
Member

dplewis commented Feb 10, 2025

The default priority is 10 so no need to change it.

https://github.com/parse-community/node-apn/blob/master/doc/notification.markdown#notificationpriority

@MarmolDevApps
Copy link
Author

MarmolDevApps commented Feb 10, 2025

@dplewis Ok I will not send priority 10 but if you send it the request fails. In case you want to evaluate a correction in that validation. Close the issue

@dplewis
Copy link
Member

dplewis commented Feb 10, 2025

If the request fails then that’s an issue, looks like this check prevents the default from being passed too but I’m not sure

@cbaker6
Copy link

cbaker6 commented Feb 10, 2025

From the APN docs: https://developer.apple.com/documentation/usernotifications/sending-notification-requests-to-apns:

The priority of the notification. If you omit this header, APNs sets the notification priority to 10.

So the value of 10 will be set automatically, even if the check mentioned above doesn't set it.

@cbaker6
Copy link

cbaker6 commented Feb 10, 2025

Though the broadcast docs doesn't specify this default behavior, https://developer.apple.com/documentation/usernotifications/sending-broadcast-push-notification-requests-to-apns

So it's best to allow it to be set by the developer. @MarmolDevApps you may want to reopen the issue.

@MarmolDevApps MarmolDevApps reopened this Feb 10, 2025
@MarmolDevApps
Copy link
Author

MarmolDevApps commented Feb 10, 2025

If set priority 10 the request throw error 'BadPriority'. I'm reopening the issue in case you want to modify it. Thanks for the quick response.

@cbaker6
Copy link

cbaker6 commented Feb 10, 2025

If set priority 10 the request throw error 'BadPriority'. I'm reopening the issue in case you want to modify it.

Can you elaborate on this? Are you saying if 10 is sent, you receive the error above? Is this for broadcast notifications or standard notifications? For broadcast notifications this does not seem to be in-line with the documentation in #172 (comment), which states:

The priority of the notification. 

Specify 10 to send the notification immediately. 

Specify 5 to send the notification based on power considerations on the user’s device. 

Specify 1 to prioritize the device’s power considerations over all other factors for
 delivery, and prevent awakening the device.

In addition, the APN documentation shows an example of using a priority of 10.

@MarmolDevApps
Copy link
Author

If set priority 10 the request throw error 'BadPriority'. I'm reopening the issue in case you want to modify it.

Can you elaborate on this? Are you saying if 10 is sent, you receive the error above? Is this for broadcast notifications or standard notifications? Broadcast messages this seems to not be in-line with the documentation in #172 (comment), which states:

The priority of the notification.

Specify 10 to send the notification immediately.

Specify 5 to send the notification based on power considerations on the user’s device.

Specify 1 to prioritize the device’s power considerations over all other factors for
delivery, and prevent awakening the device.
In addition, the APN documentation shows an example of using a priority of 10.

Sorry, I'll go into more detail. Exactly, at least in broadcast sending the apns-priority header is mandatory but when building the headers in a notification in the priority part if something other than 10 is sent the apns-priority header is set but if it is 10 it is not sent and the error is executed.

Therefore, whether we set it or not from our side, if it is 10 it throws an error, at least the broadcast method. (By default you have 10 in the notification and it does not enter the validation and does not set the header).

on line 71 of notification/index.js

if (this.priority !== 10) {
    headers['apns-priority'] = this.priority;
  }

@cbaker6
Copy link

cbaker6 commented Feb 11, 2025

Sorry, I'll go into more detail. Exactly, at least in broadcast sending the apns-priority header is mandatory but when building the headers in a notification in the priority part if something other than 10 is sent the apns-priority header is set but if it is 10 it is not sent and the error is executed.

I see, so #173 should resolve this issue

@parseplatformorg
Copy link

🎉 This change has been released in version 6.4.3

@MarmolDevApps
Copy link
Author

Thanks so much @cbaker6 ! It's working now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants