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

Cross Geolocator Consent Event Notifier

$
0
0

I'm successfully using the Geolocator Plugin from @JamesMontemagno in a Xamarin.Forms app to query a user's location. On iOS:

1) It successfully shows the consent dialog box upon the first (ever) attempt to query location
2) Naturally, this query fails
3) To get the location information I want - I have to perform this operation again at some later point

The problem is, I don't know at what later point I can perform the operation. Upon first use, I want my app :

1) To ask for location consent,
2) Upon it being granted immediately perform the location query and populate a view.

Code is currently something like this:

SomeView.xaml.cs

private async void StartMyApp()
{
    await FirstLocationAttempt(); // try to query location which shows the iOS consent dialog if it's the first time. 
                          //  location query fails if it's the first time.

    await GetLocationAndShowStuff(); // try another query location, and use it in a view
}

If the user is quick to give access (via FirstLocationAttempt()) then everything works. If the user waits, the code moves onto GetLocationAndShowStuff() despite the await on FirstLocationAttempt();

Seems that the plugin doesn't (yet) pass through the native iOS "locationManager:didChangeAuthorizationStatus" as described here:

https://developer.apple.com/library/mac/documentation/CoreLocation/Reference/CLLocationManagerDelegate_Protocol/#//apple_ref/occ/intfm/CLLocationManagerDelegate/locationManager:didChangeAuthorizationStatus

http://nshipster.com/core-location-in-ios-8/

I do see I can subscribe to PositionError for CrossGeolocator - but not sure if there's a specific error code to look for.

Help?

I'm open to slightly changing the sequencing of operations on my screens, but I don't think my use case is very far off of what other apps do. Am I missing something?


Viewing all articles
Browse latest Browse all 91519

Trending Articles



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