I'm trying to implement the following framework in an empty project:
https://github.com/spotify/SpotifyLogin
This method should be called from AppDelegate but is not:
func application(_ app: UIApplication, open url: URL, options [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
// This is not called
}
According to the documentation, this method is not called if your implementations return false from both the application(_:willFinishLaunchingWithOptions:)
and application(_:didFinishLaunchingWithOptions:)
methods.
However, this is not the case in my app, which explicitly returns true.
- I created a new project
- followed the steps to removing
SceneDelegate
from my project - Added code from github link to Info.plist (pic below)
- copied and pasted the App Delegate from the above github link
- added my custom URL scheme in the Target's URL Types (pic below)
I tried googling, found this question of the same name and this question - but neither helped
however, application:openURL:options:
is not getting called
This is my ApplicationDelegate
import UIKit
import SpotifyLogin
@main
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
print("DidFinishLaunchingWithOptions")
let redirectURL: URL = URL(string: "myscheme://callback/")!
SpotifyLogin.shared.configure(clientID: "###CLIENTID##",
clientSecret: "###CLIENTSECRET##",
redirectURL: redirectURL)
print("Returning true")
return true
}
func application(_ app: UIApplication,
open url: URL,
options: [UIApplication.OpenURLOptionsKey: Any] = [:]) -> Bool {
print("Delegate method called")
let handled = SpotifyLogin.shared.applicationOpenURL(url) { data in
print("Something happened in here")
print(data)
}
return handled
}
}
How I set up my URL Scheme
My Info.plist