2

if I try to send a push notification silent (no badge/sound/alert) and just content-available, as per specs for silent notifications, on iOS 11, the notification is ignored and not forwarded to the app.

This is the notification

{
    "aps" : {
        "content-available" : 1,
    }, 
    "type" : "0"
}

The device log has:

<Error>: Ignoring notification with no alert, sound or badge (it.my.app.dev): C146-3838

And more complete:

Dec 27 10:11:30 iPierX SpringBoard(UserNotificationsServer)[59] <Notice>: [it.my.app.dev] Received remote notification request C146-3838 [ hasAlertContent: 0, hasSound: 0 hasBadge: 0 hasContentAvailable: 1 hasMutableContent: 0 ]
Dec 27 10:11:30 iPierX SpringBoard(UserNotificationsServer)[59] <Notice>: [it.my.app.dev] Deliver push notification request C146-3838
Dec 27 10:11:30 iPierX SpringBoard(UserNotificationsServer)[59] <Notice>: [it.my.app.dev] Passing content-available push to Duet
Dec 27 10:11:30 iPierX SpringBoard(DuetActivityScheduler)[59] <Notice>: SUBMITTING: <private>
Dec 27 10:11:30 iPierX SpringBoard(UserNotificationsServer)[59] <Error>: Ignoring notification with no alert, sound or badge (it.my.app.dev): C146-3838
Dec 27 10:11:30 iPierX SpringBoard(UserNotificationsServer)[59] <Notice>: [it.my.app.dev] Not saving push notification C146-3838 to store [ error=Error Domain=UNErrorDomain Code=1401 "Notification has no user-facing content" UserInfo={NSLocalizedDescription=Notification has no user-facing content} ]
Dec 27 10:11:30 iPierX dasd(DuetActivitySchedulerDaemon)[1645] <Notice>: Submitted Activity: com.apple.pushLaunch.it.my.app.dev:EA2367 <private>
Dec 27 10:11:30 iPierX dasd(DuetActivitySchedulerDaemon)[1645] <Notice>: Daemon Canceling Activities: {(
    com.apple.pushLaunch.it.my.app.dev:EA2367
)}
Dec 27 10:11:30 iPierX dasd(DuetActivitySchedulerDaemon)[1645] <Notice>: CANCELED: com.apple.pushLaunch.it.my.app.dev:EA2367 <private>
zontar
  • 485
  • 7
  • 18
  • Please try with at least one key(badge or sound or alert) in push data. In iOS 11 there should be at least one key in dictionary. – Mehul Sojitra Dec 27 '17 at 10:12
  • Tried, but different error, same result, and please be aware that the doc is different on Silent Notifications (called Configuring a Background Update Notification) https://developer.apple.com/library/content/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/CreatingtheNotificationPayload.html – zontar Dec 27 '17 at 11:29

2 Answers2

1

This works also and does not play a sound when it arrives:

{
    aps = {
        "content-available" : 1,
        sound : ""
    };
}
Shehata Gamal
  • 98,760
  • 8
  • 65
  • 87
  • Nice try.. does not work like that. I can manage a different effect with `"sound" : "x"` for example. But still does not work. – zontar Dec 27 '17 at 11:30
  • Yes in the end it worked as expected. Right now I don't remember, maybe it was the priority thing.. sorry – zontar Sep 16 '18 at 16:56
1

Ok.. after a while and chatting with some Apple Engineers and here, I had it working. The key was setting the notification as being High Priority as delivery priority, as well as content-available = 1.

Then of course there are the usual rate limitations for silent push notifications, but overall it works as expected.

zontar
  • 485
  • 7
  • 18
  • I've also found that notifications are more reliable if you set an empty `alertBody`. Otherwise, you device can still ignore background pushes even with the content available flag set. – Clifton Labrum Aug 09 '18 at 05:34
  • 2
    How do you set "high priority"? – Le-roy Staines Sep 15 '18 at 10:44
  • https://developer.apple.com/documentation/usernotifications/setting_up_a_remote_notification_server/sending_notification_requests_to_apns - It's a header in the request to the APNs `apns-priority` with value 5 (as per Apple docs) – zontar Sep 17 '18 at 07:59
  • But to be honest I don't find this header in my server code, so I guess just omitting it is OK. If using Firebase (on another server) I've set priority to `normale` and not `high` – zontar Sep 17 '18 at 08:07
  • apns-priority: 5 is not high priority. That's low priority. Omitting that value defaults to 10, as per the above linked document. This answer makes no sense. – AlexPi Dec 16 '21 at 01:01