diff --git a/README.md b/README.md index ed090ea..60a5971 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ A react Native module to enable location based services on Android and IOS. ## Installation Android -1. npm install react-native-location-switch +1. ```npm install react-native-location-switch``` 2. add the following 2 lines to your /android/settings.gradle file ``` @@ -59,7 +59,16 @@ A react Native module to enable location based services on Android and IOS. ## Installation IOS -1. Open the project in xCode, left click on the Libraries folder -> Add files to ... and select +Using Pods : + +1. add the following into your podfile : + ``` + pod 'ReactNativeAndroidLocationSwitch', :path => '../node_modules/react-native-location-switch/ios' + ``` + +Using xcode : + +1. Open the project in xCode, left click on the Libraries folder -> Add files to ... and select ``` ./node_modules/react-native-location-switch/ios/RNReactNativeLocationSwitch.xcodeproj ``` @@ -67,6 +76,7 @@ A react Native module to enable location based services on Android and IOS. 2. Open the project -> Build Phases -> Link Binary With Libraries and select libRNReactNativeLocationSwitch.a + ## React Native Interface ```javascript diff --git a/android/build.gradle b/android/build.gradle index b2aaa7b..3368ac4 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -20,12 +20,12 @@ buildscript { apply plugin: 'com.android.library' android { - compileSdkVersion 26 - buildToolsVersion "26.0.1" + compileSdkVersion 30 + buildToolsVersion "30.0.0" defaultConfig { minSdkVersion 16 - targetSdkVersion 26 + targetSdkVersion 30 versionCode 1 versionName computeVersionName() } @@ -40,6 +40,6 @@ repositories { dependencies { - compile 'com.facebook.react:react-native:+' - compile 'com.google.android.gms:play-services-location:11.0.0' + implementation 'com.facebook.react:react-native:+' + implementation 'com.google.android.gms:play-services-location:11.0.0' } diff --git a/ios/RNReactNativeLocationSwitch.m b/ios/RNReactNativeLocationSwitch.m index 9f5122e..f08f6de 100644 --- a/ios/RNReactNativeLocationSwitch.m +++ b/ios/RNReactNativeLocationSwitch.m @@ -20,15 +20,15 @@ - (dispatch_queue_t)methodQueue CLAuthorizationStatus status = [CLLocationManager authorizationStatus]; if (![CLLocationManager locationServicesEnabled]) { - [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"App-Prefs:root=Privacy&path=LOCATION"] options:@{} - completionHandler:^(BOOL success) {}]; + // redirect to the app settings page not the previously set "App-Prefs:root=Privacy&path=LOCATION" + // thus to avoid app rejection from the app store + [[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]]; } else if (status == kCLAuthorizationStatusDenied) { NSLog(@"Location Services Disabled"); - + // show location settings - [[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString] options:@{} - completionHandler:^(BOOL success) {}]; + [[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]]; } else { NSLog(@"Location Services Enabled"); @@ -42,7 +42,7 @@ - (dispatch_queue_t)methodQueue onLocationDisable:(RCTResponseSenderBlock)errorCallback) { CLAuthorizationStatus status = [CLLocationManager authorizationStatus]; - + if (![CLLocationManager locationServicesEnabled] || status == kCLAuthorizationStatusDenied) { NSLog(@"Location Services Disabled"); errorCallback(@[[NSNull null]]); diff --git a/ios/ReactNativeAndroidLocationSwitch.podspec b/ios/ReactNativeAndroidLocationSwitch.podspec index d4c08cb..cf330f4 100644 --- a/ios/ReactNativeAndroidLocationSwitch.podspec +++ b/ios/ReactNativeAndroidLocationSwitch.podspec @@ -6,13 +6,13 @@ Pod::Spec.new do |s| s.description = <<-DESC ReactNativeAndroidLocationSwitch DESC - s.homepage = "" + s.homepage = "https://github.com/philiWeitz/react-native-location-switch" s.license = "Apache-2.0" # s.license = { :type => "Apache-2.0", :file => "../LICENSE" } s.author = { "author" => "author@domain.cn" } - s.platform = :ios, "7.0" + s.platform = :ios, "8.0" s.source = { :git => "https://github.com/philiWeitz/react-native-android-location-switch.git", :tag => "master" } - s.source_files = "ReactNativeAndroidLocationSwitch/**/*.{h,m}" + s.source_files = "*.{h,m}" s.requires_arc = true @@ -20,5 +20,3 @@ Pod::Spec.new do |s| #s.dependency "others" end - - \ No newline at end of file