HTTPCookieStorage: Sharing cookies between app an extension

We have a notification service extension which does silent login to our backing to get and update notification content. Login response comes with HTTP header Set-Cookie which adds session cookie used to identify login session.

Then in the app we have actions registered for the corresponding category identifier. Both actions result in requests to our backend which also require session cookie.

Both extension and the app have AppGroup entitlement and use same app group.

Then we configure HTTPCookieStorage:

let cookieStorage = HTTPCookieStorage.sharedCookieStorage(forGroupContainerIdentifier:<group_id>) let configuration = URLSessionConfiguration.default configuration.httpCookieStorage = NetworkClient.cookieStorage

And we do use the very same configuration for all requests in extension / app, however when the app is spawned in the background after user taps one of the notification actions, the cookie storage in the app is empty. Although beforehand the cookie is set in the extension.

Tested with with iOS 14.4.2. Also the question would be if it is possible to activate CFNETWORK_DIAGNOSTICS in both app and extension? App works so far. But not getting logs for the extension in the console.

Appreciate any help and / or ideas.

Post not yet marked as solved Up vote post of mneuwert Down vote post of mneuwert
520 views