diff --git a/docs/client/iOS/_initialize.mdx b/docs/client/iOS/_initialize.mdx index 41c45b363..6e5fd3ffe 100644 --- a/docs/client/iOS/_initialize.mdx +++ b/docs/client/iOS/_initialize.mdx @@ -11,16 +11,16 @@ import TabItem from "@theme/TabItem"; ```swift -Statsig.start( +Statsig.initialize( sdkKey: "my_client_sdk_key", user: StatsigUser(userID: "my_user_id"), options: StatsigOptions(environment: StatsigEnvironment(tier: .Staging))) -{ errorMessage in +{ error in // Statsig has finished fetching the latest feature gate and experiment values for your user. // If you need the most recent values, you can get them now. - // You can also check errorMessage for any debugging information. + // You can also check error.message and error.code for any debugging information. } ``` @@ -30,11 +30,11 @@ Statsig.start( ```swift StatsigUser *user = [[StatsigUser alloc] initWithUserID:@"my_user_id"]; -[Statsig startWithSDKKey:@"my_client_sdk_key", user:user, completion:^(NSString * errorMessage) { +[Statsig initializeWithSDKKey:@"my_client_sdk_key", user:user, completion:^(StatsigClientError * error) { // Statsig has finished fetching the latest feature gate and experiment values for your user. // If you need the most recent values, you can get them now. - // You can also check errorMessage for any debugging information. + // You can also check error.message and error.code for any debugging information. }]; ``` diff --git a/docs/client/iOS/_options.mdx b/docs/client/iOS/_options.mdx index c4c5248af..ab673fcc7 100644 --- a/docs/client/iOS/_options.mdx +++ b/docs/client/iOS/_options.mdx @@ -1,4 +1,4 @@ -`Statsig.start()` takes an optional parameter `options` in addition to `sdkKey` and `user` that you can provide to customize the Statsig client. Here are the current options and we are always adding more to the list: +`Statsig.initialize()` takes an optional parameter `options` in addition to `sdkKey` and `user` that you can provide to customize the Statsig client. Here are the current options and we are always adding more to the list: - **initTimeout**: Double, default `3.0` - used to decide how long the Statsig client waits for the initial network request to respond before calling the completion block. The Statsig client will return either cached values (if any) or default values if checkGate/getConfig/getExperiment is called before the initial network request completes. @@ -45,7 +45,7 @@ } let opts = StatsigOptions(evaluationCallback: callback) - Statsig.start(sdkKey: "client-key", options: opts) + Statsig.initialize(sdkKey: "client-key", options: opts) ``` - **storageProvider**: StorageProvider, default `nil` diff --git a/docs/client/iOS/_stableID.mdx b/docs/client/iOS/_stableID.mdx index d17cf4237..d4fa07b00 100644 --- a/docs/client/iOS/_stableID.mdx +++ b/docs/client/iOS/_stableID.mdx @@ -10,7 +10,7 @@ export const GetStableID = () => ( export const OverrideStableID = () => ( {`let opts = StatsigOptions(overrideStableID: "my_stable_id") -Statsig.start(sdkKey: "client-xyx", options: opts) +Statsig.initialize(sdkKey: "client-xyx", options: opts) `} ); diff --git a/docs/client/iOS/_statsigListening.mdx b/docs/client/iOS/_statsigListening.mdx index fe035d271..2443ff192 100644 --- a/docs/client/iOS/_statsigListening.mdx +++ b/docs/client/iOS/_statsigListening.mdx @@ -8,18 +8,18 @@ export const AddedInVersion = "1.14.0"; In version v{AddedInVersion}+, you can now listen for changes in Statsig values. -This can be useful if you have one location that calls Statsig.start or Statsig.updateUser +This can be useful if you have one location that calls Statsig.initialize or Statsig.updateUser and you would like these changes to flow to separate locations. To use this API, simply have the class you wish to respond to these changes implement the `StatsigListening` protocol and add it as a listener. The StatsigListening protocol has two methods that can be implemented: -`onInitialized` - Will be called when the initialize request is returned in Statsig.start(). -An error string may be passed to this function if something went wrong with the network request. +`onInitializedWithResult` - Will be called when the initialize request is returned in Statsig.initialize(). +An error object may be passed to this function if something went wrong with the network request. -`onUserUpdated` - Will be called when the network request for Statsig.updateUser is returned. -An error string may be passed to this function if something went wrong with the network request. +`onUserUpdatedWithResult` - Will be called when the network request for Statsig.updateUser is returned. +An error object may be passed to this function if something went wrong with the network request. You may also check the new `Statsig.isInitialized()` to verify if Statsig has already completed initialization. @@ -40,7 +40,7 @@ class MyViewController: UIViewController, StatsigListening { } private func render() { - var showNewUI = Statsig.checkGate("new_ui_enabled", false) + var showNewUI = Statsig.checkGate("new_ui_enabled") if showNewUI { // Render the new } else { @@ -50,17 +50,18 @@ class MyViewController: UIViewController, StatsigListening { private func renderLoading() { /* Some Loading UI */ } - private func renderError(error: String) { /* Some Error UI */ } + private func renderError(error: StatsigClientError) { /* Some Error UI */ } // StatsigListening Implementation - func onInitialized(_ error: String?) { - if (error) { + func onInitializedWithResult(_ error: StatsigClientError?) { + if let error = error { renderError(error) + return } render() } - func onUserUpdated(_ error: String?) { /* Optional rerender when User changed */ } + func onUserUpdatedWithResult(_ error: StatsigClientError?) { /* Optional rerender when User changed */ } } ```