launchdarkly / react-native-client-sdk

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

Calling allFlags returns empty object in Android #179

Closed ff-marco-pereira closed 1 year ago

ff-marco-pereira commented 1 year ago

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 allFlags call returns an empty object in Android

To reproduce tested with sample app

Expected behavior

Logs taken using console.log ANDROID = {"allFlags": {}, "lastError": "UNEXPECTED_RESPONSE_CODE"} IOS = {"allFlags": {"flag": false, "other-flag": true}, "lastError": "NONE"}

last error is the output of calling client.getLastFailure()

SDK version 6.3.0

Language version, developer tools JS React 18.1.0 React native 0.70.5

OS/platform Mac OS Monterey Apple M1 Pro

Additional context Add any other context about the problem here.

RaiKouz759 commented 1 year ago

Having the same issue with the same versions

RaiKouz759 commented 1 year ago

While the documentation states that a key will be generated automatically if none is provided, I only managed to get it to work by having a dummy key value in the LDUser object in the initial configure call, e.g. client.configure(config, { key: uniqueId() }. Hope this helps others that come across this issue.

louis-launchdarkly commented 1 year ago

Hello @RaiKouz759, sorry for the late reply, and thank you for the suggestion. We will look into this. In the meantime, if you can, we recommend migrating to the 7.x version of the React Native SDK if possible, as there are improvements we added to the adapter code from React portion to the Native module.

Filed Internally as 190725.

yusinto commented 1 year ago

The user key property is mandatory for the React Native SDK versions 6.x because the underlying Android SDK mandates it. In versions >= 7.x the React Native SDK will auto generate the context key if none is provided. Please update to the latest 7.x version to resolve this issue.

If you have to stay on versions 6.x, the workaround is to ensure that the user key is set.