我试图避免每次会话在Spotify for SDK中过期时用户的弹出窗口授予权限.
Pop出现一小时后,弹出窗口似乎再次授予用户权限,这样他就可以在我的应用程序上播放Spotify中的曲目,我在尝试续订会话时遇到错误:
[PLAYER][PLAY][SPOTIFY] Error renew Session Optional(Error Domain=com.spotify.auth Code=0 "Missing token refresh service." UserInfo={NSLocalizedDescription=Missing token refresh service.})
[PLAYER][SPOTIFY] Session Could not be renewed,popup login
在这里我如何尝试更新会话:
//Renew Session
func renewSession(completion:@escaping (Bool)->())
{
print("[PLAYER][PLAY][SPOTIFY] Renew Session requested ")
let auth = SPTAuth.defaultInstance()
auth?.renewSession(auth?.session,callback: { (error,session) in
if (error != nil)
{
print("[PLAYER][PLAY][SPOTIFY] Error renew Session \(String(describing: error))")
completion(false)
return
}
auth?.session = session
if auth?.session.isValid() == true
{
print("[PLAYER][PLAY][SPOTIFY] Renew Session Success")
completion(true)
}else
{
print("[PLAYER][PLAY][SPOTIFY] Renew Session Failed")
completion(false)
}
})
}
任何解决方案?
解决方法
您是否在SPTAuth对象上分配了这些属性?
[SPTAuth defaultInstance] .tokenSwapURL = [NSURL URLWithString:@“swapURL”];
[SPTAuth defaultInstance] .tokenRefreshURL = [NSURL URLWithString:@“refreshURL”];
取自https://github.com/spotify/ios-sdk/issues/427,如果这还不够,可能会有更多信息.
还有一个SPTAuth类的参考:
https://spotify.github.io/ios-sdk/Classes/SPTAuth.html