tsif / pu.sh

A bash script to send iOS push notifications with the Apple Push Notification service (APNs)
MIT License
180 stars 18 forks source link

`apns-priority` and `apns-push-type` needed for remote notifications #2

Open kejadlen opened 4 years ago

kejadlen commented 4 years ago

Thanks for this script - it was very helpful for doing development, but we found that for sending content-available pushes, the following headers needed to be set:

apns-priority: 5
apns-push-type: background

Apple documentation:

header description
apns-push-type (Required for watchOS 6 and later; recommended for macOS, iOS, tvOS, and iPadOS) The value of this header must accurately reflect the contents of your notification’s payload. If there is a mismatch, or if the header is missing on required systems, APNs may return an error, delay the delivery of the notification, or drop it altogether.
apns-priority The priority of the notification. If you omit this header, APNs sets the notification priority to 10. Specify 10 to send the notification immediately. A value of 10 is appropriate for notifications that trigger an alert, play a sound, or badge the app’s icon. Specifying this priority for a notification that has a payload containing the content-available key causes an error. Specify 5 to send the notification based on power considerations on the user’s device. Use this priority for notifications that have a payload that includes the content-available key. Notifications with this priority might be grouped and delivered in bursts to the user’s device. They may also be throttled, and in some cases not delivered.  

I don't know if you want to handle this in the script or just add it as documentation for the README.

tsif commented 3 years ago

Hi @kejadlen thanks for this (and sorry for taking forever to reply 🙂)

If you create a PR placing it in the readme file I'll be happy to merge it in!