如何在Xcode中添加Spotify的URL方案?

时间:2017-07-24 08:21:05

标签: ios xcode spotify url-scheme

我正在使用Spotify iOS SDK,我已经按照官方页面上的教程进行操作,一切都很好,直到我尝试提交到iTunes连接进行测试,我收到错误,说无效的URL方案。这就是我在pllist中最初所拥有的:

spotify-action://

然后我改为

spotify-action

这允许我提交到itunes connect,但是登录流程被打破 - 当我点击登录时,没有任何反应。没有错误,没有警告。

如果我将“://”添加到URL方案中,Spotify App将启动并正确验证

这是我用来登录的功能:

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 })
    }
}

canOpenURL总是返回true,无论我在URL方案中使用“spotify-action://”还是“spotify-action”。

UIApplication.shared.canOpenURL(url)

万一你想知道,这是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&

0 个答案:

没有答案