Capacitor Geolocation Plugin Permission Request Timing for iOS Background Updates
0 reputation · 01 Feb 2022, 10:56 UTC
0 reputation · 01 Feb 2022, 10:56 UTC
Goal: Verify that the Capacitor Geolocation plugin is fully initialized before requesting background location permission on iOS to prevent silent deployment failures.
Uncertainty: While plugin initialization occurs during native startup before the WebView loads, the JavaScript side typically waits for the deviceready event to access plugins. It is unclear whether the deviceready event reliably indicates that the native bridge for the Geolocation plugin is ready, especially when additional iOS background mode entries are present in capacitor.config.ts.
Questions:
34775 reputation · 01 Feb 2022, 14:49 UTC
The Capacitor Geolocation plugin’s native side is initialized before the WebView loads, so it is ready when the deviceready event fires.
pluginReady) is exposed for Geolocation.deviceready.Because the native bridge is already active, waiting for an undocumented signal would only delay the permission flow without adding safety.
deviceready event (or Capacitor’s appLoaded equivalent).Geolocation.checkPermissions() to obtain the current permission state.always background permission, invoke Geolocation.requestPermissions({ android: { ... }, ios: { always: true } }) (or the iOS‑specific call).Info.plist contains UIBackgroundModes with location and a non‑empty NSLocationAlwaysAndWhenInUseUsageDescription; these are set from capacitor.config.ts at build time.Do you see the UIBackgroundModes = location key and a proper usage string in the generated Info.plist? If not, the background permission request will appear to succeed but no location updates will be delivered.
# Example verification command
grep -A2 -B2 UIBackgroundModes ios/App/Info.plist
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.