While there is a similarity to another question here: iOS 10 don't call Notification Service Extension
I wish to provide a more concrete issue with concrete misbehavior. Consider the following push payload:
{
"service-alert":{
"title":"[Service]Title",
"subtitle":"[Service]Subtitle",
"body":"[Service]Body may be substituted."
},
"image":"https://some.small/thumbnail.jpg",
"aps":{
"badge":1,
"alert":{
"title":"[Default]Title",
"subtitle":"[Default]Subtitle",
"body":"[Default]A simple body of text."
},
"sound":"default",
"mutable-content":1
}
}
(the "service-alert" dictionary is for testing over-rides on the default alert text for devices that support it)
I'm debugging in Xcode on my iOS 10 device (iPhone 6+), I set a breakpoint in the Service Extension to verify it receives an opportunity to modify the push before presenting.
When I send the push, there are times when the Service Extension is hit (breakpoint hit), I can verify that the push payload is correct, and the displayed push shows only the default "aps" payload. No image. No modified title/subtitle/body.
My breakpoint in serviceExtensionTimeWillExpire
is not hit. The notification mechanism appears to be "working" yet the result is incorrect.
When I send the exact same push again, it works.
The image is loaded from the "image" URL and the modified "service-alert" text is displayed as designed. Sometimes I have to send the same push 2 or 3 times before it works, but then it seems consistent after that. So, if I see a modified notification once, from that point on every push test appears to work properly.
I feel, but do not have conclusive data to support yet, that a period of inactivity causes the Service Extension to be flushed and it is too slow to wake up when called upon. If so, this makes it useless, because it will never be fully awake when a push is received.
Current environment:
- Xcode 8.2 beta (8C30a)
- iOS 10.2 betas 2, 3, and 4
- Debug scheme
Can anyone confirm/deny this behavior on iOS 10 beta and/or non-beta? Have I found a 10.2 bug, or is this "normal behavior?"
bestAttemptContent
, that text does not appear in the failed pushes. I could partially understand if the text modification appeared, but not the image (image download timeout?). But for it to be all or nothing, doesn't seem right to me. – Eyelid