iosswiftios10serviceextension

didReceiveNotificationRequest:withContentHandler - execution time limit?


UNNotificationServiceExtension has a method didReceiveNotificationRequest:withContentHandler to handle notification change.

It has a very ambiguous description, regarding timeout time:

That method has a limited amount of time to perform its task and execute the provided completion block. If your method does not finish in time,

And here's a description of serviceExtensionTimeWillExpire method:

If your didReceiveNotificationRequest:withContentHandler: method takes to long to execute its completion block, the system calls this method on a separate thread to give you one last chance to execute the block.

I don't fully get, what "to long to execute" means. Does it have any quantitative data? Does it vary on device it runs, etc.?

Thanks!


Solution

  • https://developer.apple.com/reference/usernotifications/unnotificationserviceextension/1648229-didreceivenotificationrequest?language=objc#discussion

    Taken from Apple docs above link.

    Your extension has a limited amount of time (no more than 30 seconds) to modify the content and execute the contentHandler block.