Skip to content

Commit

Permalink
Remove any forcing for LDClient.get() to a null check first. This wil…
Browse files Browse the repository at this point in the history
…l prevent issue launchdarkly#75 (causing a crash when closing the LDClient).
  • Loading branch information
andhappymoney committed May 24, 2021
1 parent 4e94289 commit 49c9139
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions ios/LaunchdarklyReactNativeClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -449,34 +449,34 @@ class LaunchdarklyReactNativeClient: RCTEventEmitter {
}

@objc func setOffline(_ resolve: @escaping RCTPromiseResolveBlock, reject: RCTPromiseRejectBlock) -> Void {
LDClient.get()!.setOnline(false) {
LDClient.get()?.setOnline(false) {
return resolve(true)
}
}

@objc func isOffline(_ resolve: RCTPromiseResolveBlock, reject: RCTPromiseRejectBlock) -> Void {
resolve(LDClient.get()!.isOnline)
resolve(LDClient.get()?.isOnline)
}

@objc func setOnline(_ resolve: @escaping RCTPromiseResolveBlock, reject: RCTPromiseRejectBlock) -> Void {
LDClient.get()!.setOnline(true) {
LDClient.get()?.setOnline(true) {
return resolve(true)
}
}

@objc func flush() -> Void {
LDClient.get()!.flush()
LDClient.get()?.flush()
}

@objc func close(_ resolve: RCTPromiseResolveBlock, reject: RCTPromiseRejectBlock) -> Void {
LDClient.get()!.close()
LDClient.get()?.close()
resolve(true)
}

@objc func identify(_ options: NSDictionary, resolve: @escaping RCTPromiseResolveBlock, reject: RCTPromiseRejectBlock) -> Void {
let user = userBuild(userDict: options)
if let usr = user {
LDClient.get()!.identify(user: usr) {
LDClient.get()?.identify(user: usr) {
resolve(nil)
}
} else {
Expand Down

0 comments on commit 49c9139

Please sign in to comment.