From 49c91391fa9799b05eaa8c0858a5e289d96af8af Mon Sep 17 00:00:00 2001 From: andhappymoney Date: Mon, 24 May 2021 17:53:10 -0600 Subject: [PATCH] Remove any forcing for LDClient.get() to a null check first. This will prevent issue #75 (causing a crash when closing the LDClient). --- ios/LaunchdarklyReactNativeClient.swift | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/ios/LaunchdarklyReactNativeClient.swift b/ios/LaunchdarklyReactNativeClient.swift index 0dd1488..e389c33 100644 --- a/ios/LaunchdarklyReactNativeClient.swift +++ b/ios/LaunchdarklyReactNativeClient.swift @@ -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 {