-
Notifications
You must be signed in to change notification settings - Fork 93
Feature flag values are inaccessible from extensions that don't have network access #300
Description
Describe the bug
I have an app with a Safari extension and it can't access any LaunchDarkly feature flag values. Safari extensions don't have network access and the SDK is caching flags in a custom user default suite that is inaccessible from app extensions. This is non-configurable from what I can tell (this protocol and implementation is internal):
ios-client-sdk/LaunchDarkly/LaunchDarkly/ServiceObjects/Cache/FeatureFlagCache.swift
Line 23 in cb42f92
| self.keyedValueCache = serviceFactory.makeKeyedValueCache(cacheKey: "com.launchdarkly.client.\(cacheKey)") |
ios-client-sdk/LaunchDarkly/LaunchDarkly/ServiceObjects/ClientServiceFactory.swift
Lines 28 to 30 in cb42f92
| func makeKeyedValueCache(cacheKey: String?) -> KeyedValueCaching { | |
| UserDefaults(suiteName: cacheKey)! | |
| } |
There should be some way to configure this UserDefaults suite to point to the app group ID so extensions can also read from the defaults.
Am I overlooking something? How can I access cached LD flags from extensions that don't have network access?
To reproduce
- Create an iOS app that has a main app target and a Safari extension.
- Set up the LDClient in both the main app and the extension.
- Launch the main app and log the
allFlagsvalue from the client. - Launch the Safari extension target and log the
allFlagsvalue from the client. - Observe that the Safari extension doesn't have any of the fetched or cached flag values from the main app target—it only has the default fallback values.
Expected behavior
Flag values fetched from the main app should be cached in such a way that extension targets can also access the cached values.
SDK version
9.0.0
Language version, developer tools
Xcode 14.3.1
OS/platform
iOS 16.6