From 493ba1516f47c8fe4a5d2367c0ba1f73ba1a5708 Mon Sep 17 00:00:00 2001 From: Dan Field Date: Mon, 19 Nov 2018 12:21:00 -0800 Subject: [PATCH 1/3] Update location_background --- .../ios/Classes/LocationBackgroundPlugin.m | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/packages/location_background/ios/Classes/LocationBackgroundPlugin.m b/packages/location_background/ios/Classes/LocationBackgroundPlugin.m index ea266a91013e..8ccf723627ac 100644 --- a/packages/location_background/ios/Classes/LocationBackgroundPlugin.m +++ b/packages/location_background/ios/Classes/LocationBackgroundPlugin.m @@ -8,7 +8,7 @@ @implementation LocationBackgroundPlugin { CLLocationManager *_locationManager; - FlutterHeadlessDartRunner *_headlessRunner; + FlutterEngine *_headlessRunner; FlutterMethodChannel *_callbackChannel; FlutterMethodChannel *_mainChannel; NSObject *_registrar; @@ -48,7 +48,9 @@ - (BOOL)application:(UIApplication *)application _locationManager.showsBackgroundLocationIndicator = [self getShowsBackgroundLocationIndicator]; } - _locationManager.allowsBackgroundLocationUpdates = YES; + if (@available(iOS 9.0, *)) { + _locationManager.allowsBackgroundLocationUpdates = YES; + } // Finally, restart monitoring for location changes to get our location. [self->_locationManager startMonitoringSignificantLocationChanges]; } @@ -97,7 +99,8 @@ - (instancetype)init:(NSObject *)registrar { [_locationManager setDelegate:self]; [_locationManager requestAlwaysAuthorization]; - _headlessRunner = [[FlutterHeadlessDartRunner alloc] init]; + _headlessRunner = [[FlutterEngine alloc] initWithName:@"io.flutter.plugins.location_background" + project:nil]; _registrar = registrar; // This is the method channel used to communicate with the UI Isolate. @@ -178,7 +181,7 @@ - (void)startHeadlessService:(int64_t)handle { // Here we actually launch the background isolate to start executing our // callback dispatcher, `_backgroundCallbackDispatcher`, in Dart. - [_headlessRunner runWithEntrypointAndLibraryUri:entrypoint libraryUri:uri]; + [_headlessRunner runWithEntrypoint:entrypoint libraryURI:uri]; // The headless runner needs to be initialized before we can register it as a // MethodCallDelegate or else we get an illegal memory access. If we don't @@ -194,12 +197,14 @@ - (void)monitorLocationChanges:(NSArray *)arguments { _locationManager.pausesLocationUpdatesAutomatically = arguments[1]; if (@available(iOS 11.0, *)) { _locationManager.showsBackgroundLocationIndicator = arguments[2]; + [self setShowsBackgroundLocationIndicator:_locationManager.showsBackgroundLocationIndicator]; } _locationManager.activityType = [arguments[3] integerValue]; - _locationManager.allowsBackgroundLocationUpdates = YES; + if (@available(iOS 9.0, *)) { + _locationManager.allowsBackgroundLocationUpdates = YES; + } [self setPausesLocationUpdatesAutomatically:_locationManager.pausesLocationUpdatesAutomatically]; - [self setShowsBackgroundLocationIndicator:_locationManager.showsBackgroundLocationIndicator]; [self->_locationManager startMonitoringSignificantLocationChanges]; } From ce3f56e4ee201f97aa2fef890909affed6f9885c Mon Sep 17 00:00:00 2001 From: Dan Field Date: Mon, 19 Nov 2018 12:31:25 -0800 Subject: [PATCH 2/3] Format --- .../ios/Classes/LocationBackgroundPlugin.m | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/location_background/ios/Classes/LocationBackgroundPlugin.m b/packages/location_background/ios/Classes/LocationBackgroundPlugin.m index 8ccf723627ac..f2e267b218db 100644 --- a/packages/location_background/ios/Classes/LocationBackgroundPlugin.m +++ b/packages/location_background/ios/Classes/LocationBackgroundPlugin.m @@ -99,8 +99,8 @@ - (instancetype)init:(NSObject *)registrar { [_locationManager setDelegate:self]; [_locationManager requestAlwaysAuthorization]; - _headlessRunner = [[FlutterEngine alloc] initWithName:@"io.flutter.plugins.location_background" - project:nil]; + _headlessRunner = + [[FlutterEngine alloc] initWithName:@"io.flutter.plugins.location_background" project:nil]; _registrar = registrar; // This is the method channel used to communicate with the UI Isolate. From 97147eb055915d4057f6ff02dd2d19e01dc5bf0a Mon Sep 17 00:00:00 2001 From: Dan Field Date: Mon, 19 Nov 2018 12:32:33 -0800 Subject: [PATCH 3/3] rename var --- .../ios/Classes/LocationBackgroundPlugin.m | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/location_background/ios/Classes/LocationBackgroundPlugin.m b/packages/location_background/ios/Classes/LocationBackgroundPlugin.m index f2e267b218db..2370d5ce6a87 100644 --- a/packages/location_background/ios/Classes/LocationBackgroundPlugin.m +++ b/packages/location_background/ios/Classes/LocationBackgroundPlugin.m @@ -8,7 +8,7 @@ @implementation LocationBackgroundPlugin { CLLocationManager *_locationManager; - FlutterEngine *_headlessRunner; + FlutterEngine *_headlessEngine; FlutterMethodChannel *_callbackChannel; FlutterMethodChannel *_mainChannel; NSObject *_registrar; @@ -99,7 +99,7 @@ - (instancetype)init:(NSObject *)registrar { [_locationManager setDelegate:self]; [_locationManager requestAlwaysAuthorization]; - _headlessRunner = + _headlessEngine = [[FlutterEngine alloc] initWithName:@"io.flutter.plugins.location_background" project:nil]; _registrar = registrar; @@ -116,7 +116,7 @@ - (instancetype)init:(NSObject *)registrar { // `startHeadlessService` below. _callbackChannel = [FlutterMethodChannel methodChannelWithName:@"plugins.flutter.io/ios_background_location_callback" - binaryMessenger:_headlessRunner]; + binaryMessenger:_headlessEngine]; return self; } @@ -181,7 +181,7 @@ - (void)startHeadlessService:(int64_t)handle { // Here we actually launch the background isolate to start executing our // callback dispatcher, `_backgroundCallbackDispatcher`, in Dart. - [_headlessRunner runWithEntrypoint:entrypoint libraryURI:uri]; + [_headlessEngine runWithEntrypoint:entrypoint libraryURI:uri]; // The headless runner needs to be initialized before we can register it as a // MethodCallDelegate or else we get an illegal memory access. If we don't