我的问题很像this issue。运行Spotify in Swift时,我昨天可以转到播放器。今天,当我构建我的应用程序时,它会调用
UIApplication.shared.open(url, options: [:],
completionHandler: {
(success) in
print("Open success \(success)")
然后在App Delegate:
中打印出来自此回调的URLfunc application(_ application: UIApplication, open url: URL, sourceApplication: String?, annotation: Any) -> Bool {
// Ask SPTAuth if the URL given is a Spotify authentication callback
print("The URL: \(url)")
if SPTAuth.defaultInstance().canHandle(url) {
SPTAuth.defaultInstance().handleAuthCallback(withTriggeredAuthURL: url) { error, session in
// This is the callback that'll be triggered when auth is completed (or fails).
if error != nil {
print("*** Auth error: \(error)")
return
}
else {
SPTAuth.defaultInstance().session = session
}
NotificationCenter.default.post(name: NSNotification.Name.init(rawValue: "sessionUpdated"), object: self)
}
}
return false
}
我的代码中没有任何与Spotify登录流程相关的更改。 我也遇到过这个错误:
-canOpenURL: failed for URL: "spotify-action://" - error: "The operation couldn’t be completed.