Issue
I'm new and currently working on a Xamarin.IOS app based on a Xamarin.Android app. I noticed that the Android native app does background tasks using a class called Service
from Android.App
and classes from Android.Support.V7.App
and Android.Content
. I'm just wondering if there's any similar solution for Xamarin.IOS, or do I have to do it completely from scratch?
Solution
From document Backgrounding in Xamarin.iOS,we know that:
In iOS, backgrounding is recognized as an application state, and apps are moved in and out of the background state depending on the behavior of the app and the user. iOS also offers several options for wiring an app to run in the background, including asking the OS for time to complete an important task, operating as a type of known background-necessary application, and refreshing an application's content at designated intervals.
IOS regulates background processing very tightly, and offers three approaches to implement it:
- Register a Background Task If an application needs to complete an important task, it can ask iOS not to interrupt the task when the application moves into the background. For example, an application might need to finish logging in a user, or finish downloading a large file.
- Register as a Background-Necessary Application - An app can register as a specific type of application that has known, specific backgrounding requirements, such as Audio , VoIP , External Accessory , Newsstand , and Location . These applications are allowed continuous background processing privileges as long as they are performing tasks that are within the parameters of the registered application type.
- Enable Background Updates - Applications can trigger background updates with Region Monitoring or by listening for Significant Location Changes . As of iOS 7, applications can also register to update content in the background using Background Fetch or Remote Notifications .
For more details, you can check:https://docs.microsoft.com/en-us/xamarin/ios/app-fundamentals/backgrounding/introduction-to-backgrounding-in-ios.
Answered By - Jessie Zhang -MSFT
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.