Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 204402

xamarin form ios not work background mode and kill app

$
0
0

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?

`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;
}`

My 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`


Viewing all articles
Browse latest Browse all 204402

Latest Images

Trending Articles



Latest Images

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