Hi, i having a problem on first acess geolocation in IOS, when the access is Deny Location, 'callback_notification' show me alert then gps off,
in second access application enter in loop and not show nothing.
$gpsCount = 0GeoLocation.set_notification('/app/Location/callback_notification', "", 3)
def callback_notification if $gpsCount 5 if @params['known_position'].to_i != 0 && @params['status'] == 'ok' WebView.execute_js("getLocationGps(@params['latitude'], @params['longitude'])") GeoLocation.turnoff end else WebView.execute_js("alert('GPS Off'));") GeoLocation.turnoff end $gpsCount += 1end
1 Replies
I'm uncertain what you mean by "first access" and "second access". Can you tell us the exact steps to reproduce? When/from where are the first two lines run?
- I would reverse the order of the params check, though probably not the cause here.
- You should also check the available parameter. It will be 0 if the hardware is not present, permission is not granted, etc. There is no point in trying 5 times in that case!
- What does LocationGps() do?
- I would avoid using Javascript alert() for debugging, since it stops all async operations in JS. Just use console.log and either view using Safari/Chrome remote inspection or else write a little JS replacement for console.log that forwards logging to the Rhodes log.
if @params['status'] == 'ok' && @params['known_position'].to_i != 0