Skip to content
This repository has been archived by the owner on Feb 22, 2023. It is now read-only.

Commit

Permalink
Addressed comments; fixed permissions
Browse files Browse the repository at this point in the history
  • Loading branch information
bkonyi committed Jul 20, 2018
1 parent 0879b5d commit 5dd6c5d
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@ public static void registerWith(Registrar registrar) {

@Override
public void onMethodCall(MethodCall call, Result result) {
if (call.method.equals("getPlatformVersion")) {
result.success("Android " + android.os.Build.VERSION.RELEASE);
} else {
result.notImplemented();
}
result.notImplemented();
}
}
4 changes: 4 additions & 0 deletions packages/location_background/example/ios/Runner/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@
<string>gps</string>
<string>armv7</string>
</array>
<key>UIBackgroundModes</key>
<array>
<string>location</string>
</array>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
Expand Down
14 changes: 7 additions & 7 deletions packages/location_background/example/lib/background.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@ import 'dart:ui';
import 'package:location_background_plugin/location_background_plugin.dart';

const String kLocationPluginPortName = 'location_plugin_port';
SendPort uiSendPort;

/// This is an example of a callback for LocationBackgroundPlugin's
/// `startMonitoringLocation`. A callback can be defined anywhere in an
/// application's code, but cannot be from another program.
class Foo {
class LocationMonitor {
static void locationCallback(Location location) {
if (uiSendPort == null) {
// We use isolate ports to communicate between the main isolate and spawned
// isolates since they do not share memory.
uiSendPort = IsolateNameServer.lookupPortByName(kLocationPluginPortName);
}
print('Background Location: $location');
// We use isolate ports to communicate between the main isolate and spawned
// isolates since they do not share memory. The port lookup will return
// null if the UI isolate has explicitly removed the mapping on shutdown.
final SendPort uiSendPort =
IsolateNameServer.lookupPortByName(kLocationPluginPortName);
uiSendPort?.send(location.toJson());
}
}
6 changes: 5 additions & 1 deletion packages/location_background/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ class _MyAppState extends State<MyApp> {
setState(() {
_lastLocation = location;
});
}, onDone: () {
// Remove the port mapping just in case the UI is shutting down but
// background isolate is continuing to run.
IsolateNameServer.removePortNameMapping(kLocationPluginPortName);
});
_locationPlugin ??= LocationBackgroundPlugin();
}
Expand Down Expand Up @@ -112,7 +116,7 @@ class _MyAppState extends State<MyApp> {
onPressed: () async {
if (!_isTracking) {
await _locationPlugin
.monitorLocationChanges(Foo.locationCallback);
.monitorLocationChanges(LocationMonitor.locationCallback);
} else {
await _locationPlugin.cancelLocationUpdates();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ - (void)monitorLocationChanges:(NSArray *)arguments {
_locationManager.distanceFilter = [arguments[3] integerValue];
_locationManager.desiredAccuracy = [arguments[4] integerValue];
_locationManager.activityType = [arguments[5] integerValue];
_locationManager.allowsBackgroundLocationUpdates = YES;
[self->_locationManager startUpdatingLocation];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,8 @@ class LocationBackgroundPlugin {
LocationActivityType activityType;

LocationBackgroundPlugin(
{this.pauseLocationUpdatesAutomatically = true,
this.showsBackgroundLocationIndicator = false,
{this.pauseLocationUpdatesAutomatically = false,
this.showsBackgroundLocationIndicator = true,
this.distanceFilter = 0,
this.desiredAccuracy = LocationAccuracy.best,
this.activityType = LocationActivityType.other}) {
Expand Down

0 comments on commit 5dd6c5d

Please sign in to comment.