Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 77050

How to correctly require authorization to use geolocator plugin in ios?

$
0
0

Hello,
I'm currently use Montemagno Geolocator plugin on my app, and until the last version all seems to work fine.
Some days ago I released a new version, with some bugfix and using new versions of nuget packages.
Now that I've submitted the app to the Appstore it was rejected because something is wrong about the declaration about the use of GPS position.

I just need to use position on my app to obtain coordinates when the app goes in a certain view, so I don't need to track the position in background.
What I've done until now is to add these keys:
NSLocationWhenInUseUsageDescription
NSLocationAlwaysUsageDescription

in my info.plist file, but I noticed that on my project properties the checkbox "Enable background modes -> Location updates" was enabled.

Apple reject my app explaining these details:

2.16 Details

Your app declares support for location in the UIBackgroundModes key in your Info.plist file but does not declare any features that require persistent location. Apps that declare support for location in the UIBackgroundModes key in your Info.plist file must have features that require persistent location.

In my code until now I don't require explicitly authorization, I just try to obtain the position using this code on ios:

if (geolocator.IsGeolocationEnabled)
{
try
{
if (!geolocator.IsListening)
geolocator.StartListening(1000, 1000);

                    var task = await geolocator.GetPositionAsync(10000, CancellationToken.None);

                    if (task != null)
                    {
                        position = task;
                    }
                }
                catch { ; }
                finally 
                {
                    geolocator.StopListening();
                }
            }

So my question is, what have I to do in order to correctly declare that I want to use GPS position (only in foreground) making my app acceptable by apple?


Viewing all articles
Browse latest Browse all 77050

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>