I am currently planning a Xamarin.Forms app and while doing so i came across a point which seems to have no answer.
The app will have to work with a WCF Service to get its data and also to tell the service to do certain tasks. While the application is active, doing so is easy. But there is something the App has to do. Call the Service every x Minutes to refresh data and create notifications for the user in some cases.
I've read something about backgrounding in iOS or Services in Android, but there seems to be no way for a Xamarin.Forms aplication to have a common way of doing background work. So, how can I access the WCF service, and process the data, while the app is inactive in Xamarin.Forms?
This is the only solution I have found: https://robgibbens.com/backgrounding-with-xamarin-forms/
In a few words: you can't abstract background tasks in Xamarin.Forms because iOS, Android and WP works in a different way. You have to use MessagingCenter to send and receive data from specific implementations in each platform.
A similar thread (I copied my answer from here): Xamarin.forms long running background work
You do it in the same way wih Xamarin as you would do it in an Objective-C or Java app. You use the same API to register a background service.
There are also documents about it for iOS and for Android.
Xamarin uses the same native API on each system like any other native app does. So everything you want to do with Xamarin can be done the same way as you would use the vendors' original toolings. The only difference is the programming language.
Xamarin.Forms is completely irrelevant here. It is an abstraction layer for the native UI frameworks that enable developers to define the user interface once and run a truly native UI on Android, iOS, Windows Phone and Windows Store apps. It has nothing to do with backgrounding here.
© 2022 - 2024 — McMap. All rights reserved.