Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MissingPluginException - Problem with several plugins on iOS only. #105

Open
Christer-Muntean opened this issue Apr 17, 2022 · 3 comments
Open

Comments

@Christer-Muntean
Copy link

Christer-Muntean commented Apr 17, 2022

I have issues on iOS with this simple code sample, it throws an MissingPluginException. On Android everything works perfectly fine.

flutter_isolate: ^2.0.2

void connect(String args) async {
  SpotifySdk.subscribeConnectionStatus().listen((event) {
    print(event);
    SpotifySdk.subscribePlayerState().listen((playerStreamData) {
      print('track name: ${playerStreamData.track?.name}');
    });
  });
  SpotifySdk.connectToSpotifyRemote(
    clientId: 'xxxxxx',
    redirectUrl: 'spotify-ios-quick-start://spotify-login-callback',
  );
}

Future<void> main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await FlutterIsolate.spawn(connect, '');

Error spotify_sdk:

======= 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:175:7)
<asynchronous suspension>
#1      EventChannel.receiveBroadcastStream.<anonymous closure> (package:flutter/src/services/platform_channel.dart:516:9)
<asynchronous suspension>
====================================================================================================

Also having problem with shared_preferences:
[VERBOSE-2:ui_dart_state.cc(209)] Unhandled Exception: MissingPluginException(No implementation found for method getAll on channel plugins.flutter.io/shared_preferences)

@DennisMuchiri
Copy link

@Christer-Muntean did you resolve the shared preferences issue?

@DennisMuchiri
Copy link

@Christer-Muntean
After much trials I discovered you have to re-initialize the shared preferences plugin after entering isolate
Using these two plugins; add to pubspec.yaml

shared_preferences_ios: shared_preferences_android:

In your isolate function

if (Platform.isAndroid) { SharedPreferencesAndroid.registerWith(); } else if (Platform.isIOS) { SharedPreferencesIOS.registerWith(); }

@nmfisher
Copy link
Collaborator

nmfisher commented Jun 4, 2022

Unfortunately due to the way that flutter_isolate creates new isolates (by creating a new FlutterEngine), many plugins will have incompatibilities that have to be addressed on the plugin side (or at least with workarounds like the one @DennisMuchiri posted). There's not much that can be done on the flutter_isolate side and this is unlikely to change in the near future.

@Christer-Muntean does reinitializing fix your issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants