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

Added iOS location plugin to showcase background execution APIs #656

Merged
merged 14 commits into from
Aug 9, 2018

Conversation

bkonyi
Copy link
Contributor

@bkonyi bkonyi commented Jul 12, 2018

No description provided.

@bkonyi bkonyi force-pushed the location_background_plugin branch from 2a49dba to 54781cb Compare July 18, 2018 16:34
@bkonyi bkonyi changed the title [WIP] Added iOS location plugin to showcase background execution APIs Added iOS location plugin to showcase background execution APIs Jul 18, 2018

@Override
public void onMethodCall(MethodCall call, Result result) {
if (call.method.equals("getPlatformVersion")) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this return result.notImplemented() unconditionally?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didn't even think to look at the Android stuff. Thanks!

/// 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 {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's have a better name than Foo =) Something that hints at what one might do with location data. Maybe "LocationMonitor" or ...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was left over from testing, so I'll go with your suggestion :)

// isolates since they do not share memory.
uiSendPort = IsolateNameServer.lookupPortByName(kLocationPluginPortName);
}
uiSendPort?.send(location.toJson());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens when the foreground isolate closes the port?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've changed this so the port lookup is done on each event since there's really no other way to tell that an isolate port has been closed from the SendPort. Thoughts?

}

// Listen on the port for location updates from our background callback.
_foregroundPort.listen((dynamic message) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When does this port get closed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This port should stay open the life of the UI, but I've updated this logic to remove the port from the IsolateNameServer on close.

@bkonyi bkonyi force-pushed the location_background_plugin branch from bc11f5c to 60930dd Compare August 8, 2018 00:28
# Flutter Background Execution Sample - LocationBackgroundPlugin

A example Flutter plugin that showcases background execution using iOS location services.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not necessarily in this PR, but it would be good to fill this out with brief installation and usage examples.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ack


@Override
public void onMethodCall(MethodCall call, Result result) {
result.notImplemented();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you had plans to implement the Android side, you might add a TODO here that points to the API to use and explains the strategy a bit.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

flutter_test:
sdk: flutter

location_background_plugin:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be a regular dependency?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably. Not sure how that ended up there.


#import <CoreLocation/CoreLocation.h>

@implementation LocationBackgroundPlugin {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As with the android_alarm_manager plugin, I think this file needs detailed comments so that 3p plugin developers know how to hook into the background execution features of the engine.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@bkonyi bkonyi merged commit e293027 into master Aug 9, 2018
@bkonyi bkonyi deleted the location_background_plugin branch August 9, 2018 01:53
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
3 participants