Nou*_*our 5 xcode url-scheme spotify ios
我正在使用 Spotify iOS SDK,我按照官方页面上的教程进行操作,一切都很好,直到我尝试提交到 iTunes connect 进行测试,但出现错误,提示 URL 方案无效。这是我最初在 pllist 中的内容:
spotify-action://
Run Code Online (Sandbox Code Playgroud)
然后我改成
spotify-action
Run Code Online (Sandbox Code Playgroud)
这允许我提交到 itunes connect,但登录流程被破坏 - 当我单击登录时,没有任何反应。没有错误,没有警告。
如果我将“://”添加到 URL 方案中,Spotify 应用程序将启动并正确进行身份验证
这是我用来登录的功能:
func openLoginPage() {
let auth = SPTAuth.defaultInstance()
if SPTAuth.supportsApplicationAuthentication() {
guard let url = auth?.spotifyAppAuthenticationURL() else { return }
if #available(iOS 10.0, *) {
if(!UIApplication.shared.openURL(auth!.spotifyAppAuthenticationURL())){
self.showAlertL(message: "Link won't work for some reason", link: url)
}
else{
print("This works - start screen");
print(schemeAvailable(scheme: "\(url)"))
}
print("This is the URL For Spotify ios 10 \(String(describing: auth?.spotifyAppAuthenticationURL()))")
} else {
print("This is the URL For Spotify old \(auth!.spotifyAppAuthenticationURL())")
UIApplication.shared.openURL(auth!.spotifyAppAuthenticationURL())
}
} else {
self.authViewController = self.getAuthViewController(withURL: SPTAuth.defaultInstance().spotifyWebAuthenticationURL())
self.definesPresentationContext = true
self.present(self.authViewController!, animated: true, completion: { () in })
}
}
Run Code Online (Sandbox Code Playgroud)
canOpenURL 始终返回 true,无论我在 URL 方案中使用“spotify-action://”还是仅使用“spotify-action”。
UIApplication.shared.canOpenURL(url)
Run Code Online (Sandbox Code Playgroud)
以防万一您想知道,这是 URL 的内容(我已删除重定向 URI 部分)
spotify-action://authorize?
nolinks=true&
nosignup=true&
response_type=code&
scope=streaming%20playlist-read-private%20playlist-modify-public%20playlist-modify-private%20user-read-private&
utm_source=spotify-sdk&
utm_medium=ios-sdk&
utm_campaign=ios-sdk&
Run Code Online (Sandbox Code Playgroud)