launchdarkly / ios-client-sdk

LaunchDarkly Client-side SDK for iOS (Swift and Obj-C)
https://docs.launchdarkly.com/sdk/client-side/ios
Other
69 stars 84 forks source link

Can no longer retrieve LDUser to modify parameters #221

Closed jeremybarr closed 3 years ago

jeremybarr commented 3 years ago

With the 5.1 release, it seems that I can no longer access the LDUser that's part of the LDClient. My understanding in previous versions was that I could retrieve the LDClient.shared.user, add a new custom parameter, and then call LDClient.shared.identify to update the user with LD servers.

What is the recommended approach to update the current user that's already part of the LDClient object with the new 5.1 release? The documentation does not discuss this change.

torchhound commented 3 years ago

Hi @jeremybarr, the new major release brought a lot of changes to the iOS SDK most of which are hopefully covered in the 4.x to 5.x migration guide on our docs site. You should be able to do LDClient.get().user instead of LDClient.shared.user.

jeremybarr commented 3 years ago

@torchhound so I had tried to use that but I get the following error message when I try and use it...

'user' is inaccessible due to 'internal' protection level

This is what we were using in the 4.x code

` var user = LDClient.shared.user user.custom?.append(["customParam":paramValue]) LDClient.shared.identify(user: user) {

} `

torchhound commented 3 years ago

Hi @jeremybarr, I think this is a bug. We'll remedy this in a patch soon. Thanks for reporting this!

Filed internally as 88475.

torchhound commented 3 years ago

Hi @jeremybarr after internal review we have determined that this is correct behavior and we will not be patching this to make user public.

jeremybarr commented 3 years ago

@torchhound woah! so you're basically saying I can no longer update a user in Launch Darkly?! This makes this product 100% unusable for us. Can you then please explain how I'm supposed to update the properties of the current user after we initialize LD?

brooswit commented 3 years ago

Hi @jeremybarr,

I see you opened a support ticket, so I'll be happy to help you use the product and answer any questions you have over there.

Just so that others can benefit from the answer to your questions, I'll share a short version of my response here as well. The only intended way to update the user's context is by using the SDKs identify method. More information can be found here: https://docs.launchdarkly.com/sdk/client-side/ios#changing-the-user-context