func verifyOTP(_ completion: @escaping(_ isSuccess: Bool) -> Void){ if let otpToken = otpResponseDetails?.otpToken, let phoneNumber = mobileNumberView.inputTextField.text?.digits { var params: [String:Any] = ["otp_token": otpToken, "grant_type" : "otp_grant", "client_id" : AppConstants.Credentials.clientID, "client_secret" : AppConstants.Credentials.clientSecret, "otp" : otpInputView.getOTPCode(), "username" : phoneNumber, "provider" : "users"] if self.screenType == .forgotPassword { params["request_type"] = "forgot_password" } self.verifyOTPForLogin(params: params, phoneNumber: phoneNumber) { (object) in if let isNewUser = object?.data?.isNewUser, (isNewUser){ let userID = object?.data?.customer?.msisdnNumber ?? "" let params: [String: Any] = ["msisdn": userID] EventsManager.shared.logEventWith(event: .bs_new_signup, params: params) } if object?.statusCode == 200 { if AuthManager.userIsLoggedIn() { DataManager.shared.shouldRefreshData = true self.otpInputView.hideErrorView() TaskManager.saveFCMToken(false) { (success) in} if self.screenType == .loginWithOTP { UIApplication.topViewController()?.navigationController?.popToRootViewController(animated: true) } completion(object != nil) } else { self.otpInputView.updateErrorView(errorString: "Oops! The last OTP you provided didn't work. Please check your SMS and provide the correct OTP.".localized) completion(false) } } else { self.otpInputView.updateErrorView(errorString: "Oops! The last OTP you provided didn't work. Please check your SMS and provide the correct OTP.".localized) completion(false) } } } }