-
Notifications
You must be signed in to change notification settings - Fork 23
Description
Describe the bug
According to your documentation:
When the app is backgrounded, the stream connection terminates. The SDK polls for flag updates every hour (or another interval you configure) to stay in sync
I could confirm that the SDK works as expected in the foreground and that background polling is working as expected for both 15min and 1 hour intervals when the app is in the background. However, for large polling intervals (I've tried 12 and 24h), the flag is not being updated. I've included my testing implementation bellow. Can you please confirm this is an issue? Am I doing something wrong?
To reproduce
- Setup LaunchDarkly client in the
ApplicationonCreatemethod with a large polling interval, e.g. 12h - Open the app, confirm that changing the flag remotely immediately reflects a flag change locally
- Exit the app. Change the flag remotely one last time
- Wait for 24h without opening the app. The flag is never updated locally. Usually the system kills the process during this period but the flag is not updated even when the process is brought to life in the background
- Open the app, the flag is immediately updated
Expected behavior
The flag should be updated in the background for long polling periods on or around the background polling period defined
Logs
I have none but I'm happy to provide upon request
SDK version
implementation 'com.launchdarkly:launchdarkly-android-client-sdk:2.14.1'
OS/platform
Tested on a Pixel 3a, Android 11
Additional context
Bellow is the current implementation (Application class). You may notice that we have defined a secondary key as we wish to have flags synced from two different projects.
@Override
public void onCreate() {
(...)
Map<String, String> otherKeys = new HashMap<String, String>();
otherKeys.put("secondaryIdentifier", "secondaryKey");
LDConfig ldConfig = new LDConfig.Builder()
.setMobileKey("mainKey")
.setSecondaryMobileKeys(otherKeys)
.setBackgroundPollingIntervalMillis(12 * 60 * 60 * 1000)
.build();
LDUser user = new LDUser.Builder("user")
.build();
LDClient appClient = LDClient.init(this, ldConfig, user, 0);
appClient.registerAllFlagsListener(new LDAllFlagsListener() {
@Override
public void onChange(List<String> flagKey) {
for (String flag : flagKey) {
//Persisting flag to disk
}
}
});
//Sdk-related setup
try {
LDClient ldSdkClient = LDClient.getForMobileKey("secondaryIdentifier");
ldSdkClient.registerAllFlagsListener(new LDAllFlagsListener() {
@Override
public void onChange(List<String> flagKey) {
for (String flag : flagKey) {
//Persisting flag to disk
}
}
});
} catch (LaunchDarklyException e) {
e.printStackTrace();
}
}