【问题标题】:Spotify AppRemote is not reconnecting once disconnected in iOS在 iOS 中断开连接后,Spotify AppRemote 不会重新连接
【发布时间】:2020-02-04 15:31:31
【问题描述】:

我在我的 iOS 应用程序中使用 Spotify 来列出和播放播放列表。最初,我连接appRemote 并获取具有以下范围的基本播放列表内容,例如 .appRemote、.playlist、. playlistReadPrivate 等

应用程序运行正常,但如果我接到电话,则我的appRemote 与以下日志断开连接:

AppRemote:因错误断开连接:错误域=com.spotify.app-remote.transport Code=-2001“流结束。” UserInfo={NSLocalizedRecoverySuggestion=重新连接到 Spotify 应用程序。, NSLocalizedDescription=流结束。, NSLocalizedFailureReason=其中一个流已经结束。}

我尝试在应用 WillResignActive 状态下断开 appRemote,并在前台状态下重新启用(使用 appRemote.connect() 重新连接)。他们都没有帮助。有什么办法可以解决这个问题,否则我们必须再次重新授权。任何帮助都感激不尽。谢谢。

【问题讨论】:

    标签: ios spotify


    【解决方案1】:

    我试过了:

    - (void)appRemote:(SPTAppRemote *)appRemote didFailConnectionAttemptWithError:(NSError *)error
    

    使用计数器变量和增加延迟来处理重新连接尝试

    [self performSelector:@selector(connect2Spotify) withObject:self afterDelay:3.0];
    

    不完美...但在大多数情况下都有效..

    -(void)connect2Spotify
    {
        if (self.appRemote!=nil)
        {
            if (!self.appRemote.connected){
                self.appRemote.connectionParameters.accessToken = self.token;
                [self.appRemote connect];
            }
        }
    }
    

    【讨论】:

      猜你喜欢
      • 2012-08-07
      • 2019-02-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-04-12
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多