UIKit.UIApplication Class
Encapsulates the main processing loop for a MonoTouch application.

See Also: UIApplication Members

Syntax

[Foundation.Register("UIApplication", true)]
[ObjCRuntime.Availability(Introduced=ObjCRuntime.Platform.iOS_2_0)]
public class UIApplication : UIResponder

Remarks

The UIKit.UIApplication encapsulates the central administrative properties of an application running on iOS. Application developers must not instantiate new UIKit.UIApplications using constructors, but instead must use the static UIApplication.SharedApplication singleton property. Application developers may subclass UIKit.UIApplication and use the principalClassName argument to the UIApplication.Main(string[], string, string) method to specify their subclass. In that situation, developers must create a public constructor for their subclass that the runtime will call appropriately. Subsequently, the UIApplication.SharedApplication singleton will refer to the instance of their subclass.

Unlike with most classes in the UIKit namespace, events relating to the UIKit.UIApplication cannot be handled using C#-style events but rather only by the Objective-C style UIKit.UIApplicationDelegate delegate style.

The UIKit.UIApplication object is responsible for maintaining the highest-level context of the application, such as the UIApplication.ApplicationState, the set of open windows (UIApplication.Windows), and functions relating to notifications (see also UIKit.UIAppearance.Notifications.xml). Additionally, the UIApplication.OpenUrl method may be used to launch another application.

The UIKit.UIApplication class contains methods relating to background processing, such as UIApplication.EnsureUIThread, UIApplication.BeginBackgroundTask, and UIApplication.EndBackgroundTask.

Background Fetch

Starting with iOS 7, applications can request that they be woken up to download data from the server in the background. When this feature is enabled, the operating system will resume the application or launch the application at some point to allow the application to download any new contents it needs from the server.

To use this, applications need to have the "fetch" background operation requested on their requested Entitlements as well as calling the UIKit.UIApplication.SetMinimumBackgroundFetchInterval method with the desired wake up interval at launch.

When the operating system determines that the application should be resumed to download data, the UIKit.UIApplicationDelegate.PerformFetch method will be invoked. This method should perform any downloads and then notify the operating system of the result of the operation.

Applications do not really have control of when the application will be launched. The actual launch time is determined by a set of heuristics based that the operating system tracks based on how the user uses the application, as well as tracking the status of previous download operations that the application has done.

Remote Notifications

Starting with iOS 7, applications can request that they be woken up when a remote notification is received. When this feature is enabled, the operating system will resume the application and invoke the UIKit.UIApplicationDelegate.DidReceiveRemotNotification overload that takes a completion handler parameter and let it run.

To use this, applications need to have the "remote-notification" background operation requested on their requested Entitlements as.

Related content

Requirements

Namespace: UIKit
Assembly: Xamarin.iOS (in Xamarin.iOS.dll)
Assembly Versions: 0.0.0.0