This module gives you the possibility to shortcircuit the current iOS location permission from Titanium to properly support iOS 11 its new way of location permissions.
-
Integrate the module into the
modules
folder and define them into thetiapp.xml
file:<modules> <module platform="iphone" version="0.1.0">ti.locationpermission</module> </modules>
-
Check if you have a location permission
var locationPermission = (OS_IOS) ? require('ti.locationpermission') : Ti.Geolocation; if (locationPermission.hasLocationPermissions(Ti.Geolocation.AUTHORIZATION_WHEN_IN_USE)) { alert('true'); }
-
Request or upgrade location permission
var locationPermission = (OS_IOS) ? require('ti.locationpermission') : Ti.Geolocation; locationPermission.requestLocationPermissions(Ti.Geolocation.AUTHORIZATION_WHEN_IN_USE, function(e) { alert(e.success); }); locationPermission.requestLocationPermissions(Ti.Geolocation.AUTHORIZATION_ALWAYS, function(e) { if (OS_IOS && e.authorizationStatus !== Ti.Geolocation.AUTHORIZATION_ALWAYS) { alert('Permission wasn\'t upgraded'); } });
Cheers!
If you already have Titanium installed, skip the first 2 steps, if not let's install Titanium locally.
brew install yarn --without-node
to install yarn without relying on a specific Node version- In the ios directory execute
yarn install
- Alter the
titanium.xcconfig
to build with the preferred SDK - To build the module execute
rm -rf build && ./node_modules/.bin/ti build -p ios --build-only