ios – Spotify SDK缺少令牌刷新服务?

前端之家收集整理的这篇文章主要介绍了ios – Spotify SDK缺少令牌刷新服务?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我试图避免每次会话在Spotify for SDK中过期时用户的弹出窗口授予权限.

Pop出现一小时后,弹出窗口似乎再次授予用户权限,这样他就可以在我的应用程序上播放Spotify中的曲目,我在尝试续订会话时遇到错误

  1. [PLAYER][PLAY][SPOTIFY] Error renew Session Optional(Error Domain=com.spotify.auth Code=0 "Missing token refresh service." UserInfo={NSLocalizedDescription=Missing token refresh service.})
  2. [PLAYER][SPOTIFY] Session could not be renewed,popup login

在这里我如何尝试更新会话:

  1. //Renew Session
  2. func renewSession(completion:@escaping (Bool)->())
  3. {
  4. print("[PLAYER][PLAY][SPOTIFY] Renew Session requested ")
  5.  
  6. let auth = SPTAuth.defaultInstance()
  7. auth?.renewSession(auth?.session,callback: { (error,session) in
  8.  
  9. if (error != nil)
  10. {
  11. print("[PLAYER][PLAY][SPOTIFY] Error renew Session \(String(describing: error))")
  12. completion(false)
  13. return
  14. }
  15.  
  16. auth?.session = session
  17.  
  18. if auth?.session.isValid() == true
  19. {
  20. print("[PLAYER][PLAY][SPOTIFY] Renew Session Success")
  21. completion(true)
  22. }else
  23. {
  24. print("[PLAYER][PLAY][SPOTIFY] Renew Session Failed")
  25. completion(false)
  26. }
  27. })
  28.  
  29. }

任何解决方案?

解决方法

您是否在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

猜你在找的iOS相关文章