diff --git a/CHANGELOG.md b/CHANGELOG.md index 1b61c3ed..03cbf0ea 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +# [11.3.0](https://github.com/react-native-netinfo/react-native-netinfo/compare/v11.2.1...v11.3.0) (2024-02-14) + + +### Features + +* add visionOS support ([#714](https://github.com/react-native-netinfo/react-native-netinfo/issues/714)) ([65ffc48](https://github.com/react-native-netinfo/react-native-netinfo/commit/65ffc48)) + ## [11.2.1](https://github.com/react-native-netinfo/react-native-netinfo/compare/v11.2.0...v11.2.1) (2023-12-12) diff --git a/ios/RNCConnectionState.m b/ios/RNCConnectionState.m index 431e0ccc..5a807a4d 100644 --- a/ios/RNCConnectionState.m +++ b/ios/RNCConnectionState.m @@ -6,11 +6,11 @@ */ #import "RNCConnectionState.h" -#if !TARGET_OS_TV && !TARGET_OS_MACCATALYST +#if !TARGET_OS_TV && !TARGET_OS_MACCATALYST && !TARGET_OS_VISION #import #endif -#if TARGET_OS_TV || TARGET_OS_OSX || TARGET_OS_MACCATALYST +#if TARGET_OS_TV || TARGET_OS_OSX || TARGET_OS_MACCATALYST || TARGET_OS_VISION #include #endif @@ -41,7 +41,7 @@ - (instancetype)initWithReachabilityFlags:(SCNetworkReachabilityFlags)flags (flags & kSCNetworkReachabilityFlagsConnectionRequired) != 0) { _type = RNCConnectionTypeNone; } -#if !TARGET_OS_TV && !TARGET_OS_OSX && !TARGET_OS_MACCATALYST +#if !TARGET_OS_TV && !TARGET_OS_OSX && !TARGET_OS_MACCATALYST && !TARGET_OS_VISION else if ((flags & kSCNetworkReachabilityFlagsIsWWAN) != 0) { _type = RNCConnectionTypeCellular; _expensive = true; @@ -73,7 +73,7 @@ - (instancetype)initWithReachabilityFlags:(SCNetworkReachabilityFlags)flags #endif else { _type = RNCConnectionTypeWifi; -#if TARGET_OS_TV || TARGET_OS_OSX || TARGET_OS_MACCATALYST +#if TARGET_OS_TV || TARGET_OS_OSX || TARGET_OS_MACCATALYST || TARGET_OS_VISION struct ifaddrs *interfaces = NULL; struct ifaddrs *temp_addr = NULL; int success = 0; diff --git a/ios/RNCNetInfo.m b/ios/RNCNetInfo.m index e83b8c40..ee759ba0 100644 --- a/ios/RNCNetInfo.m +++ b/ios/RNCNetInfo.m @@ -11,7 +11,7 @@ #include #include -#if !TARGET_OS_TV && !TARGET_OS_MACCATALYST +#if !TARGET_OS_TV && !TARGET_OS_MACCATALYST && !TARGET_OS_VISION #import #import #endif @@ -130,7 +130,7 @@ - (NSMutableDictionary *)detailsFromInterface:(nonnull NSString *)requestedInter } else if ([requestedInterface isEqualToString: RNCConnectionTypeWifi] || [requestedInterface isEqualToString: RNCConnectionTypeEthernet]) { details[@"ipAddress"] = [self ipAddress] ?: NSNull.null; details[@"subnet"] = [self subnet] ?: NSNull.null; - #if !TARGET_OS_TV && !TARGET_OS_OSX && !TARGET_OS_MACCATALYST + #if !TARGET_OS_TV && !TARGET_OS_OSX && !TARGET_OS_MACCATALYST && !TARGET_OS_VISION /* Without one of the conditions needed to use CNCopyCurrentNetworkInfo, it will leak memory. Clients should only set the shouldFetchWiFiSSID to true after ensuring requirements are met to get (B)SSID. @@ -146,7 +146,7 @@ Clients should only set the shouldFetchWiFiSSID to true after ensuring requireme - (NSString *)carrier { -#if (TARGET_OS_TV || TARGET_OS_OSX || TARGET_OS_MACCATALYST) +#if (TARGET_OS_TV || TARGET_OS_OSX || TARGET_OS_MACCATALYST || TARGET_OS_VISION) return nil; #else CTTelephonyNetworkInfo *netinfo = [[CTTelephonyNetworkInfo alloc] init]; diff --git a/package.json b/package.json index 3c80db27..2c3f71b3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@react-native-community/netinfo", - "version": "11.2.1", + "version": "11.3.0", "description": "React Native Network Info API for iOS & Android", "react-native": "src/index.ts", "types": "lib/typescript/src/index.d.ts", diff --git a/react-native-netinfo.podspec b/react-native-netinfo.podspec index e34e728d..ccd671f4 100644 --- a/react-native-netinfo.podspec +++ b/react-native-netinfo.podspec @@ -10,7 +10,7 @@ Pod::Spec.new do |s| s.authors = package['author'] s.homepage = package['homepage'] - s.platforms = { :ios => "9.0", :tvos => "9.2", :osx => "10.14" } + s.platforms = { :ios => "9.0", :tvos => "9.2", :osx => "10.14", :visionos => "1.0" } s.source = { :git => "https://github.com/react-native-community/react-native-netinfo.git", :tag => "v#{s.version}" } s.source_files = "ios/**/*.{h,m}" diff --git a/src/internal/internetReachability.ts b/src/internal/internetReachability.ts index 5cf797b2..757d784a 100644 --- a/src/internal/internetReachability.ts +++ b/src/internal/internetReachability.ts @@ -79,9 +79,9 @@ export default class InternetReachability { // Create promise that will reject after the request timeout has been reached let timeoutHandle: ReturnType; - const timeoutPromise = new Promise((): void => { + const timeoutPromise = new Promise((_, reject): void => { timeoutHandle = setTimeout( - (): void => controller.abort('timedout'), + (): void => reject('timedout'), this._configuration.reachabilityRequestTimeout, ); }); @@ -120,6 +120,10 @@ export default class InternetReachability { if ('canceled' === error) { controller.abort(); } else { + if ('timedout' === error) { + controller.abort(); + } + this._setIsInternetReachable(false); this._currentTimeoutHandle = setTimeout( this._checkInternetReachability,