#Svenson

1 messages · Page 1 of 1 (latest)

lethal basaltBOT
winter sage
#

👋 happy to help

granite knot
#

hey, thank you

winter sage
#

I'm not really familiar but I can try to help as far as I know

granite knot
#

it's actually swift problem I think

#

Attempt to present <StripeCardScan.SimpleScanViewController: 0x7fad5a8dd800> on <Scan: 0x7fad58c219d0> (from <Scan: 0x7fad58c219d0>) whose view is not in the window hierarchy.

#

this is the error I get

#

this is the code I have

#

I added dispatchqueue due to that error

#

but it's still not helping

winter sage
granite knot
#

my example is from that repo, but not payment sheet

#

I just took the code from cardscan

#

this one

#

and one more question

#

can I then create a new payment method with those result I get?

#

meaning that user can just scan the card and we add it as a source in Stripe

shy cairn
#

Hello, tarzan had to step out but I can help. Were you able to get the original version of that card scan example to work before copying that in to your code?

granite knot
#

no

#

i had the same issue as now

#

Attempt to present * whose view is not in the window hierarchy.

#

can I then create a new payment method with those result I get?
meaning that user can just scan the card and we add it as a source in Stripe

#

or I just can get the result

shy cairn
#

Interesting. If it is even happening in our sample without any changes then it might have something to do with your setup.

#

Trying to think of what we can check further in to based on that

granite knot
#

I had a similar behaviour with one of your additional plugins

#

and this helped

#
    func findViewControllerPresenter(from uiViewController: UIViewController) -> UIViewController {
        // Note: creating a UIViewController inside here results in a nil window
        // This is a bit of a hack: We traverse the view hierarchy looking for the most reasonable VC to present from.
        // A VC hosted within a SwiftUI cell, for example, doesn't have a parent, so we need to find the UIWindow.
        var presentingViewController: UIViewController =
            uiViewController.view.window?.rootViewController ?? uiViewController

        // Find the most-presented UIViewController
        while let presented = presentingViewController.presentedViewController {
            presentingViewController = presented
        }
        return presentingViewController
    }
#
        DispatchQueue.main.async {
            let presentUIViewController = self.findViewControllerPresenter(from: UIApplication.shared.delegate?.window??.rootViewController ?? UIViewController())
            presentUIViewController.present(controller!, animated: true, completion: nil)
        }

#

someone here in the chat helped me with that

shy cairn
#

Interesting. What is the main change there? I am loading up the CardScan sample myself now to see if it is broken for everyone

granite knot
#

I don't think it's broken

#

I am not using native swift app, i am using capacitor app and creating swift plugins

#

but connection is working between these two

#

that's why dispatchque.main.async is needed

#

i am begginer in Swift, so I do not understand much about it

#

but logic for scan card seems easy, but for some reason view is not rendering the right way

shy cairn
#

Oh so did the example work at first, but once you added capacitor stuff it started seeing the same issue?

granite knot
#

maybe I explained it better

#

I have capcitor app

#

and just wanted to add ios plugin for scan card

#

and it does not work

#

connection between the plugin and app is working

#

they are properly connected

#

but something in the plugin code is bugging

shy cairn
#

Gotcha, unfortunately I'm still not finding much on this. I talked to my colleagues and we think it might be best to address this via email so we have time to look deeper in to it. Would you be able to write in about this to a ticket at https://support.stripe.com/?contact=true ?

granite knot
#

Thank you for your time sir