Language: Swift
MobilePaymentsSDK - v2.2.3
Hi, I wrote below two methods in my code after following SDK documentation. Even though the method loginSquareReaderSDK()
successfully authorizes SDK, subsequent check isSquareReaderSDKAuthorized()
returns false.
In other words MobilePaymentsSDK.shared.authorizationManager.state
returns false
even after successful authorization.
Can I please know what is going wrong here or if I am doing something wrong?
Thank you.
func loginSquarePaymentsSDK(mobileAuthCode: String, locationID: String, completion: @escaping (Result<Void>) -> Void) {
guard MobilePaymentsSDK.shared.authorizationManager.state == .notAuthorized else {
return completion(.success(()))
}
MobilePaymentsSDK.shared.authorizationManager.authorize(withAccessToken: mobileAuthCode, locationID: locationID) { error in
if let error {
completion(.error(error))
} else {
completion(.success(()))
}
}
}
func isSquarePaymentsSDKAuthorized() -> Bool {
// Returns `false` even after successful authorization in the above method.
MobilePaymentsSDK.shared.authorizationManager.state == .authorized
}