You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import Foundation
finalclassSpotifyTestManager:NSObject{staticletshared=SpotifyTestManager()enumConfig{staticvarclientID:String{/* Client ID string returned here */}staticvarredirectURL:URL{/* url returned here */}staticvartokenSwapURL:URL{/* url returned here */}staticvartokenRefreshURL:URL{/* url returned here */}}
lazy varplayer:SPTAppRemote={letremote=SPTAppRemote(
configuration: config,
logLevel:.debug
)
remote.delegate =selfreturn remote
}()private lazy varconfig:SPTConfiguration={letconfig=SPTConfiguration(
clientID:Config.clientID,
redirectURL:Config.redirectURL
)
config.tokenSwapURL =Config.tokenSwapURL
config.tokenRefreshURL =Config.tokenRefreshURL
return config
}()private lazy varsessionManager:SPTSessionManager={returnSPTSessionManager(configuration: config, delegate:self)}()overrideinit(){
super.init()NotificationCenter.default.addObserver(self,
selector: #selector(willResignActive),
name:UIApplication.willResignActiveNotification,
object:nil)NotificationCenter.default.addObserver(self,
selector: #selector(didBecomeActive),
name:UIApplication.didBecomeActiveNotification,
object:nil)}func connect(){letscopes:SPTScope=[.streaming,.playlistReadPrivate,.userLibraryRead,.userReadPrivate,.userModifyPlaybackState]
sessionManager.initiateSession(with: scopes, options:.clientOnly)}func toggle(){}func next(){}@discardableResultfunc application(_ app:UIApplication, open url:URL, options:[UIApplication.OpenURLOptionsKey:Any]=[:])->Bool{letwillParse= sessionManager.application(app, open: url, options: options)print("BACK: \(willParse)")return willParse
}@objcprivatefunc willResignActive(){
if player.isConnected {
player.disconnect()}}@objcprivatefunc didBecomeActive(){
if let token = player.connectionParameters.accessToken, sessionManager.session !=nil{
player.connect()}}}extensionSpotifyTestManager:SPTSessionManagerDelegate{func sessionManager(manager:SPTSessionManager, didInitiate session:SPTSession){
log.verbose("INITIATE")
player.connectionParameters.accessToken = session.accessToken
SPTAppRemote.checkIfSpotifyAppIsActive{ isActive in
if isActive {self.player.connect()}else{self.player.authorizeAndPlayURI("")}}}func sessionManager(manager:SPTSessionManager, didFailWith error:Error){print("FAIL")}func sessionManager(manager:SPTSessionManager, didRenew session:SPTSession){print("RENEW")}func sessionManager(manager:SPTSessionManager, shouldRequestAccessTokenWith code:String)->Bool{print("REQ CODE: \(code)")return true
}}extensionSpotifyTestManager:SPTAppRemoteDelegate{func appRemoteDidEstablishConnection(_ appRemote:SPTAppRemote){print("PLAYER-ESTABLISH")}func appRemote(_ appRemote:SPTAppRemote, didFailConnectionAttemptWithError error:Error?){print("PLAYER-FAIL")}func appRemote(_ appRemote:SPTAppRemote, didDisconnectWithError error:Error?){print("PLAYER-DISCONNECT")}}
I'm always lading on "INITIATE" then "PLAYER-FAIL".
This is showing up in the console:
AppRemote: Connecting...
AppRemote: Established a connection to the Spotify app.
AppRemote: Failed to authenticate with the Spotify app.
AppRemote: Failed to establish a sesssion with error: Error Domain=com.spotify.app-remote.wamp-client Code=-1001 "wamp.error.not_authorized" UserInfo={details={
message = "Token not valid.";
}, NSLocalizedFailureReason=wamp.error.not_authorized}
The Spotify app (8.5.60) is playing in the background all the time, and it does an app-switch, but always fails on setting up the remote. I also have the Info.plist set up for redirect host (and it is properly returning to the app after going through Spotify).
I've also seen this thread and the error looks similar (#125)
Any help regarding this?
The text was updated successfully, but these errors were encountered:
Hello, this is my example class for connecting
I'm always lading on "INITIATE" then "PLAYER-FAIL".
This is showing up in the console:
The Spotify app (8.5.60) is playing in the background all the time, and it does an app-switch, but always fails on setting up the remote. I also have the Info.plist set up for redirect host (and it is properly returning to the app after going through Spotify).
I've also seen this thread and the error looks similar (#125)
Any help regarding this?
The text was updated successfully, but these errors were encountered: