stripe / stripe-ios

Stripe iOS SDK
https://stripe.com
MIT License
2.12k stars 982 forks source link

App Getting Crashed during token creation in iOS 13 but works fine in iOS 12 #1588

Closed vikaskumawat123 closed 3 years ago

vikaskumawat123 commented 4 years ago

Summary

Payment works fine in iOS 12 but not in iOS 13. I am getting the following error in console : - Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<__NSURLSessionLocal 0x12154e3e0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key delegate.'

Code to reproduce

csabol-stripe commented 4 years ago

Hi @vikaskumawat123, would you be able to provide a full backtrace showing when the crash occurs and additional reproduction steps? I was not able to reproduce this crash in my initial investigation

vikaskumawat123 commented 4 years ago

I am using the following code to get token

 let arrTemp = str.components(separatedBy: "/")
    let cardParams = STPCardParams()
    cardParams.number = self.cardNumberTextField.text!
    cardParams.expMonth = UInt(arrTemp[0])!
    cardParams.expYear = UInt(arrTemp[1])!
    cardParams.cvc = self.cvvTextfield.text
    self.hudShow()
    STPAPIClient.shared().createToken(withCard: cardParams) { (token: STPToken?, error: Error?) in
        guard let token = token, error == nil else {
            self.hudHide()
            self.commonMethod.showToast(message: NSLocalizedString("Invalid Card!", comment: ""), view: self.view)
            return
        }
       // Use token .....
    }

This code gives me proper token in iOS 12 but getting crashed in iOS 13 and crash happens on (void)logPayload:(NSDictionary *)payload {} method in STPAnalyticsClient.m class.

csabol-stripe commented 4 years ago

hmm, could you add an Exception breakpoint in Xcode and copy the backtrace when the exception is triggered? The error message is complaining about the key "delegate" but I'm not sure on where that key is being used in this function

davidme-stripe commented 3 years ago

It sounds like it's possible that another component might be trying to swizzle some NSURLSession-related classes. I'm closing this out as we haven't heard back in a while, but let us know if you're still experiencing this issue.