I’m trying to integrate Shopify SDK on a SwiftUI project and I’m having some troubles with the authentication flow.
The code provided on the documentation is pretty straight forward:
func application(_ application: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
spotifyConnection.sessionManager.application(application, open: url, options: options)
return true
}
with SwiftUI though this delegate method is never called so I’m trying to use openUrl
var body: some Scene {
WindowGroup {
MenuView()
.onOpenURL { (url) in
spotifyConnection.sessionManager.application(??, open: url, options: ??)
}
}
}
Question is how do I access the parameters application and options from here?
2
Answers
You need an UIApplicationDelegateAdaptor
I am also having the same issue, for Spotify SDK particularly, I tried passing in
UIApplication.shared
and an empty options dictionary, which seems to work. I also tried examining theoptions
dictionary when I use a UIKit AppDelegate lifecycle. It shows it’s returningopenInPlace
to be false in the options dictionary in the Spotify url callback.