Skip to content
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

Allow ability to explicitly set APNS priority #437

Merged
merged 5 commits into from
Feb 7, 2020

Conversation

McPo
Copy link
Contributor

@McPo McPo commented Nov 1, 2019

While APNS apparently defaults to high priority https://developer.apple.com/documentation/usernotifications/setting_up_a_remote_notification_server/sending_notification_requests_to_apns.

We have seen behaviour which may contradict this. As such we would like to be able to explicitly set the priority level.

notification.Priority = apns2.PriorityLow
} else if req.Priority == "high" {
notification.Priority = apns2.PriorityHigh
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why we need another condition req.Priority == "high"?

You can set any value or ignore the property if you want the priority to high.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry only seeing your comment now, I must have missed it.

You are correct in that you could get away without the second condition. However I just prefer to be explicit about such things. Im not a fan of having API's "assume" things, hence why Id like to be explicit with high priority in the first place.

For example If a dev was to mistakenly put "medium" priority into the request, it would come out as "high", this could be confusing. Ideally in this instance gorush would return an error. The 2nd best option is to not set the property at all (and rely on the implicit default of APS), The third, would be to fall through and set the priority as high. IMO.

This also has the advantage of being "backwards compatible", in that people who never passed an explicit priority wont now be explicitly passing "high" to APS.

Im happy to change it, if its gonna block the PR.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree totally

@codecov-io
Copy link

codecov-io commented Jan 13, 2020

Codecov Report

Merging #437 into master will decrease coverage by 2.13%.
The diff coverage is 44.08%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #437      +/-   ##
==========================================
- Coverage   82.95%   80.81%   -2.14%     
==========================================
  Files          20       20              
  Lines        1396     1423      +27     
==========================================
- Hits         1158     1150       -8     
- Misses        189      220      +31     
- Partials       49       53       +4
Impacted Files Coverage Δ
gorush/notification.go 100% <ø> (ø) ⬆️
gorush/notification_fcm.go 79.48% <0%> (-2.82%) ⬇️
rpc/server.go 0% <0%> (ø) ⬆️
config/config.go 94.04% <100%> (+0.07%) ⬆️
gorush/status.go 85% <100%> (ø) ⬆️
gorush/log.go 88.23% <30%> (-4.83%) ⬇️
gorush/server.go 77.41% <40%> (-7.59%) ⬇️
gorush/server_normal.go 71.64% <70.58%> (-6.41%) ⬇️
gorush/worker.go 85.48% <85.71%> (-1.41%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e5dd534...83a161c. Read the comment docs.

@appleboy appleboy merged commit dbc57cd into appleboy:master Feb 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants