I am using a free Spotify account for development purposes only. I am trying to use this to connect my Flutter iOS application with Spotify. One thing to mention in advance is that the whole code I did is working fine on Android perfectly but not on iPhone. I followed the instructions in the section Setup the iOS SDK of Spotify iOS SDK Quick Start. It connects then returns a token and opens my application and songs start playing on Spotify. I am able to hit the button at the bottom and it also changes the song "I'll Make a Man Out of You" which is linked in the example at https://github.com/brim-borium/spotify_sdk/tree/main/example
Well I just copied example project files in my project and use my ClientID and RedirectURL and it works well in Andriod but when I run it on iOS it started giving me the below error...
AppRemote: Connecting...
[connection] nw_socket_handle_socket_event [C1.1.1:1] Socket SO_ERROR [61: Connection refused]
AppRemote: Established a connection to the Spotify app.
AppRemote: Authenticated with the Spotify app.
AppRemote: Established a session with the Spotify app.
flutter: \^[[38;5;12m┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────<…>
flutter: \^[[38;5;12m│ #0 _SpotifyExampleState.setStatus (package:runwith/screens/SpotifyExample/Debugging.dart:647:13)<…>
flutter: \^[[38;5;12m│ #1 _SpotifyExampleState.getAccessToken (package:runwith/screens/SpotifyExample/Debugging.dart:459:7)<…>
flutter: \^[[38;5;12m├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄<…>
flutter: \^[[38;5;12m│ 22:26:44.966 (+0:01:30.499038)<…>
flutter: \^[[38;5;12m├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄<…>
flutter: \^[[38;5;12m│ 💡 Got a token: BQDPjhNCDTPalqK71CNYU2PGI_VF8ejg7PzaQK7e01p2mnpi4smf7bX5SCANXUd211T84grf_DgcKKmuWN7KbOGPy-sKESYmgKG59_4EC0MKX21E6mZ9UVPaH58D4ovtKg33DJRU9FRJEWODFOISYGIUU09S328EWEYYWR802384WUDJUF98YCOIFIHSDJHCJ38EYIEDN90WEUF0UJDOFCJW09R0JFOIJU0R9U0rlumS_GSMx-OR0arQdE7ayy-OJxIDXCyPIZ8o0NlQtQdPwoJ7ZIxT4vzmNj4kj4JnbWxiy2V5v6NdMhUY8qYLk7YmZSdY2oL8CZe9oMOGQSoXR7cJA<…>
flutter: \^[[38;5;12m└───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────<…>
======== Exception caught by services library ======================================================
The following MissingPluginException was thrown while activating platform stream on channel player_state_subscription:
MissingPluginException(No implementation found for method listen on channel player_state_subscription)
When the exception was thrown, this was the stack:
#0 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:313:7)
<asynchronous suspension>
#1 EventChannel.receiveBroadcastStream.<anonymous closure> (package:flutter/src/services/platform_channel.dart:662:9)
<asynchronous suspension>
====================================================================================================
======== Exception caught by services library ======================================================
The following MissingPluginException was thrown while activating platform stream on channel player_context_subscription:
MissingPluginException(No implementation found for method listen on channel player_context_subscription)
When the exception was thrown, this was the stack:
#0 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:313:7)
<asynchronous suspension>
#1 EventChannel.receiveBroadcastStream.<anonymous closure> (package:flutter/src/services/platform_channel.dart:662:9)
<asynchronous suspension>
====================================================================================================
So my main bug is MissingPluginException(No implementation found for method listen on channel player_state_subscription)
& MissingPluginException(No implementation found for method listen on channel player_context_subscription)
that was not showing earlier and crashing the app in iOS then I did this GCDWebServer always aborts on options check then I am able to see upper error code.
Here is the rest of the required details...
Other Plugin
dependencies:
flutter:
sdk: flutter
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^1.0.2
# ThirdParty Dependencies Added Manually
shared_preferences: ^2.0.15
google_fonts: ^3.0.1
http: ^0.13.4
http_interceptor: ^1.0.2
dio: ^4.0.4
retrofit: ^3.0.0
flutter_datetime_picker: ^1.5.1
intl: ^0.17.0
fluttertoast: ^8.0.9
sn_progress_dialog: ^1.1.3
flutter_native_splash: ^2.2.14
flutter_launcher_icons: ^0.10.0
animated_splash_screen: ^1.3.0
country_code_picker: ^2.0.2
country_codes: ^2.2.0
animated_bottom_navigation_bar: ^1.1.0
carousel_slider: ^4.1.1
csc_picker: ^0.2.6
google_maps_flutter: ^2.2.0
location: ^4.4.0
permission_handler: ^9.2.0
path_provider: ^2.0.8
provider: ^6.0.1
flutter_polyline_points: 1.0.0
share_plus: ^4.0.4
flutter_background_service: ^2.4.5
device_info_plus: ^8.0.0
sensors_plus: ^2.0.1
image_picker: ^0.8.4+8
better_player: any
flutter_google_places: 0.3.0
google_maps_webservice: ^0.0.19
google_api_headers: ^1.5.0
custom_marker: 1.0.0
pull_to_refresh: ^2.0.0
spotify_sdk: ^2.3.1
flutter_dotenv: ^5.0.2
cast: ^1.1.1
logger: ^1.1.0
flutter_vlc_player: ^7.1.4
app_settings: ^4.1.1
number_to_words: ^1.0.0
just_audio: ^0.9.31
webview_flutter: ^3.0.4
flutter_easyloading: ^3.0.5
flutter_html: ^3.0.0-alpha.6
just_the_tooltip: ^0.0.12
image: ^3.3.0
screenshot: ^1.3.0
Fluter Doctor
/Users/my_macbook_username/AndroidStudioProjects/flutter_v3.7.11/bin/flutter doctor --verbose
[!] Flutter (Channel stable, 3.7.11, on macOS 13.3.1 22E261 darwin-arm64, locale en-PK)
• Flutter version 3.7.11 on channel stable at /Users/my_macbook_username/AndroidStudioProjects/flutter_v3.7.11
! The flutter binary is not on your path. Consider adding /Users/my_macbook_username/AndroidStudioProjects/flutter_v3.7.11/bin to your path.
! The dart binary is not on your path. Consider adding /Users/my_macbook_username/AndroidStudioProjects/flutter_v3.7.11/bin to your path.
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision f72efea43c (3 weeks ago), 2023-04-11 11:57:21 -0700
• Engine revision 1a65d409c7
• Dart version 2.19.6
• DevTools version 2.20.1
• If those were intentional, you can disregard the above warnings; however it is recommended to use "git" directly to perform update checks and upgrades.
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
• Android SDK at /Users/exeideasmy_macbook_usernameLibrary/Android/sdk
• Platform android-33, build-tools 33.0.0
• Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 11.0.13+0-b1751.21-8125866)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 14.3)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 14E222b
• CocoaPods version 1.11.3
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2021.3)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 11.0.13+0-b1751.21-8125866)
[✓] Connected device (3 available)
• SM A325F (mobile) • RF8R509QMYF • android-arm64 • Android 13 (API 33)
• macOS (desktop) • macos • darwin-arm64 • macOS 13.3.1 22E261 darwin-arm64
• Chrome (web) • chrome • web-javascript • Google Chrome 112.0.5615.137
[✓] HTTP Host Availability
• All required HTTP hosts are available
! Doctor found issues in 1 category.
Process finished with exit code 0
Target Platform, Version & Device
Development OS
After trying multiple ways, I found out that "flutter_background_service" plugin is breaking this Spotify Player State Stream. When I stop background service then it is working fine but when I start background service before the Spotify connection then it is giving me this error. Now how to keep both?
Finally, with the support of the Plugin Author, this bug is fixed and released in the new version of the plugin. You can read more history at https://github.com/brim-borium/spotify_sdk/issues/189
A new version has been released and can be used from pub.dev: https://pub.dev/packages/spotify_sdk/versions/3.0.0-dev.3