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: 7 additions & 7 deletions android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import groovy.json.JsonSlurper


def computeVersionName() {
// dynamically retrieve version from package.json
def slurper = new JsonSlurper()
def json = slurper.parse(file('../package.json'), "utf-8")
return json.version
Expand All @@ -20,12 +20,12 @@ buildscript {
apply plugin: 'com.android.library'

android {
compileSdkVersion 26
buildToolsVersion "26.0.1"
compileSdkVersion 28
buildToolsVersion "28.0.3"

defaultConfig {
minSdkVersion 16
targetSdkVersion 26
minSdkVersion 19
targetSdkVersion 28
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'
}
43 changes: 20 additions & 23 deletions ios/RNReactNativeLocationSwitch.m
Original file line number Diff line number Diff line change
@@ -1,53 +1,50 @@

#import "RNReactNativeLocationSwitch.h"
#import "UIKit/UIKit.h"
#import <Foundation/NSURL.h>
#import <CoreLocation/CoreLocation.h>


@implementation RNReactNativeLocationSwitch

- (dispatch_queue_t)methodQueue
{
- (dispatch_queue_t)methodQueue {
return dispatch_get_main_queue();
}
RCT_EXPORT_MODULE()

RCT_EXPORT_MODULE()

RCT_REMAP_METHOD(enableLocationService,
onPermissionGiven:(RCTResponseSenderBlock)successCallback
onPermissionDenied:(RCTResponseSenderBlock)errorCallback)
{
onPermissionDenied:(RCTResponseSenderBlock)errorCallback) {
CLAuthorizationStatus status = [CLLocationManager authorizationStatus];

if (![CLLocationManager locationServicesEnabled]) {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"App-Prefs:root=Privacy&path=LOCATION"] options:@{}
completionHandler:^(BOOL success) {}];

} else if (status == kCLAuthorizationStatusDenied) {
NSLog(@"Location Services Disabled");

if (![CLLocationManager locationServicesEnabled] || status == kCLAuthorizationStatusDenied) {
NSURL *serviceURL = [NSURL URLWithString:UIApplicationOpenSettingsURLString];

// show location settings
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString] options:@{}
completionHandler:^(BOOL success) {}];

} else {
NSLog(@"Location Services Enabled");
if ([[UIApplication sharedApplication] canOpenURL:serviceURL]) {
if (@available(iOS 10.0, *)) {
[[UIApplication sharedApplication] openURL:serviceURL options:@{} completionHandler:^(BOOL success) {}];
} else {
[[UIApplication sharedApplication] openURL:serviceURL];
}
}
else {
errorCallback(@[[NSNull null]]);
}
}
else {
successCallback(@[[NSNull null]]);
}
}


RCT_REMAP_METHOD(isLocationEnabled,
onLocationEnabled:(RCTResponseSenderBlock)successCallback
onLocationDisable:(RCTResponseSenderBlock)errorCallback)
{
onLocationDisable:(RCTResponseSenderBlock)errorCallback) {
CLAuthorizationStatus status = [CLLocationManager authorizationStatus];

if (![CLLocationManager locationServicesEnabled] || status == kCLAuthorizationStatusDenied) {
NSLog(@"Location Services Disabled");
errorCallback(@[[NSNull null]]);
} else {
NSLog(@"Location Services Enabled");
successCallback(@[[NSNull null]]);
}
}
Expand Down
23 changes: 21 additions & 2 deletions ios/RNReactNativeLocationSwitch.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
58B511D31A9E6C8500147676 /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0830;
LastUpgradeCheck = 1030;
ORGANIZATIONNAME = Facebook;
TargetAttributes = {
58B511DA1A9E6C8500147676 = {
Expand All @@ -93,10 +93,11 @@
};
buildConfigurationList = 58B511D61A9E6C8500147676 /* Build configuration list for PBXProject "RNReactNativeLocationSwitch" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
developmentRegion = en;
hasScannedForEncodings = 0;
knownRegions = (
en,
Base,
);
mainGroup = 58B511D21A9E6C8500147676;
productRefGroup = 58B511D21A9E6C8500147676;
Expand Down Expand Up @@ -124,18 +125,27 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
Expand Down Expand Up @@ -172,18 +182,27 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
Expand Down
24 changes: 0 additions & 24 deletions ios/ReactNativeAndroidLocationSwitch.podspec

This file was deleted.

22 changes: 22 additions & 0 deletions ios/react-native-location-switch.podspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
require 'json'

package = JSON.parse(File.read(File.join(__dir__, '../package.json')))


Pod::Spec.new do |s|
s.authors = package['author']
s.homepage = package['homepage']
s.license = package['license']
s.name = package['name']
s.summary = package['description']
s.version = package['version']

s.platform = :ios, "8.0"
s.requires_arc = true
s.source = { :git => "https://github.com/philiWeitz/react-native-android-location-switch.git", :tag => "master" }
s.source_files = "*.{h,m}"

s.dependency 'React'


end
22 changes: 12 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,25 +1,27 @@
{
"name": "react-native-location-switch",
"version": "0.1.0",
"author": "Philipp Weitz",
"private": false,
"license": "Apache-2.0",
"nativePackage": true,
"repository": {
"type": "git",
"url": "https://github.com/philiWeitz/react-native-location-switch.git"
},
"bugs": {
"url": "https://github.com/philiWeitz/react-native-location-switch/issues"
},
"description": "A React Native module that allows you to verify the status of the device's location services.",
"homepage": "https://github.com/philiWeitz/react-native-location-switch",
"license": "Apache-2.0",
"keywords": [
"react-native",
"android",
"ios",
"library",
"location"
],
"name": "react-native-location-switch",
"nativePackage": true,
"peerDependencies": {
"react-native": ">= 0.38.0"
}
},
"private": false,
"repository": {
"type": "git",
"url": "https://github.com/philiWeitz/react-native-location-switch.git"
},
"version": "0.1.1"
}