From 7241dd80e81c440d7fac301ad66595d6fa37f41c Mon Sep 17 00:00:00 2001 From: Muhammad Rehan Date: Sat, 25 Jul 2026 15:01:58 +0500 Subject: [PATCH] fix: gate iOS geofence enablement on a dictionary config The geofence enablement checks used key presence (config["geofence"] != nil) while NativeGeofence.module(from:) only builds the module for a dictionary value. A non-map geofence value (e.g. null bridged from JS) would enable the implied Location module and default allowBackgroundDelivery on without adding the geofence module. Both checks now use the same `as? [String: Any]` cast. Android already gates on getTypedValue>, so no change there. Co-Authored-By: Claude Opus 4.8 (1M context) --- ios/wrappers/NativeCustomerIO.swift | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/ios/wrappers/NativeCustomerIO.swift b/ios/wrappers/NativeCustomerIO.swift index db04dd4d..9bc0d94a 100644 --- a/ios/wrappers/NativeCustomerIO.swift +++ b/ios/wrappers/NativeCustomerIO.swift @@ -53,7 +53,9 @@ public class NativeCustomerIO: NSObject { // config is provided or geofence is enabled, since geofence relies on the // location module's fixes. #if CIO_GEOFENCE_ENABLED - let geofenceConfigured = config["geofence"] != nil + // Match NativeGeofence.module(from:): only a dictionary counts as configured, + // so a non-map value (e.g. null bridged from JS) doesn't imply location. + let geofenceConfigured = config["geofence"] as? [String: Any] != nil #else let geofenceConfigured = false #endif @@ -71,7 +73,9 @@ public class NativeCustomerIO: NSObject { // Customer value wins; default on when the geofence module is added, off otherwise. #if CIO_GEOFENCE_ENABLED - let geofenceAdded = config["geofence"] != nil + // Match NativeGeofence.module(from:): only a dictionary adds the module, so + // background delivery shouldn't default on for a non-map geofence value. + let geofenceAdded = config["geofence"] as? [String: Any] != nil #else let geofenceAdded = false #endif