Skip to content

Commit

Permalink
feat: add visionOS support (#714)
Browse files Browse the repository at this point in the history
  • Loading branch information
thiagobrez committed Feb 14, 2024
1 parent 30d8931 commit 65ffc48
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions ios/RNCConnectionState.m
Expand Up @@ -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 <CoreTelephony/CTTelephonyNetworkInfo.h>
#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 <ifaddrs.h>
#endif

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions ios/RNCNetInfo.m
Expand Up @@ -11,7 +11,7 @@
#include <ifaddrs.h>
#include <arpa/inet.h>

#if !TARGET_OS_TV && !TARGET_OS_MACCATALYST
#if !TARGET_OS_TV && !TARGET_OS_MACCATALYST && !TARGET_OS_VISION
#import <CoreTelephony/CTCarrier.h>
#import <CoreTelephony/CTTelephonyNetworkInfo.h>
#endif
Expand Down Expand Up @@ -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.
Expand All @@ -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];
Expand Down
2 changes: 1 addition & 1 deletion react-native-netinfo.podspec
Expand Up @@ -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}"
Expand Down

0 comments on commit 65ffc48

Please sign in to comment.