Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <project>/android/settings.gradle file
```
Expand Down Expand Up @@ -59,14 +59,24 @@ 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
```

2. Open the project -> Build Phases -> Link Binary With Libraries and select libRNReactNativeLocationSwitch.a



## React Native Interface

```javascript
Expand Down
10 changes: 5 additions & 5 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand All @@ -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'
}
12 changes: 6 additions & 6 deletions ios/RNReactNativeLocationSwitch.m
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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]]);
Expand Down
8 changes: 3 additions & 5 deletions ios/ReactNativeAndroidLocationSwitch.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,17 @@ 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


s.dependency "React"
#s.dependency "others"

end