Skip to content

Commit

Permalink
Fixed 'Always Allow' for iOS (Path-Check#97)
Browse files Browse the repository at this point in the history
* 1. Added RN permissions to dependencies.
2. Added location permissions in AndroidManifest.xml

* 1. Permissions now handled by react-native-permissions
2. If platform is iOS 12.x.x or earlier. Directly acquire 'Always Allow' permission
3. If platform is iOS 13.0 or later, redirect to app settings.
Apps cannot directly ask for 'Always Allow' post iOS 13.

* Added comments

* Added yarn.lock and Podfile.lock to gitignore

* No changes

* Added lock files

* Removed Podfile.lock

Co-authored-by: Rich Paret <623643+rparet@users.noreply.github.com>
Co-authored-by: Abhishek Singh <abhi24@mit.edu>
  • Loading branch information
3 people authored and jgrainger-745 committed Apr 1, 2020
1 parent a9c0c7c commit 972b8a7
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 8,031 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,6 @@ buck-out/

# CocoaPods
/ios/Pods/
yarn.lock
.vscode/launch.json
ios/Podfile.lock
3 changes: 3 additions & 0 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>

<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

<application
android:name=".MainApplication"
android:label="@string/app_name"
Expand Down
12 changes: 9 additions & 3 deletions app/services/LocationService.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { GetStoreData, SetStoreData } from '../helpers/General';
import BackgroundGeolocation from '@mauron85/react-native-background-geolocation';
import { Alert, Platform } from 'react-native';

import {Alert, Platform, Linking} from 'react-native';
import {PERMISSIONS, check, RESULTS, request} from 'react-native-permissions';
import PushNotificationIOS from '@react-native-community/push-notification-ios';

import PushNotification from 'react-native-push-notification';
Expand Down Expand Up @@ -260,7 +260,13 @@ export default class LocationServices {
[
{
text: 'Yes',
onPress: () => BackgroundGeolocation.showLocationSettings(),
onPress: () => {
if (Platform.OS === 'android'){ // showLocationSettings() only works for android
BackgroundGeolocation.showLocationSettings();
} else {
Linking.openURL('App-Prefs:Privacy'); // Deeplinking method for iOS
}
},
},
{
text: 'No',
Expand Down
7 changes: 6 additions & 1 deletion ios/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ target 'PrivateKit' do
pod 'React-RCTVibration', :path => '../node_modules/react-native/Libraries/Vibration'
pod 'React-Core/RCTWebSocket', :path => '../node_modules/react-native/'


permissions_path = '../node_modules/react-native-permissions/ios'

pod 'Permission-LocationAlways', :path => "#{permissions_path}/LocationAlways.podspec"

pod 'React-cxxreact', :path => '../node_modules/react-native/ReactCommon/cxxreact'
pod 'React-jsi', :path => '../node_modules/react-native/ReactCommon/jsi'
pod 'React-jsiexecutor', :path => '../node_modules/react-native/ReactCommon/jsiexecutor'
Expand All @@ -34,7 +39,7 @@ target 'PrivateKit' do
pod 'glog', :podspec => '../node_modules/react-native/third-party-podspecs/glog.podspec'
pod 'Folly', :podspec => '../node_modules/react-native/third-party-podspecs/Folly.podspec'

pod 'react-native-webview', :path => '../node_modules/react-native-webview'


# React Native Maps dependencies
rn_maps_path = '../node_modules/react-native-maps'
Expand Down
Loading

0 comments on commit 972b8a7

Please sign in to comment.