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

Community
  • 1
  • 1
christopherdrum
  • 1,513
  • 9
  • 25
  • 1
    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. – christopherdrum Dec 05 '16 at 10:25
  • Have you figured this out? – N.Lee Jun 14 '17 at 12:15
  • I'm sorry, no. I never did get to the bottom of this. – christopherdrum Sep 19 '17 at 23:34

1 Answers1

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"
    }
  }
}
Busti
  • 5,492
  • 2
  • 21
  • 34
madhu kiran
  • 1
  • 1
  • 2
  • Using this Pay load Push will come along with default sound – madhu kiran Apr 17 '19 at 12:21
  • 1
    Please put your comment as a part of an answer – Robson Apr 17 '19 at 12:36
  • While this code may solve the question, [including an explanation](https://meta.stackexchange.com/questions/114762/explaining-entirely-code-based-answers) 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. – Busti Apr 17 '19 at 14:57