[ad_1]
I am utilizing flutter_background_service to start out a service to fetch knowledge from Cloud.
It is working simply high-quality in Android. However once I run on an iOS Simulator, I get the Above talked about error.
void syncData() async {
WidgetsFlutterBinding.ensureInitialized();
Fimber.plantTree(DebugTree());
Fimber.d("SyncData() referred to as");
ultimate service = FlutterBackgroundService();
Fimber.d("Sync Service Began: $service");
ApiRepo apiRepo = ApiRepo();
bool isPatientUploaded = false;
Fimber.d("isPatientUploaded: $isPatientUploaded");
if(Platform.isAndroid) {
SharedPreferencesAndroid.registerWith();
PathProviderAndroid.registerWith();
FlutterBackgroundServiceAndroid.registerWith();
} else if (Platform.isIOS) {
SharedPreferencesIOS.registerWith();
PathProviderIOS.registerWith();
FlutterBackgroundServiceIOS.registerWith();
}
Fimber.d("Fetching Shared Choice");
SharedPreferences prefs = await SharedPreferences.getInstance();
Fimber.d("Fetched Shared Choice: $prefs");
String? authToken = prefs.getString(PrefKeys.TOKEN);
...........
}
I can see the Log until “Fetching Shared Choice” after which get an error afterwards. I do not see the Subsequent log.
[VERBOSE-2:ui_dart_state.cc(209)] Unhandled Exception: PlatformException(channel-error, Unable to determine connection on channel., null, null)
That is how I am beginning the Service
startSync() async {
Fimber.d("startSync() referred to as");
ultimate service = FlutterBackgroundService();
Fimber.i("Configuring $service");
bool? isConfigured = await service.configure(
iosConfiguration: IosConfiguration(
onForeground: syncData, onBackground: syncData, autoStart: false),
androidConfiguration: AndroidConfiguration(
onStart: syncData,
isForegroundMode: true,
autoStart: false,
foregroundServiceNotificationContent: "Importing Knowledge to Cloud...",
foregroundServiceNotificationTitle: "Selfi",
));
await DatabaseHelper().db;
Fimber.i("isConfigured: $isConfigured");
if (isConfigured) {
Fimber.d("Beginning Service");
bool isStarted = await service.startService();
Fimber.d("Service Began: $isStarted");
}
}
[ad_2]
