Created
July 15, 2019 22:12
-
-
Save Ayyagaries/79740c369cde3bf99cf7d6261f0e0e6a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function openCheckInScreen() { | |
if (geolocation.hasPermissions()) { | |
location.getDeviceLocation({ | |
callback: getDeviceCallback | |
}); | |
} else { | |
geolocation.requestPermissions(function(result) { | |
if (result) { | |
location.getDeviceLocation({ | |
callback: getDeviceCallback | |
}); | |
} | |
}); | |
} | |
} | |
function getDeviceCallback(e) { | |
var dist = App.location.distance(e.coords.latitude, e.coords.longitude, facilityLatitude, facilityLongitude); | |
Ti.API.info('User Lat: ' + e.coords.latitude + ', User Long: ' + e.coords.longitude + ', Facility Lat: ' + facilityLatitude + ', Facility Long: ' + facilityLongitude); | |
Ti.API.info('The distance is ' + dist + ', Mobile check in range is ' + mobileCheckInRange); | |
if (dist < mobileCheckInRange) { | |
App.openScreen('checkin/rep_checkin') | |
} else { | |
App.alert({ | |
title: 'Error', | |
message: 'To check in, you must be approximately 100 yards from ' + $.l_hospital_name.getText() + '. Please move closer to the facility and/or try again in 3 minutes.' | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment