matthijs2704/vapor-apns

possible makeJSON problem - content-available = true ignore the rest of keys

gperdomor opened this issue · 2 comments

I need to set payload.contentAvailable = true but doing that, the other keys (like title, body, etc) are ignored, it's a bug or exists a logical reason to do that, in my case I need all keys...

Your code, indented:
screen shot 2017-01-06 at 10 47 17 am

Hey there!

Yeah there is a logical reason for doing it this way: content-available push should only be used as a silent push! Using it in combination with an alert and title is an error. (Also see https://forums.developer.apple.com/thread/31296 and https://developer.apple.com/library/content/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/CreatingtheNotificationPayload.html)

The content-available flag should, according to Apple, ONLY be used with silent notifications. And I even think you don't need the content-available flag in a notification to trigger a data refresh,just implement didReceiveRemoteNotification and you can refresh the data without the content-available flag with a non-silent notification as this is called for every remote notification. The content-available flag is only used to make a notification trigger that method without showing an alert.

Hope this makes it more clear for you!

Although this is not the recommended method, you can force add a content-available flag manually by setting the extra property of the payload to ["content-available": true], but again this is not needed at all and is considered to be an error :)