React-Native Spotify SDK iOS:取消授权 window

React-Native Spotify SDK iOS: Dismiss auth window

我一直在使用以下模块开发 react-native 应用程序:

https://github.com/viestat/react-native-spotify

目前应用开启鉴权window登录spotify。我确实获得了 return 的成功,但我很困惑我现在如何摆脱弹出来登录的 window。我知道它应该重定向回我的应用程序,但它与注销/我的帐户按钮保持相同 window。

知道如何在 returned 成功消息中忽略此 window 吗?

SpotifyAuth.setClientID('*****','*****', ['streaming', 'playlist-read-private'], (error)=>{
          if(error){
            console.log(error);
          } else {
            console.log('success');
          }
        });

如果您看一下代码,登录屏幕(准确地说是 SpotifyLoginViewController)会在 this line of code. According to the logic here, if the redirectURL that you've passed to the setClientID API doesn't match to the redirect URI that you defined in your Spotify developer account (see their authorization guide 处关闭屏幕)- 屏幕不会关闭。

我建议您在检查 url 方案之前在此函数中放置一个断点,看看那里发生了什么。您的帐户配置不正确,或者错误的 URL(或 URL 不是此包预期的格式)正在发送到此 API.

看来您的重定向 URL 配置不正确。

  1. 确保您的 URI 已输入到 Spotify 我的应用程序仪表板中。

  2. 确保您的 URI 符合以下内容:

    • URI 中的所有字符都应小写。
    • 您的 URI 前缀(第一个冒号之前的部分)对于您的应用程序必须是唯一的。它不能是像 http 这样的通用前缀。 您的 URI 前缀只能由您的应用程序用于对 Spotify 进行身份验证。如果您的应用程序已经处理了一个 URL 方案用于其他用途,则不应回收它。
    • 将您的应用程序名称放在其中是一个很好的约定。
    • 您还应该有一个指向您的 URI 的路径组件(第一组正斜杠之后的部分,类似于 your-app://callback