Can we ask the GPS to be enabled?

Hello all,

Is there any chace to get the information from the device that the GPS is turned off?

I could not find any reply in google / corona sdk librares about that one, now I’m handling simply by making try times like:

if currentLocation.errorCode then

try = try + 1

Then if the try is bigger than 30 (1 minute) it is stopping and asking user to have the GPS deviece enabled.

Which is not good, I think there should be way to use any event of the phone to get info if the GPS module is enabled, there is a lot of GPS Apps which is asking for the GPS to have enabled before you open the map etc.

I have tried with the event “location” but it is only checking if the system has the GPS module or not, how Can I handle this, to be faster to inform user about having GPS module enabled?

Regards,

M.

On iOS you should automatically get a popup when you first request the GPS to turn on.  It should remember your choice in the Settings Location Services and won’t ask again.  You are also required to include a setting in your build.settings that tells the user what you are going to use the GPS for:   NSLocationWhenInUseUsageDescription…

settings = { iphone = { plist= { UIRequiredDeviceCapabilities = {"location-services", "gps", "magnetometer" }, NSLocationWhenInUseUsageDescription = "This app uses maps and GPS when active to find your Car. ", }, }, }

Hey!

Thanks for that!

Is there any chance to have it done by the Andorid OS as well?

Regards,

M.

Android has no rules, other than to make sure you have all the permissions turned on.

 android = { usesPermissions = { "android.permission.INTERNET", "android.permission.ACCESS\_NETWORK\_STATE", "android.permission.RECEIVE\_BOOT\_COMPLETED", "android.permission.ACCESS\_FINE\_LOCATION", }, usesFeatures = { { name="android.hardware.location", required=false }, { name="android.hardware.location.gps", required=false }, } },

Yes but I ment like if you press a button on the APP you will see the box to enable the GPS, because it is needed.

I had the permissions set already, I just wonder if there is any event in the corona like (isTheGPSTurnedOn = true/false).

If not then you will press a button and that will forward you to the location settings, similar to the Google Maps. 

Example:

android_launching_gps_settings.png?e9b29

When your app first runs on Android, it asks for all the permissions you have enabled.  This is when the user agrees to let you use the GPS.  You generally don’t need to prompt the user again.  iOS asks when you first fire up the GPS and only asks once and the OS takes care of it for you.

But as far as having the Turn on/off the GPS on demand, there are many reasons why a GPS can’t be found, and its not only the GPS. Sometimes WiFi provides locations data.  Because the GPS can some times sync quickly and other times it can take some time to sync, you have to do what you’re doing.  There really isn’t an “Is the GPS on” or not.  You know when you enable the event and you can set some timeout to trigger after some time (a minute is good).  If you get GPS events, you’ve found the satellites, then you’re good.  If not, alert the user.

In addition you should monitor your event results even if you do get the GPS synched, because going in and out of buildings can cause you to loose the signal.

Rob

It sounds like you’re on the right path.

On iOS you should automatically get a popup when you first request the GPS to turn on.  It should remember your choice in the Settings Location Services and won’t ask again.  You are also required to include a setting in your build.settings that tells the user what you are going to use the GPS for:   NSLocationWhenInUseUsageDescription…

settings = { iphone = { plist= { UIRequiredDeviceCapabilities = {"location-services", "gps", "magnetometer" }, NSLocationWhenInUseUsageDescription = "This app uses maps and GPS when active to find your Car. ", }, }, }

Hey!

Thanks for that!

Is there any chance to have it done by the Andorid OS as well?

Regards,

M.

Android has no rules, other than to make sure you have all the permissions turned on.

 android = { usesPermissions = { "android.permission.INTERNET", "android.permission.ACCESS\_NETWORK\_STATE", "android.permission.RECEIVE\_BOOT\_COMPLETED", "android.permission.ACCESS\_FINE\_LOCATION", }, usesFeatures = { { name="android.hardware.location", required=false }, { name="android.hardware.location.gps", required=false }, } },

Yes but I ment like if you press a button on the APP you will see the box to enable the GPS, because it is needed.

I had the permissions set already, I just wonder if there is any event in the corona like (isTheGPSTurnedOn = true/false).

If not then you will press a button and that will forward you to the location settings, similar to the Google Maps. 

Example:

android_launching_gps_settings.png?e9b29

When your app first runs on Android, it asks for all the permissions you have enabled.  This is when the user agrees to let you use the GPS.  You generally don’t need to prompt the user again.  iOS asks when you first fire up the GPS and only asks once and the OS takes care of it for you.

But as far as having the Turn on/off the GPS on demand, there are many reasons why a GPS can’t be found, and its not only the GPS. Sometimes WiFi provides locations data.  Because the GPS can some times sync quickly and other times it can take some time to sync, you have to do what you’re doing.  There really isn’t an “Is the GPS on” or not.  You know when you enable the event and you can set some timeout to trigger after some time (a minute is good).  If you get GPS events, you’ve found the satellites, then you’re good.  If not, alert the user.

In addition you should monitor your event results even if you do get the GPS synched, because going in and out of buildings can cause you to loose the signal.

Rob

It sounds like you’re on the right path.