Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RMET-3900 :: bridge :: add getCurrentPosition wrapper for both capacitor and cordova #1

Open
wants to merge 5 commits into
base: development
Choose a base branch
from

Conversation

OS-martacarlos
Copy link
Collaborator

Description

This PR provides a wrapper to the plugin, adding timeout logic for getCurrentPosition.
The main goal is to use this code inside the OutSystems Plugin, but it can also be used outside of it. I
As it already uses CapacitorUtils.Synapse it's ready for both cordova and capacitor plugins.

It can also detect if an old build of the plugin is being used (aka the old cordova-geolocation-plugin)

Type of changes

  • Fix (non-breaking change which fixes an issue)
  • Feature (non-breaking change which adds functionality)
  • Refactor (cosmetic changes)
  • Breaking change (change that would cause existing functionality to not work as expected)

Platforms affected

  • Android
  • iOS
  • JavaScript

Screenshots (if appropriate)

Screenshot 2024-12-19 at 17 46 09

Checklist

  • Pull request title follows the format RNMT-XXXX <title>
  • Code follows code style of this project
  • CHANGELOG.md file is correctly updated
  • Changes require an update to the documentation
    • Documentation has been updated accordingly

@OS-martacarlos OS-martacarlos requested a review from a team December 19, 2024 17:48
@OS-martacarlos OS-martacarlos self-assigned this Dec 19, 2024
Comment on lines +5 to +24
export type OSGLOCPosition = {
timestamp: number;
latitude: number;
longitude: number;
accuracy: number;
altitude: number | null;
speed: number | null;
heading: number | null;
altitudeAccuracy: number | null;
};
export type LegacyOSPosition = {
timestamp: number;
latitude: number;
longitude: number;
accuracy: number;
altitudeAccuracy: number | null | undefined;
altitude: number | null;
velocity: number | null;
heading: number | null;
};

Choose a reason for hiding this comment

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

Do we need both? They are identical so I was wondering if we could reuse one of them.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

should be fixed!

@OS-martacarlos OS-martacarlos force-pushed the feat/RMET-3900/get-location branch from 81e3eb1 to 1fa586f Compare December 20, 2024 11:26
Comment on lines +41 to +42
if (this.#lastPosition && options.maximumAge && (((new Date()).getTime() - this.#lastPosition.timestamp) <= options.maximumAge)) {
success(this.#lastPosition);

Choose a reason for hiding this comment

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

I see this was taken from how the cordova plugin was setup - but On Android, this logic is being managed by the actual FusedLocationProviderClient. I don't know how it is on iOS, but if there is analagous logic, perhaps there is no need to store the lastPosition in this wrapper.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I checked with @OS-ricardomoreirasilva and iOS does not have this logic, so it needs to exist here

packages/capacitor-plugin/src/web.ts Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants