Skip to content

Conversation

@OS-pedrogustavobilro
Copy link
Contributor

Description

This PR adds a new parameter interval to watchPosition in Android, to allow configuring specific intervals in which to receive location updates.

In version 7.1.x of the plugin, timeout was used for this purpose, which, even if documented, is prone to confusion.. Now we are applying the timeout parameter for its original purpose - to give a timeout error if a location isn't returned until the specified timeout value. This is implemented in the latest version of our Geolocation android native library (2.1.0).

To maintain backwards compatibility with versions 7.1.x, the default value of interval is that of timeout. Users should explicitly provide a different value (possibly lower than timeout) if they want to.

This is technically a breaking change (or has the potential to break client apps), as detailed below in this PR description.

This PR also contains updates the lockfiles to be npm instead of pnpm in this repo, because we have configured next peerDependency which does not work with pnpm.

Context

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)

BREAKING CHANGE: The timeout property now gets applied to all requests on Android on iOS, as opposed to just web and getCurrentPosition on Android. This aligns with what is documented in the plugin. If you are experiencing timeouts when requesting location in your app, consider using a higher timeout value. For watchPosition on Android, you may use the interval parameter introduced in version 8.0.0.

Platforms affected

  • Android
  • iOS
  • JavaScript

Tests

Use the example app in this repository to test - has a field for the new interval parameter.

Because we have "next" as `peerDependency` that causes pnpm install to fail

 `ERR_PNPM_INVALID_PEER_DEPENDENCY_SPECIFICATION  The peerDependencies field named '@capacitor/core' of package '@capacitor/geolocation' has an invalid value: 'next'`
Because the native Android library now applies the `timeout` explicitly to `addWatch`, we should allow consumers of this plugin to configure interval's to be lower that timeout, while leaving default value of `timeout` for backwards compatibility with versio 7.1.x

We document this as a breaking change, as it has the possibility of causing location timeouts where there previously were none. There was also an equivalent breaking change for iOS, in a previous PR.

References:

- https://outsystemsrd.atlassian.net/browse/RMET-4360
- https://outsystemsrd.atlassian.net/browse/RMET-4688
- #55

BREAKING CHANGE: The `timeout` property now gets applied to all requests on Android on iOS, as opposed to just web and `getCurrentPosition` on Android. This aligns with what is documented in the plugin. If you are experiencing timeouts when requesting location in your app, consider using a higher `timeout` value. For `watchPosition` on Android, you may use the `interval` parameter introduced in version 8.0.0.
Copy link
Contributor

@OS-ruimoreiramendes OS-ruimoreiramendes left a comment

Choose a reason for hiding this comment

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

Tested the example app in this repo and tried to repeat the same tests we did on iOS a few days/weeks ago, and it seems to be working fine.

@OS-pedrogustavobilro OS-pedrogustavobilro merged commit 7fda0cf into next Nov 21, 2025
8 checks passed
@OS-pedrogustavobilro OS-pedrogustavobilro deleted the feat/RMET-4688/android-timeout-interval branch November 21, 2025 09:21
OS-pedrogustavobilro added a commit that referenced this pull request Nov 21, 2025
# [8.0.0-next.7](v8.0.0-next.6...v8.0.0-next.7) (2025-11-21)

### Features

* **android:** New parameter `interval` in `watchPosition` ([#62](#62)) ([7fda0cf](7fda0cf))

### BREAKING CHANGES

* The `timeout` property now gets applied to all requests on Android on iOS, as opposed to just web and `getCurrentPosition` on Android. This aligns with what is documented in the plugin. If you are experiencing timeouts when requesting location in your app, consider using a higher `timeout` value. For `watchPosition` on Android, you may use the `interval` parameter introduced in version 8.0.0.
capacitor-bot pushed a commit that referenced this pull request Nov 26, 2025
# [8.0.0-next.6](v8.0.0-next.5...v8.0.0-next.6) (2025-11-26)

### Features

* **android:** New parameter `interval` in `watchPosition` ([#62](#62)) ([7fda0cf](7fda0cf))

### BREAKING CHANGES

* **android:** The `timeout` property now gets applied to all requests on Android on iOS, as opposed to just web and `getCurrentPosition` on Android. This aligns with what is documented in the plugin. If you are experiencing timeouts when requesting location in your app, consider using a higher `timeout` value. For `watchPosition` on Android, you may use the `interval` parameter introduced in version 8.0.0.
capacitor-bot pushed a commit that referenced this pull request Dec 8, 2025
# [8.0.0](v7.1.6...v8.0.0) (2025-12-08)

### Bug Fixes

* **android:** use 'propName = value' assignment syntax in build.gradle files ([08f311a](08f311a))
* **ios:** added timeout implementation for both getCurrentPosition and watchPosition ([#55](#55)) ([4c22ac3](4c22ac3))
* peerDependency for pnpm compatibility ([a94839d](a94839d))

### Features

* **android:** Fallback option for no network or Play Services ([#53](#53)) ([09277b7](09277b7))
* **android:** New parameter `interval` in `watchPosition` ([#62](#62)) ([7fda0cf](7fda0cf))
* Capacitor 8 support ([6ead26a](6ead26a))

### BREAKING CHANGES

* **android:** The `timeout` property now gets applied to all requests on Android on iOS, as opposed to just web and `getCurrentPosition` on Android. This aligns with what is documented in the plugin. If you are experiencing timeouts when requesting location in your app, consider using a higher `timeout` value. For `watchPosition` on Android, you may use the `interval` parameter introduced in version 8.0.0.
* Capacitor major version update requires major version update on the plugin.
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