Repository navigation
geolocator_watchos 0.2.0: accuracy, service status, workout settings - #12
Conversation
getLocationAccuracy reports accuracyAuthorization. requestTemporaryFullAccuracy asks with a purpose key and waits for the answer; without NSLocationTemporaryUsageDescriptionDictionary it throws PermissionDefinitionsNotFoundException, as geolocator does on iOS. getServiceStatusStream starts with the current status, then each change CoreLocation signals. AppleSettings now reach CoreLocation, read through toJson() so the package does not depend on geolocator_apple: activityType (ActivityType.fitness for a run) and allowBackgroundLocationUpdates, which turns on only when the Info.plist has the location background mode, since CoreLocation treats it as a fatal error otherwise. Checked: 21 host tests (10 new), a Simulator build with every ffiSymbols entry exported, and the example on the watchOS 27.0 Simulator returning the simulated fix after the permission prompt. The temporary-accuracy prompt and background updates are not yet checked on a physical watch. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ared manager Review fixes on top of the 0.1.2 work, still unreleased: * allowsBackgroundLocationUpdates turns on only when UIBackgroundModes has "location". The check also accepted WKBackgroundModes, but CoreLocation reads only UIBackgroundModes on watchOS too: with "location" under WKBackgroundModes, setting the flag asserted and ended the app (seen on the watchOS 27.0 Simulator; with UIBackgroundModes it runs). * getCurrentPosition no longer stops a position stream that is running, and cancelling one of two streams no longer stops the other: they share the one CLLocationManager, which stops when the last of them ends, and a call during a stream waits for the stream's next fix. * A cached fix more than 5 seconds older than the request is not returned by getCurrentPosition, nor emitted first by a new stream. Checked: 25 host tests (4 new); on the Simulator, the background flag with each plist key, getLocationAccuracy and getServiceStatusStream, and the example's fix after the change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MAUstaoglu
left a comment
There was a problem hiding this comment.
Thanks a lot for this, @iamoguzhanarslantas. The new tests are good, and the watchOS availability work is careful. A few things need to change before we can merge.
Must-fix
-
watchos/Classes/geolocator_watchos_ffi.m:150:CLActivityTypeMaritimeis declared only in the watchOS 27 SDK, so the plugin no longer compiles with Xcode 26, which flutter-watchos still supports. Please guard it with#if __WATCH_OS_VERSION_MAX_ALLOWED >= 270000. At:152, fall back toCLActivityTypeOtherNavigation, as geolocator_apple does, rather thanOther. -
lib/geolocator_watchos.dart:218-222, 260: one shared location manager serves both single fixes and streams.- A
getCurrentPositionduring a distance-filtered stream times out after 30 s if the wearer stands still. - A second stream overwrites the first stream's accuracy and background settings.
Please mirror geolocator_apple: a separate one-time manager for single fixes, and reuse of the running stream. Add tests for both cases.
- A
-
lib/geolocator_watchos.dart:250: the 5 s staleness filter also applies to streams. Upstream filters only single fixes (GeolocationHandler.m:225), and reduced-accuracy fixes can legitimately be much older. -
README.md:81linksflutter_watch_workout, which doesn't exist in this repo or on pub.dev.
Nice-to-have
.m:167: an activity type of 0 keeps the previous value. Please reset it toOther.lib:350calls the blocking+locationServicesEnabledon every fix. Let the callback carry the kind instead (AUTHORING §2b).- The public
GeolocatorWatchosBackendchanged shape, so this should be 0.2.0 with a Breaking CHANGELOG entry. - The activity-type test duplicates the mapping table. Consider testing the real
AppleSettingsthrough a geolocator_apple dev_dependency. - README:
- mention that
allowBackgroundLocationUpdatesdefaults to true; - point to App Review guideline 2.5.4 for background location;
- say that the temporary full-accuracy prompt and wrist-down updates aren't verified on a device yet.
- mention that
Note: our CI doesn't compile the .m files yet, so please build the example with both Xcode 26 and 27. We'll start the CI run once you push the update. Thanks again!
Posted from the wrong account; superseded by the maintainer review.
From the review of PR flutterwatch#12: * CLActivityTypeMaritime is declared only from the watchOS 27 SDK on, so its use is behind #if __WATCH_OS_VERSION_MAX_ALLOWED >= 270000, and the fallback is CLActivityTypeOtherNavigation, as in geolocator_apple. The package builds with Xcode 26 again. * getCurrentPosition has a CLLocationManager of its own, as in geolocator_apple: native starts it at the call's accuracy, skips cached fixes more than 5 seconds old, and stops it after the first fix it accepts. A call during a distance-filtered stream no longer times out while the wearer stands still, nor changes the stream's settings. * getPositionStream called while a stream runs returns that stream, with the settings it started with, as geolocator_apple does; a second stream overwrote the first one's accuracy and background settings. * The 5-second age filter applies only to single fixes, as upstream: a stream emits every fix native delivers, counted by a new geolocator_watchos_position_count, so a fix at the same place is one too. * A stream without AppleSettings gets CLActivityTypeOther instead of the previous stream's type. * The native callback carries a kind (position, authorization, accuracy), so the service status stream asks the blocking locationServicesEnabled only on an authorization change, not on every fix. * 0.2.0 with a Breaking section: GeolocatorWatchosBackend, which is public, changed shape. * The host tests pass geolocator_apple's real AppleSettings, a dev dependency, instead of a copy of its toJson(). * README: no link to flutter_watch_workout, which is not in this repo; AppleSettings turns background updates on by default; App Review Guideline 2.5.4; what is not yet checked on a physical watch. Checked: 26 host tests; the example built for the watchOS 27.0 Simulator with all 13 ffiSymbols exported, and on the Simulator getCurrentPosition answered a simulated location, then a moved one. The .m compiles with the SDK ceiling set to 26 and to 27; it was not built with Xcode 26 itself. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks for the review. Pushed 2536ff2, now 0.2.0: Must-fix
Nice-to-have
Checked: 26 host tests. The example builds for the watchOS 27.0 Simulator with all 13 🤖 Generated with Claude Code |
MAUstaoglu
left a comment
There was a problem hiding this comment.
Thanks, @iamoguzhanarslantas. Every point is addressed. We syntax-checked the .m with Xcode 26.6 and 27.0, for device and simulator, and it compiles on both; the previous revision didn't on Xcode 26. Approving.
CI ran on Ubuntu and never compiled packages/*/watchos. In flutterwatch#12 a symbol declared only in the watchOS 27 SDK would have broken every Xcode 26 build with CI green (flutterwatch#17). tool/check_native_sources.sh compiles every tracked .m, .mm and .c the way the CLI does (clang -target arm64-apple-watchos26.0[-simulator] -fobjc-arc -fmodules -I<each header directory>), with -fsyntax-only, and type-checks SwiftUI view sources with swiftc and a copy of the CLI's registration shim (tool/native/plugin_views_shim.swift, CLI 0.1.1). An error or a warning fails; a deprecation is counted, as in_app_purchase_watchos uses StoreKit 1 on purpose. The four firebase packages, whose Package.swift names a SwiftPM package, are listed and skipped: only a SwiftPM build provides those modules. The new `native` job runs it on macos-26 with Xcode 26.0.1 and 26.6, and on xcode-27 with Xcode 27.0, then runs the check's own tests there. Its fixtures cover the plan (--list, also on Ubuntu), an undeclared symbol and a warning (fail), and a clean source with a deprecation and a view that uses the shim (pass). Locally, on plugins main, all 38 compiles are clean on Xcode 26.6 and 27.0.
Summary
geolocator_watchos0.1.2: three members that were "Not supported on watchOS",AppleSettingsreaching CoreLocation, and two fixes to how streams and single fixes share the location manager.Added
getLocationAccuracyreportsaccuracyAuthorization: precise or reduced.requestTemporaryFullAccuracyasks with a purpose key and waits for the answer. WithoutNSLocationTemporaryUsageDescriptionDictionaryit throwsPermissionDefinitionsNotFoundException, as geolocator does on iOS.getServiceStatusStreamstarts with the current status, then reports each change CoreLocation signals.AppleSettingspassed togetPositionStreamorgetCurrentPositionnow reach CoreLocation, read throughtoJson()so the package does not depend ongeolocator_apple:activityType(for exampleActivityType.fitnessfor a run) andallowBackgroundLocationUpdates.geolocator_watchos_accuracy_authorization,_request_temporary_full_accuracyand_accuracy_requests_done.geolocator_watchos_start_updatestakes the activity type and the background flag.Fixed
getCurrentPositionno longer stops a position stream that is running, and cancelling one of two streams no longer stops the other. They share the oneCLLocationManager, which stops when the last of them ends; a call during a stream waits for the stream's next fix without changing its settings.getCurrentPosition, nor emitted first by a new stream: CoreLocation hands over its last fix first, however old.Background flag
allowsBackgroundLocationUpdatesturns on only when theInfo.plist'sUIBackgroundModeshaslocation. CoreLocation asserts and ends the app otherwise, and it reads onlyUIBackgroundModeson watchOS too: withlocationunderWKBackgroundModesthe app ended on the Simulator, and withUIBackgroundModesit runs. SoWKBackgroundModesdoes not count.Verified
On the watchOS 27.0 Simulator (Apple Watch Series 12, 46 mm):
Info.plistkey, as above.getLocationAccuracyandgetServiceStatusStreamanswer.ffiSymbolsentry in the export table.Off the watch:
AppleSettingsfields, the activity-type mapping, the shared manager with two streams and a single fix during a stream, and the stale cached fix.tool/check,dart formatas CI runs it, andpub publish --dry-runare clean.Not verified
activityTypechanges in real GPS fixes. The Simulator's fixes are simulated.Notes for review
UIBackgroundModes-only check, the shared manager, the stale fix).🤖 Generated with Claude Code