【问题标题】:How to connect spotify auth in flutter如何在颤振中连接 spotify auth
【发布时间】:2021-02-17 07:35:55
【问题描述】:

我正在使用 spotify_sdk 1.0.1 插件在我的颤振应用程序中发现身份验证。我已经设置了一切,当它处于调试模式而不是发布模式时,它也能正常工作。

请帮帮我。

pubspec.yaml-> 添加包

flutter_secure_storage:^3.3.5 url_launcher:^5.7.10 spotify_sdk: ^1.0.1

 Future<void> connectToSpotifyRemote() async {
try {
  setState(() {
    _loading = true;
  });
  var result = await SpotifySdk.connectToSpotifyRemote(
    clientId: clientId,
    redirectUrl: redirectUrl,);
  setStatus(result
      ? 'connect to spotify successful'
      : 'connect to spotify failed');
  setState(() {
    _loading = false;
  });
} on PlatformException catch (e) {
  setState(() {
    _loading = false;
  });
  setStatus(e.code, message: e.message);

} on MissingPluginException {

  setState(() {
    _loading = false;
  });
  setStatus('not implemented');

}

}

未来的 getAuthenticationToken() 异步 { 试试 {

  var authenticationToken = await SpotifySdk.getAuthenticationToken(
      clientId: clientId,
      redirectUrl: redirectUrl,
      scope: 'app-remote-control, '
          'user-modify-playback-state, '
          'playlist-read-private, '
          'playlist-modify-public,user-read-currently-playing');
  setStatus('Got a token: $authenticationToken');
  return authenticationToken;

 } on PlatformException catch (e) {

   setStatus(e.code, message: e.message);
   return Future.error('$e.code: $e.message');

 } on MissingPluginException {

   setStatus('not implemented');
   return Future.error('not implemented');

 }

}

void setStatus(String code, {String message = ''}) {

var text = message.isEmpty ? '' : ' : $message';
_logger.d('$code$text');

}

还在 android 模块中添加了包

spotify-auth spotify-app-remote

【问题讨论】:

  • 您可以将代码添加到问题中吗?
  • 你好兄弟,你成功为Android设置spotify_sdk了吗?
  • 我被卡住了 4 天。我需要你的帮助来设置spotify_sdk。请在 0304-4819330 上发送消息/电话。我会很感激的。

标签: flutter dart spotify flutter-dependencies


【解决方案1】:

确保您在 android manifest 文件夹中添加了互联网权限

<uses-permission android:name="android.permission.INTERNET" />

【讨论】:

    猜你喜欢
    • 2020-04-03
    • 2020-04-07
    • 2021-08-16
    • 1970-01-01
    • 2020-01-14
    • 2021-09-20
    • 2020-07-03
    • 1970-01-01
    • 2021-04-18
    相关资源
    最近更新 更多