From 5dcd0827e56f0624c93b424acca73d17200ec46a Mon Sep 17 00:00:00 2001 From: Joon Son Date: Mon, 4 Nov 2024 12:39:51 -0800 Subject: [PATCH 1/3] Add support for tvOS --- ios/RNCGeolocation.mm | 12 ++++++------ react-native-geolocation.podspec | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/ios/RNCGeolocation.mm b/ios/RNCGeolocation.mm index 03df64d..a78ce09 100644 --- a/ios/RNCGeolocation.mm +++ b/ios/RNCGeolocation.mm @@ -190,7 +190,7 @@ - (void)beginLocationUpdatesWithDesiredAccuracy:(CLLocationAccuracy)desiredAccur if (@available(iOS 14.0, *)) { if ( -#if ! TARGET_OS_VISION +#if ! TARGET_OS_VISION && !TARGET_OS_TV _lastUpdatedAuthorizationStatus == kCLAuthorizationStatusAuthorizedAlways || #endif _lastUpdatedAuthorizationStatus == kCLAuthorizationStatusAuthorizedWhenInUse @@ -204,7 +204,7 @@ - (void)beginLocationUpdatesWithDesiredAccuracy:(CLLocationAccuracy)desiredAccur - (void)startMonitoring { -#if !TARGET_OS_VISION +#if !TARGET_OS_VISION && !TARGET_OS_TV _usingSignificantChanges ? [_locationManager startMonitoringSignificantLocationChanges] : [_locationManager startUpdatingLocation]; @@ -215,7 +215,7 @@ - (void)startMonitoring - (void)stopMonitoring { -#if !TARGET_OS_VISION +#if !TARGET_OS_VISION && !TARGET_OS_TV _usingSignificantChanges ? [_locationManager stopMonitoringSignificantLocationChanges] : [_locationManager stopUpdatingLocation]; @@ -283,7 +283,7 @@ - (void)timeout:(NSTimer *)timer // Request location access permission if (wantsAlways) { -#if !TARGET_OS_VISION +#if !TARGET_OS_VISION && !TARGET_OS_TV [_locationManager requestAlwaysAuthorization]; [self enableBackgroundLocationUpdates]; #endif @@ -294,7 +294,7 @@ - (void)timeout:(NSTimer *)timer - (void)enableBackgroundLocationUpdates { -#if !TARGET_OS_VISION +#if !TARGET_OS_VISION && !TARGET_OS_TV // iOS 9+ requires explicitly enabling background updates NSArray *backgroundModes = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"UIBackgroundModes"]; if (backgroundModes && [backgroundModes containsObject:@"location"]) { @@ -473,7 +473,7 @@ - (void)locationManagerDidChangeAuthorization:(CLLocationManager *)manager } if ( -#if !TARGET_OS_VISION +#if !TARGET_OS_VISION && !TARGET_OS_TV currentStatus == kCLAuthorizationStatusAuthorizedAlways || #endif currentStatus == kCLAuthorizationStatusAuthorizedWhenInUse diff --git a/react-native-geolocation.podspec b/react-native-geolocation.podspec index df45e6d..32da249 100644 --- a/react-native-geolocation.podspec +++ b/react-native-geolocation.podspec @@ -10,7 +10,7 @@ Pod::Spec.new do |s| s.authors = package['author'] s.homepage = package['homepage'] - s.platforms = { :ios => '9.0', :visionos => '1.0' } + s.platforms = { :ios => '9.0', :tvos => '9.0', :visionos => '1.0' } s.source = { :git => "https://github.com/react-native-community/react-native-geolocation.git", :tag => "v#{s.version}" } s.source_files = "ios/**/*.{h,m,mm}" From 751a7a4c22f0c1a7c31d14ebd47bc8741230e72a Mon Sep 17 00:00:00 2001 From: Joon Son Date: Mon, 4 Nov 2024 17:18:46 -0800 Subject: [PATCH 2/3] update some functions that are not available on tvOS --- ios/RNCGeolocation.mm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ios/RNCGeolocation.mm b/ios/RNCGeolocation.mm index a78ce09..b11299b 100644 --- a/ios/RNCGeolocation.mm +++ b/ios/RNCGeolocation.mm @@ -208,7 +208,7 @@ - (void)startMonitoring _usingSignificantChanges ? [_locationManager startMonitoringSignificantLocationChanges] : [_locationManager startUpdatingLocation]; -#else +#elif !TARGET_OS_TV [_locationManager startUpdatingLocation]; #endif } @@ -219,7 +219,7 @@ - (void)stopMonitoring _usingSignificantChanges ? [_locationManager stopMonitoringSignificantLocationChanges] : [_locationManager stopUpdatingLocation]; -#else +#elif !TARGET_OS_TV [_locationManager stopUpdatingLocation]; #endif } From 39895589c9aa9cd4bb7450641fe06cf00cf3b2e6 Mon Sep 17 00:00:00 2001 From: Joon Son Date: Mon, 4 Nov 2024 17:20:28 -0800 Subject: [PATCH 3/3] remove space --- ios/RNCGeolocation.mm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ios/RNCGeolocation.mm b/ios/RNCGeolocation.mm index b11299b..8be6577 100644 --- a/ios/RNCGeolocation.mm +++ b/ios/RNCGeolocation.mm @@ -190,7 +190,7 @@ - (void)beginLocationUpdatesWithDesiredAccuracy:(CLLocationAccuracy)desiredAccur if (@available(iOS 14.0, *)) { if ( -#if ! TARGET_OS_VISION && !TARGET_OS_TV +#if !TARGET_OS_VISION && !TARGET_OS_TV _lastUpdatedAuthorizationStatus == kCLAuthorizationStatusAuthorizedAlways || #endif _lastUpdatedAuthorizationStatus == kCLAuthorizationStatusAuthorizedWhenInUse