ios-sdk icon indicating copy to clipboard operation
ios-sdk copied to clipboard

AppRemote tries "Connecting..." but does not and gives no further feedback

Open vapor-pawelw opened this issue 5 years ago • 2 comments

I am trying to connect to Spotify using this code

lazy var player: SPTAppRemote = {
        let remote = SPTAppRemote(
            configuration: config,
            logLevel: .debug
        )
        
        remote.delegate = self
        return remote
    }()

and then after initiating session manager:

player.connectionParameters.accessToken = accessToken
        
        SPTAppRemote.checkIfSpotifyAppIsActive { [weak self] isActive in
            if isActive {
                self?.player.connect()
            } else {
                self?.player.authorizeAndPlayURI("")
            }
        }

Since I have Spotify app playing in the background, I'm landing on player.connect() line when debugging with breakpoints. However, all I get in the Xcode console is AppRemote: Connecting... and no further feedback. The delegate method appRemoteDidEstablishConnection(_ appRemote: SPTAppRemote) is not called either, even though set in the lazy initializer as in the snippet above.

Is there any way I could further debug this issue?

Thank you for your help

vapor-pawelw avatar Jun 10 '20 12:06 vapor-pawelw

Didn't happen later so I'm closing this

vapor-pawelw avatar Jun 16 '20 13:06 vapor-pawelw

Unfortunately, it happened a few times for me later. I also had a situation where AppRemote did log AppRemote: Established a session with the Spotify app. but did not log authentication anywhere and did not call any delegate callback. This happened via connect() route. It seems to work fine with authorizeAndPlayURI so far, so it seems I will have to remove the connect() path for now until this is fixed.

This issue happened at some times and sometimes it didn't, I could not determine what was the cause and why sometimes it seemed to work and another time it just did not.

vapor-pawelw avatar Jun 17 '20 11:06 vapor-pawelw

2 years later still having the same problem... any ideas anyone?

vapor-pawelw avatar Sep 23 '22 10:09 vapor-pawelw

For some reason this started working - had to mark everything with @objc

vapor-pawelw avatar Sep 24 '22 17:09 vapor-pawelw