Post

Replies

Boosts

Views

Activity

How to determine when iOS app notification service extension process is about to be terminated?
class NotificationService: UNNotificationServiceExtension { override func didReceive(_ request: UNNotificationRequest, withContentHandler contentHandler: @escaping (UNNotificationContent) -> Void) { // call content handler here when ready } override func serviceExtensionTimeWillExpire() { // call content handler here with the best attempt } } As I understand, for each notification a new instance of NotificationService is created, but all these instances can be in the same process that may share access to the database, network connections and other resources - iOS doesn't start a new NSE process for each new notification, and connecting/disconnecting to/from these resources for each notification would be very inefficient. At some point iOS kills NSE process, and in some cases it results in the exception with 0xdead10cc exit code ("dead lock") that is visible to the users as an alert about the crash of the app in the background. Is there a way to determine when iOS is about to kill NSE process to release the resources?
0
0
387
Jul ’23
Using NSFileProviderService
I've configured an item and placeholder in NSFileProviderExtension iOS extension, and an XPC service in the provider (based on the template for XPC service for Mac, but as part of the NSFileProviderExtension When connecting to the service from the app using code example in getFileProviderServicesForItem I am getting an error straight in the completion handler of that function: Error Domain=NSCocoaErrorDomain Code=4097 "Error while sending identifierForItemAtURL:completionHandler:" UserInfo={NSDebugDescription=Error while sending identifierForItemAtURL:completionHandler:, NSUnderlyingError=0x2833640c0 {Error Domain=NSCocoaErrorDomain Code=4097 "connection from pid 30324 on anonymousListener or serviceListener" UserInfo={NSDebugDescription=connection from pid 30324 on anonymousListener or serviceListener}}} Could you maybe suggest what I am missing? Or, is there an example somewhere of the FileProvider extension with the service being called from the app? Code: File Provider service definition: https://github.com/simplex-chat/simplex-chat/blob/af3dcc4a9a9b24751bf9d74af67cf8e7d119597a/apps/ios/SimpleX%20Service/SimpleXFPService.swift Application code that calls the service: https://github.com/simplex-chat/simplex-chat/blob/af3dcc4a9a9b24751bf9d74af67cf8e7d119597a/apps/ios/Shared/FPService.swift Thank you!
3
0
794
Jun ’22