I am implementing paypal using SFSafariViewController. I have called the create order api and after the order is success i return back to my app to capture payment by using a deep link in openURLContexts method of scene delegate.

I want to return just where i was on a View Controller called GetPlansVC. Right now if i simply navigate to GetPlansVC the app screen turns black.

And if i create a new instance of navigation controller my previous data like access token is lost.

I tried calling notification on receiving token but that turned my app screen black.

1

There are 1 answers

0
AntiVIRUZ On

You can create an object in your scene delegate (or in other place, it can be singleton for example), which contain closure. In your GetPlansVC you place a closure, where you close SFSafariViewController, and in scene delegate, on receive deep link, you invoke this closure. It's a basic concept, you can place it in your architecture in a better way, that I've written

Example:

// GetPlansVC
sceneDelegate.safariClosure = { [weak self] in
    self?.dismiss(animated: true)
}
let safariVC = SFSafariViewController(url: url)
controller.present(safariVC, animated: true)

// Scene delegate
if isPayment(url: url) {
    self.safariClosure?()
    self.safariClosure = nil
}