How to add Spotify URL Scheme in Xcode?
I am using the Spotify iOS SDK, I followed the tutorial on the official page and everything was fine until I tried submitting to iTunes connect for testing and I got an error giving an invalid url scheme. This is what I meant in the list:
spotify-action://
which I then changed to
spotify-action
This allows me to post to itunes connect, but the input stream is interrupted - when I click the login button, nothing happens. no errors, no warnings.
If I add ": //" to the URL scheme, the Spotify App starts up and authenticates correctly
this is the function i use to login:
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 always returns true, regardless of whether I use "spotify-action: //" or just "spotify-action" in the URL scheme.
UIApplication.shared.canOpenURL(url)
just in case you are wondering, this is the content of the url (i removed the redirect URI part)
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&
source to share
No one has answered this question yet
Check out similar questions: