pusher / push-notifications-swift

Swift SDK for the Pusher Beams product:
https://www.pusher.com/beams
MIT License
34 stars 24 forks source link

Cannot change `content-available` to 0/false #156

Closed LinusGeffarth closed 4 years ago

LinusGeffarth commented 4 years ago

I would like to change the value of content-available in the notification payload. When I try to do so by simply adding "content-available" => 0 inside the "aps" dict, right next to "alert" in my PHP backend, I get the following error:

Unprocessable Entity: apns.aps.content-available: apns.aps.content-available must be one of the following: 1

How can I set it to 0 / false?

jonathanlloyd commented 4 years ago

Hi! We currently keep this value at 1 because this is required by the mechanism we use for tracking notification delivery. What problem are you trying to solve by disabling it?

LinusGeffarth commented 4 years ago

Oh I see. I tried to solve an issue where notifications triggered the AppDelegate's method didReceiveRemoteNotification twice and a suggested fix was to set content-available: 1 in the notification payload.
I was able to fix the issue now by using the UserNotifications framework provided by Apple with its custom methods.

Although I don't need this anymore, it might still be worth keeping this issue open and considering to implement support for it. I saw that a few people had the same issue with Pusher Beams. For example, if I want to send my app a silent notification, then it seems, content-available must be 0.

jonathanlloyd commented 4 years ago

Hi @LinusGeffarth just thought I'd let you know that we've added support for this! It is now possible to disable delivery tracking for iOS via a custom flag https://pusher.com/docs/beams/concepts/insights#content-available This will prevent Beams from setting content-available to 1 on your behalf.

Thanks for the feedback!

LinusGeffarth commented 4 years ago

Awesome, thank you for that quick fix!