launchdarkly / react-native-client-sdk

LaunchDarkly Client-side SDK for React Native
Other
47 stars 32 forks source link

registerFeatureFlagListener isn't working for Android #262

Closed leo-nestor closed 7 months ago

leo-nestor commented 7 months ago

Is this a support request? This issue tracker is maintained by LaunchDarkly SDK developers and is intended for feedback on the SDK code. If you're not sure whether the problem you are having is specifically related to the SDK, or to the LaunchDarkly service overall, it may be more appropriate to contact the LaunchDarkly support team; they can help to investigate the problem and will consult the SDK team if necessary. You can submit a support request by going here or by emailing support@launchdarkly.com.

Note that issues filed on this issue tracker are publicly accessible. Do not provide any private account information on your issues. If your problem is specific to your account, you should submit a support request as described above.

Describe the bug registerFeatureFlagListener is not working for Android, when the custom value is changed in LD dashboard the callback is not triggered but in iOS it does without problem.

To reproduce

const client = new LDClient();
await newClient.configure(config, context);

  useEffect(() => {
     client?.identify(context);
  }, [client, context]);

  useEffect(() => {
    if (client) {
      updateValue();
      client.registerFeatureFlagListener('custom-flag-key', updateValue);
    }

    return () => {
      if (client) {
        client.unregisterFeatureFlagListener('custom-flag-key', updateValue);
      }
    };
  }, [client]);

Expected behavior The callback (updateValue) should be called when the 'custom-flag-key' is modified in LD, but is not happening in android (it is in iOS)

Logs If applicable, add any log output related to your problem.

SDK version 7.1.6

Language version, developer tools "react-native": "0.71.13"

OS/platform Android 12

Additional context registerAllFlagsListener it is working for both Android and iOS