GeolocatorPlugin icon indicating copy to clipboard operation
GeolocatorPlugin copied to clipboard

xamarin form ios not work background mode and kill app

Open brux88 opened this issue 6 years ago • 1 comments

Bug Information

Version Number of Plugin: 4.5.0.6 Device Tested On: Simulator Tested On:iphone x 11.4.1 Version of VS: 15.8.3 Version of Xamarin: Xamarin.Forms 3.1.0.697729 Xamarin.iOS and Xamarin.Mac SDK 11.14.0.13 (373c313)

I'm trying to make the position update work even when the app is in the backgorund, and even when it's closed. with android everything works fine. with ios it only works in the simulator, just test in a physical device, it does not work if I put the app in the background. just from the backgorund I go in foreground calls me different want the event of the change of position even if I set every 20 seconds, how could I do?

Code snippet

`public MasterViewModel() { ListMasterPageItem = ListMenuService.GetMenuItems(); if (Device.RuntimePlatform == Device.iOS) { StartListening(); } }

    async Task StartListening()
    {

        if (CrossGeolocator.Current.IsListening)
            return;

        ///This logic will run on the background automatically on iOS, however for Android and UWP you must put logic in background services. Else if your app is killed the location updates will be killed.
        await CrossGeolocator.Current.StartListeningAsync(TimeSpan.FromSeconds(20), 10, true, new ListenerSettings
        {
            ActivityType = ActivityType.Other,
            AllowBackgroundUpdates = true,
            DeferLocationUpdates = false,
            DeferralDistanceMeters = null,
            DeferralTime = null,//TimeSpan.FromSeconds(1),
            ListenForSignificantChanges = true,
            
            PauseLocationUpdatesAutomatically = false
        });

        CrossGeolocator.Current.PositionChanged += Current_PositionChanged;
    }`

###permission NSLocationAlwaysUsageDescription Can we use your location NSLocationWhenInUseUsageDescription We are using your location NSLocationAlwaysAndWhenInUseUsageDescription Can we use your position to send you targeted offers and find the different stores? NSMicrophoneUsageDescription Allows you to recognise your voice to create tasks NSCalendarsUsageDescription Some ad content may access calendar NSContactsUsageDescription This app requires contacts access to function properly. NSAppleMusicUsageDescription Play using while you are hiking NSSiriUsageDescription This app siri use. UIBackgroundModes location remote-notification

brux88 avatar Sep 08 '18 10:09 brux88

I am currently experiencing the same issue and posted a question on SO here.

ediewoelfle avatar Jun 10 '19 00:06 ediewoelfle