plus_plugins
plus_plugins copied to clipboard
fix(sensors_plus): corrected iOS magnetometer source
Obtain magnetometer events from DeviceMotion rather than raw startMagnetometerUpdates(). This also makes the magnetometer onCancel() method now correct.1 Added set showsDeviceMovementDisplay
to true for magnetometer.
1 While working on the changes, I noticed the current implementation in onCancel()
calls _motionManager.stopDeviceMotionUpdates()
. This is interesting, because the correct course is to obtain events from MotionManager, but the current implementation is not. Because it currently calls startMagnetometerUpdates()
, the onCancel()
method ought to call stopMagnetometerUpdates()
. Current users of sensors_plus, after obtaining magnetometer readings, could never have the sensor correctly canceled, to my understanding.
At any rate, the onCancel gets to stay as it is while the source of the events is corrected.
Description
When this package was converted to Swift, a previous fix that corrected magnetometer source to DeviceMotion
was reverted to using startMagnetometerUpdates()
.
This pull aims to restore the calibrated magnetometer readings that users are expecting.
As before, I have no way to test this code (no iOS device), and would appreciate someone's assitance in verifying the functionality.
Related Issues
- Fix #2655
- Refix #781
Checklist
- [x] I read the Contributor Guide and followed the process outlined there for submitting PRs.
- [x] I titled the PR using Conventional Commits.
- [x] I did not modify the
CHANGELOG.md
nor the plugin version inpubspec.yaml
files. - [x] All existing and new tests are passing.
- [x] The analyzer (
flutter analyze
) does not report any problems on my PR.
Breaking Change
Does your PR require plugin users to manually update their apps to accommodate your change?
- [ ] Yes, this is a breaking change (please indicate that with a
!
in the title as explained in Conventional Commits). - [x] No, this is not a breaking change.
- Fixes incorrect behavior with no API changes.