iOS 10 Service Extension Inconsistent
Asked Answered
E

1

6

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?"

Eyelid answered 5/12, 2016 at 9:39 Comment(3)
A point of clarification: the Service Extension does two things. 1. It modifies the title, subtitle, and body after which it then 2. Attempts to load the image. Even though the textual changes should be instantaneous, and applied to the 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
Have you figured this out?Sallet
I'm sorry, no. I never did get to the bottom of this.Eyelid
R
0

Using this Pay load Push will come along with default sound

{
  "aps" : {
    "alert": {
      "title": "main title",
      "subtitle":"Subtitle",
      "body": "Custom message"
    },
      "badge" : 0,
      "sound" : "default"
    }
  }
}
Ripe answered 17/4, 2019 at 12:19 Comment(3)
Using this Pay load Push will come along with default soundRipe
Please put your comment as a part of an answerSwarm
While this code may solve the question, including an explanation of how and why this solves the problem would really help to improve the quality of your post, and probably result in more up-votes. Remember that you are answering the question for readers in the future, not just the person asking now. Please edit your answer to add explanations and give an indication of what limitations and assumptions apply.Cheese

© 2022 - 2024 — McMap. All rights reserved.