2017-09-10 66 views
8

我試圖避免每次會話在Spotify for SDK中過期時彈出授予用戶的權限。Spotify SDK缺少令牌刷新服務?

流行一小時後出現,也許一個彈出似乎再次授予權限的用戶,這樣他可以從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) 
      } 
    }) 

} 

任何解決方案呢?

+0

目前有可能在SDK它自身的問題。獲得加密的刷新令牌零,因此無法更新會話。 https://github.com/spotify/ios-sdk/issues/880臨時我解決了使用棄用SPTAuthViewController的問題,我嘗試了所有方法,並投入了將近36小時的時間來獲取刷新令牌。 –

回答

1

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

+0

我使用的SDK是swift不是objective-c,我沒有Objective-c的知識,如何在swift中編寫它? – Jack