Skip to content

chore(geofence): add support for geofencing feature - #620

Merged
mahmoud-elmorabea merged 12 commits into
mainfrom
feature/geofence-on-device
Jul 30, 2026
Merged

chore(geofence): add support for geofencing feature#620
mahmoud-elmorabea merged 12 commits into
mainfrom
feature/geofence-on-device

Conversation

@mrehan27

@mrehan27 mrehan27 commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds on-device geofencing to the React Native SDK, merging feature/geofence-on-device into main. Ported to match the native iOS/Android and Flutter SDKs: an opt-in geofence module (implies Location), CustomerIO.geofence.refreshFromCurrentLocation() + locationMode config, iOS allowBackgroundDelivery, and example-app integration.

Changes

Includes previously approved/merged PRs (oldest first):

Note

Native version pins (iOS 4.7.0 / Android 4.20.0) land via #609 before this merges — do not merge until the geofence-enabled native SDKs are released.


Note

Medium Risk
Touches background location, geofence cold-wake bootstrap on iOS, and init ordering between location/geofence modules; behavior is gated behind opt-in flags but misconfiguration could affect privacy-sensitive location handling.

Overview
Adds an optional geofence module to the React Native SDK, aligned with the native iOS/Android and Flutter SDKs. Customers opt in at build time (customerio_geofence_enabled on Android, geofence CocoaPods subspec on iOS) and at runtime via a geofence block on CioConfig; enabling geofence also turns on Location (dependency + init wiring).

Public API: CustomerIO.geofence.refreshFromCurrentLocation(), CioGeofenceLocationMode (AUTOMATIC / MANUAL), and iOS-only ios.allowBackgroundDelivery (defaults on when geofence is configured). JS uses a new TurboModule spec; native bridges register the geofence module only when the feature flag is set.

Native init: Android and iOS register ModuleGeofence / GeofenceModule when geofence config is present, and auto-register Location when geofence is configured without explicit location config. iOS sample AppDelegate calls GeofenceModule.bootstrapForBackgroundDelivery for cold-wake delivery before JS starts.

Example app: Enables geofence in Gradle/Podfile, adds background-location permissions and UI on the location screen (state-aware “Always” / background grant + calls to refreshFromCurrentLocation), default geofence: {} in storage with merge-over-persisted config, and location tracking mode in settings.

Reviewed by Cursor Bugbot for commit 446e7af. Bugbot is set up for automated code reviews on this repo. Configure here.

mrehan27 and others added 8 commits June 27, 2026 01:56
Wire the optional geofence module without enabling behavior yet:
build flags (customerio_geofence_enabled gradle property, geofence
podspec subspec), the geofence opt-in config key, and the exported
CustomerIOGeofence class. Enabling geofence also pulls in Location,
which geofence depends on, and turns on the Location build flag on both
platforms so geofence-only builds get the full Location module.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…tion (#612)

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…n screen (#614)

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@mrehan27
mrehan27 requested a review from a team as a code owner July 25, 2026 09:46
@mrehan27 mrehan27 self-assigned this Jul 25, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Sample app builds 📱

Below you will find the list of the latest versions of the sample apps. It's recommended to always download the latest builds of the sample apps to accurately test the pull request.


Comment thread ios/wrappers/NativeCustomerIO.swift
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 040e30c. Configure here.

static func module(from config: [String: Any], geofenceEnabled: Bool = false) -> LocationModule? {
let locationConfig = config["location"] as? [String: Any]
guard locationConfig != nil || geofenceEnabled else { return nil }
let trackingModeValue = locationConfig?["trackingMode"] as? String

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Geofence with location off

Medium Severity

When geofence is configured alongside location.trackingMode set to OFF, initialization still registers the location module in off mode and adds geofence. Geofence depends on location fixes, so monitoring can appear enabled while the location module will not supply them.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 040e30c. Configure here.

mrehan27 and others added 2 commits July 30, 2026 18:02
Geofence is a compileOnly dependency when disabled, but
NativeGeofenceModule always compiles, so its io.customer.geofence
references reach R8 with the classes absent — same as location.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Live Notifications and geofence add parallel modules, so every conflict
resolved as keep-both:

- CustomerIOReactNativePackage.kt: both module imports
- NativeCustomerIO.swift: register both modules, geofence keeps its
  allowBackgroundDelivery default
- customerio-reactnative.podspec: both optional subspecs
- example Podfile / storage.ts: sample app opts into both
- data-pipelines.ts: both config blocks on CioConfig
- api report regenerated with api-extractor

Both sides had already bumped the natives to the same versions
(Android 4.20.0 / iOS 4.7.0), so those merged clean.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@mahmoud-elmorabea
mahmoud-elmorabea merged commit cb2b9f8 into main Jul 30, 2026
11 checks passed
@mahmoud-elmorabea
mahmoud-elmorabea deleted the feature/geofence-on-device branch July 30, 2026 14:00
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.

2 participants