In the WWDC 2013's "What's New with Multitasking" presentation, there is a section about Silent Push Notifications. It seems straight forward. According to the presentation, if you send the APS payload with just the content-available set to 1, users will not be notified of the notification.
// A. This doesn't work { aps: { content-available: 1 } }
My testing shows that this does not work as no push is received. But if I include the sound attribute but exclude the alert attribute, it works (though not silent anymore).
// B. This works { aps: { content-available: 1, sound: "default" } }
However, if I change the sound attribute to play a silent audio, I can mimic a silent push.
// C. This works too. { aps: { content-available: 1, sound: "silence.wav" } }
Does anyone know:
Thanks in advance.
Edit with more information
For A, the state of the application does not matter. Notification is never received.
It seems like B and C only work if you enclose the attributes and values in quotes, like below.
{"aps":{"content-available": 1, "sound":"silent.wav"}}
And the notification arrives in application:didReceiveRemoteNotification:fetchCompletionHandler: regardless of state.
You can fix an iPhone that's not getting notifications by restarting it or making sure notifications are turned on. You should also make sure your iPhone is connected to the internet so apps can receive notifications. If all else fails, you should try resetting the iPhone — just make sure to back it up first.
To send a Silent Push Notification to your mobile app, check the checkbox Silent Push in the iOS and Android push settings of the Send Push form.
This works also and does not play a sound when it arrives:
{ aps = { "content-available" : 1, sound : "" }; }
EDIT
People having this problem may want to check out this link. I have been participating in a thread on Apple's Developer forum that goes over all app states and when silent pushes are received and not received.
So I just came across this issue yesterday, and after trying sending a payload with a sound set to an empty string, it was still causing vibration/sound on the device. Eventually, I stumbled on a blog post from Urban Airship that suggested needing to send:
{ priority: 5 }
in the push notification, which I had never seen. After perusing Apple's docs for push notifications, I stumbled on this page:
https://developer.apple.com/library/content/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/CommunicatingwithAPNs.html
Which indicates that priority should be set as "5" or "10", and explains:
The notification’s priority. Provide one of the following values:
10 The push message is sent immediately.
The push notification must trigger an alert, sound, or badge on the device. It is an error to use this priority for a push that contains only the content-available key.
5 The push message is sent at a time that conserves power on the device receiving it.
Ultimately, we were able to get silent push notifications working with a badge count (and I suspect you could even do the same with an alert) with the following format:
aps = { badge = 7; "content-available" = 1; priority = 5; };
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With