ilabs-flir 2.1.1 → 2.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -156,6 +156,39 @@ RCT_EXPORT_METHOD(removeListeners:(NSInteger)count) {
156
156
 
157
157
  #pragma mark - Discovery Methods
158
158
 
159
+ // Network discovery on iOS 14+ requires Local Network privacy keys.
160
+ // In USB/Bluetooth-only builds (or when the user denied permission), attempting
161
+ // Bonjour discovery can fail noisily or crash depending on SDK internals.
162
+ // We default to enabling network discovery only when the host app declares
163
+ // NSLocalNetworkUsageDescription, and allow an explicit override via
164
+ // setNetworkDiscoveryEnabled.
165
+ - (BOOL)shouldEnableNetworkDiscovery {
166
+ // Explicit override if app sets it.
167
+ NSString *key = @"ilabsFlir.networkDiscoveryEnabled";
168
+ NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
169
+ if ([defaults objectForKey:key] != nil) {
170
+ return [defaults boolForKey:key];
171
+ }
172
+
173
+ // Safe default: require Local Network usage description to be present.
174
+ id desc = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"NSLocalNetworkUsageDescription"];
175
+ if ([desc isKindOfClass:[NSString class]] && ((NSString *)desc).length > 0) {
176
+ return YES;
177
+ }
178
+ return NO;
179
+ }
180
+
181
+ RCT_EXPORT_METHOD(setNetworkDiscoveryEnabled:(BOOL)enabled
182
+ resolver:(RCTPromiseResolveBlock)resolve
183
+ rejecter:(RCTPromiseRejectBlock)reject) {
184
+ #if FLIR_SDK_AVAILABLE
185
+ [[NSUserDefaults standardUserDefaults] setBool:enabled forKey:@"ilabsFlir.networkDiscoveryEnabled"];
186
+ resolve(@(YES));
187
+ #else
188
+ resolve(@(YES));
189
+ #endif
190
+ }
191
+
159
192
  RCT_EXPORT_METHOD(startDiscovery:(RCTPromiseResolveBlock)resolve
160
193
  rejecter:(RCTPromiseRejectBlock)reject) {
161
194
  #if FLIR_SDK_AVAILABLE
@@ -197,11 +230,18 @@ RCT_EXPORT_METHOD(startDiscovery:(RCTPromiseResolveBlock)resolve
197
230
  self.discovery.delegate = self;
198
231
  }
199
232
 
200
- // Start discovery on all available interfaces
233
+ // Start discovery on allowed interfaces.
234
+ // Always include wired/BLE/emulator. Only include network when the app has
235
+ // Local Network usage description (or the app explicitly enabled it).
201
236
  FLIRCommunicationInterface interfaces = FLIRCommunicationInterfaceLightning |
202
- FLIRCommunicationInterfaceNetwork |
203
237
  FLIRCommunicationInterfaceFlirOneWireless |
204
- FLIRCommunicationInterfaceEmulator;
238
+ FLIRCommunicationInterfaceEmulator |
239
+ FLIRCommunicationInterfaceUSB;
240
+ if ([self shouldEnableNetworkDiscovery]) {
241
+ interfaces |= FLIRCommunicationInterfaceNetwork;
242
+ } else {
243
+ RCTLogInfo(@"[FlirModule] Network discovery disabled (missing NSLocalNetworkUsageDescription or overridden)");
244
+ }
205
245
  [self.discovery start:interfaces];
206
246
 
207
247
  [self emitStateChange:@"discovering"];
@@ -821,8 +861,15 @@ RCT_EXPORT_METHOD(isPreferSdkRotation:(RCTPromiseResolveBlock)resolve
821
861
  }
822
862
 
823
863
  - (void)discoveryError:(NSString *)error netServiceError:(int)nsnetserviceserror on:(FLIRCommunicationInterface)iface {
864
+ // Network discovery failures are expected when Local Network permission is missing/denied.
865
+ // Do not surface those as fatal errors; keep USB/BLE discovery running.
866
+ if ((iface & FLIRCommunicationInterfaceNetwork) == FLIRCommunicationInterfaceNetwork) {
867
+ RCTLogInfo(@"[FlirModule] Network discovery error (suppressed): %@ (%d)", error, nsnetserviceserror);
868
+ return;
869
+ }
870
+
824
871
  RCTLogError(@"[FlirModule] Discovery error: %@ (%d)", error, nsnetserviceserror);
825
-
872
+
826
873
  dispatch_async(dispatch_get_main_queue(), ^{
827
874
  [[FlirEventEmitter shared] sendDeviceEvent:@"FlirError" body:@{
828
875
  @"error": error ?: @"Unknown discovery error",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ilabs-flir",
3
- "version": "2.1.1",
3
+ "version": "2.1.2",
4
4
  "description": "FLIR Thermal SDK for React Native - iOS & Android (bundled at compile time via postinstall)",
5
5
  "main": "src/index.js",
6
6
  "types": "src/index.d.ts",