flutter_background_service
flutter_background_service copied to clipboard
Use of path_provider in background on iOS gives issues
Hi,
I get the following error:
2022-03-01 11:14:50.632181+0100 Runner[1070:257679] Metal API Validation Enabled
2022-03-01 11:14:50.877308+0100 Runner[1070:257941] [VERBOSE-2:ui_dart_state.cc(198)] Unhandled Exception: MissingPluginException(No implementation found for method getApplicationDocumentsDirectory on channel plugins.flutter.io/path_provider_ios)
#0 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:165)
I thought the problem was with the path-provider (and path-provider-ios), but it seems to be something related to registering a package (somewhere?). See https://github.com/flutter/flutter/issues/99155#issuecomment-1055288089 and subsequent communications with Stuart Morgan.
Can you help???
try to call this https://github.com/flutter/flutter/issues/99155#issuecomment-1052023743 in onBackgroundServiceStart. If the error still occured, try to register plugins in native side. See: https://github.com/ekasetiawans/flutter_background_service/blob/master/example/ios/Runner/AppDelegate.swift
try to call this flutter/flutter#99155 (comment) in
onBackgroundServiceStart.
The error message is about plugins.flutter.io/path_provider_ios, which means the Dart registration has successfully run in this scenario.
@stuartmorgan the root cause is the MethodChannelHandler in native side is not registered to the FlutterEngine. I use separated FlutterEngine to execute background task.