iOS : Swift : MobilePaymentsSDK returns wrong authorization state

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
}

Why is there any mention of Reader SDK and mobile auth code if this is with Mobile Payments SDK? :slight_smile:

Apologies. This is not with the Reader SDK. We are migrating from ReaderSDK to PaymentsSDK. Did not change the method names yet. I did change the original question. Can you please have a look at it again?

Okay, that makes sense during a migration. Just curious are you able to connect to a reader and take a payment? :slight_smile:

No, as mentioned in the original post, even though the method loginSquareReaderSDK() successfully authorizes SDK, subsequent check MobilePaymentsSDK.shared.authorizationManager.state returns false even after successful authorization. May I know what could be the reason?

So, I am unable to present Square Reader screen where I accept the payment by swiping the card on the physical reader.