christopherdrum
christopherdrum

Reputation: 1523

iOS 10 Service Extension Inconsistent

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:

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

Upvotes: 6

Views: 655

Answers (1)

madhu kiran
madhu kiran

Reputation: 1

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

Upvotes: 0

Related Questions