Skip to content

Commit

Permalink
fix(macCatalyst): add compilation conditionals for macCatalyst (#629)
Browse files Browse the repository at this point in the history
  • Loading branch information
zhumingcheng697 committed Oct 2, 2022
1 parent fbb9182 commit 8e4cace
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
12 changes: 6 additions & 6 deletions ios/RNCConnectionState.m
Expand Up @@ -6,11 +6,11 @@
*/

#import "RNCConnectionState.h"
#if !TARGET_OS_TV
#if !TARGET_OS_TV && !TARGET_OS_MACCATALYST
#import <CoreTelephony/CTTelephonyNetworkInfo.h>
#endif

#if TARGET_OS_TV || TARGET_OS_OSX
#if TARGET_OS_TV || TARGET_OS_OSX || TARGET_OS_MACCATALYST
#include <ifaddrs.h>
#endif

Expand All @@ -36,16 +36,16 @@ - (instancetype)initWithReachabilityFlags:(SCNetworkReachabilityFlags)flags
_type = RNCConnectionTypeUnknown;
_cellularGeneration = nil;
_expensive = false;

if ((flags & kSCNetworkReachabilityFlagsReachable) == 0 ||
(flags & kSCNetworkReachabilityFlagsConnectionRequired) != 0) {
_type = RNCConnectionTypeNone;
}
#if !TARGET_OS_TV && !TARGET_OS_OSX
#if !TARGET_OS_TV && !TARGET_OS_OSX && !TARGET_OS_MACCATALYST
else if ((flags & kSCNetworkReachabilityFlagsIsWWAN) != 0) {
_type = RNCConnectionTypeCellular;
_expensive = true;

CTTelephonyNetworkInfo *netinfo = [[CTTelephonyNetworkInfo alloc] init];
if (netinfo) {
if ([netinfo.currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyGPRS] ||
Expand Down Expand Up @@ -73,7 +73,7 @@ - (instancetype)initWithReachabilityFlags:(SCNetworkReachabilityFlags)flags
#endif
else {
_type = RNCConnectionTypeWifi;
#if TARGET_OS_TV || TARGET_OS_OSX
#if TARGET_OS_TV || TARGET_OS_OSX || TARGET_OS_MACCATALYST
struct ifaddrs *interfaces = NULL;
struct ifaddrs *temp_addr = NULL;
int success = 0;
Expand Down
8 changes: 4 additions & 4 deletions ios/RNCNetInfo.m
Expand Up @@ -11,7 +11,7 @@
#include <ifaddrs.h>
#include <arpa/inet.h>

#if !TARGET_OS_TV
#if !TARGET_OS_TV && !TARGET_OS_MACCATALYST
#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
#if !TARGET_OS_TV && !TARGET_OS_OSX && !TARGET_OS_MACCATALYST
/*
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)
#if (TARGET_OS_TV || TARGET_OS_OSX || TARGET_OS_MACCATALYST)
return nil;
#else
CTTelephonyNetworkInfo *netinfo = [[CTTelephonyNetworkInfo alloc] init];
Expand Down Expand Up @@ -227,7 +227,7 @@ - (NSString *)subnet
return subnet;
}

#if !TARGET_OS_TV && !TARGET_OS_OSX
#if !TARGET_OS_TV && !TARGET_OS_OSX && !TARGET_OS_MACCATALYST
- (NSString *)ssid
{
NSArray *interfaceNames = CFBridgingRelease(CNCopySupportedInterfaces());
Expand Down

0 comments on commit 8e4cace

Please sign in to comment.