iOS Guides | Samples

MonoTouch.UIKit.UIApplication Class

Encapsulates the main processing loop for a MonoTouch application.

See Also: UIApplication

Syntax

[MonoTouch.Foundation.Register("UIApplication", true)]
[MonoTouch.ObjCRuntime.Introduced(MonoTouch.ObjCRuntime.PlatformName.iOS, 2, 0, MonoTouch.ObjCRuntime.PlatformArchitecture.None, null)]
[MonoTouch.ObjCRuntime.Unavailable(MonoTouch.ObjCRuntime.PlatformName.WatchOS, MonoTouch.ObjCRuntime.PlatformArchitecture.All, null)]
public class UIApplication : UIResponder

Remarks

The UIApplication encapsulates the central administrative properties of an application running on iOS. Application developers must not instantiate new UIApplications using constructors, but instead must use the static UIApplication.SharedApplication singleton property. Application developers may subclass 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 MonoTouch.UIKit namespace, events relating to the UIApplication cannot be handled using C#-style events but rather only by the Objective-C style UIApplicationDelegate delegate style.

The 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 MonoTouch.UIKit.UIAppearance.Notifications.xml). Additionally, the UIApplication.OpenUrl method may be used to launch another application.

The 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 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 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 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: MonoTouch.UIKit
Assembly: monotouch (in monotouch.dll)
Assembly Versions: 0.0.0.0

The members of MonoTouch.UIKit.UIApplication are listed below.

See Also: UIResponder

Public Constructors

Default constructor that initializes a new instance of this class with no parameters.
A constructor that initializes the object from the data stored in the unarchiver object.
Constructor to call on derived classes to skip initialization and merely allocate the object.
A constructor used when creating managed representations of unmanaged objects; Called by the runtime.

Public Fields

static
CheckForEventAndDelegateMismatchesBoolean. If true, the system will try to diagnose potential mistakes where events and delegate-object overrides are in conflict.
static
CheckForIllegalCrossThreadCallsBoolean. Determines whether the debug builds of MonoTouch will enforce that calls done to UIKit are only issued from the UI thread.

Public Properties

ApplicationIconBadgeNumberInt32. Numeric value to display as the application badge number.
[read-only]
ApplicationStateUIApplicationState. Reflects the current application state.
ApplicationSupportsShakeToEditBoolean. Controls whether shaking the device will bring up the undo/redo buttons.
[read-only]
static
BackgroundFetchIntervalMinimumDouble. Represents the value associated with the constant UIApplicationBackgroundFetchIntervalMinimum
[read-only]
static
BackgroundFetchIntervalNeverDouble. Represents the value associated with the constant UIApplicationBackgroundFetchIntervalNever
[read-only]
BackgroundRefreshStatusUIBackgroundRefreshStatus. Whether background processing is allowed, denied, or restricted.
[read-only]
static
BackgroundRefreshStatusDidChangeNotificationNSString. Notification constant for BackgroundRefreshStatusDidChange
[read-only]
static
BackgroundTaskInvalidInt32. Represents the value associated with the constant UIBackgroundTaskInvalid
[read-only]
BackgroundTimeRemainingDouble. The number of seconds that the application has left to run in the background.
[read-only]
override
ClassHandleIntPtr. The handle for this class.
[read-only]
static
ContentSizeCategoryChangedNotificationNSString. Notification constant for ContentSizeCategoryChanged
[read-only]
CurrentUserNotificationSettingsUIUserNotificationSettings. Returns current user notification settings for the app.
DelegateUIApplicationDelegate. An instance of the MonoTouch.UIKit.UIApplicationDelegate model class which acts as the class delegate.
[read-only]
static
DidBecomeActiveNotificationNSString. Notification constant for DidBecomeActive
[read-only]
static
DidChangeStatusBarFrameNotificationNSString. Notification constant for DidChangeStatusBarFrame
[read-only]
static
DidChangeStatusBarOrientationNotificationNSString. Notification constant for DidChangeStatusBarOrientation
[read-only]
static
DidEnterBackgroundNotificationNSString. Notification constant for DidEnterBackground
[read-only]
static
DidFinishLaunchingNotificationNSString. Notification constant for DidFinishLaunching
[read-only]
static
DidReceiveMemoryWarningNotificationNSString. Notification constant for DidReceiveMemoryWarning
[read-only]
EnabledRemoteNotificationTypesUIRemoteNotificationType. Returns a bit-masked UIRemoteNotificationType indicating which types of notifications the app accepts.
IdleTimerDisabledBoolean. If true, indicates that the screen should not dim even when no input is occurring.
[read-only]
IsIgnoringInteractionEventsBoolean. Whether the receiver is ignoring touch events.
[read-only]
IsRegisteredForRemoteNotificationsBoolean. Indicates whether app is registered for remote notifications.
[read-only]
KeyWindowUIWindow. Returns the application's key window - the window that is currently displayed and receives user input
[read-only]
static
LaunchOptionsAnnotationKeyNSString. Launch Options Key: Use this key to find out if custom data was passed to the program by the opening application. The value of this key will be a property list.
[read-only]
static
LaunchOptionsBluetoothCentralsKeyNSString. Represents the value associated with the constant UIApplicationLaunchOptionsBluetoothCentralsKey
[read-only]
static
LaunchOptionsBluetoothPeripheralsKeyNSString. Represents the value associated with the constant UIApplicationLaunchOptionsBluetoothPeripheralsKey
[read-only]
static
LaunchOptionsCloudKitShareMetadataKeyNSString.
[read-only]
static
LaunchOptionsLocalNotificationKeyNSString. Notification constant for LaunchOptionsLocalNot
[read-only]
static
LaunchOptionsLocationKeyNSString. Launch Options Key: Application was started up in response to a location event.
[read-only]
static
LaunchOptionsNewsstandDownloadsKeyNSString. Launch Options Key: This key indicates that Newsstand has completed downloading the requested data.
[read-only]
static
LaunchOptionsRemoteNotificationKeyNSString. Notification constant for LaunchOptionsRemoteNot
[read-only]
static
LaunchOptionsShortcutItemKeyNSString. The presence of this key indicates that the application was launched via a shortcut item.
[read-only]
static
LaunchOptionsSourceApplicationKeyNSString. Launch Options Key: the value associated with the key is the bundle-id of the application that launched this application.
[read-only]
static
LaunchOptionsUrlKeyNSString. Launch Options Key: the application was launched in response to open a URL. the value associated with the key contains the URL to open.
[read-only]
static
LaunchOptionsUserActivityDictionaryKeyNSString. Represents the value associated with the constant UIApplicationLaunchOptionsUserActivityDictionaryKey
[read-only]
static
LaunchOptionsUserActivityTypeKeyNSString. Represents the value associated with the constant UIApplicationLaunchOptionsUserActivityTypeKey
[read-only]
static
MinimumKeepAliveTimeoutDouble. Represents the value associated with the constant UIMinimumKeepAliveTimeout
NetworkActivityIndicatorVisibleBoolean. Controls the status of the network activity indicator on the device.
[read-only]
static
OpenSettingsUrlStringNSString. Represents the value associated with the constant UIApplicationOpenSettingsURLString
[read-only]
PreferredContentSizeCategoryNSString. The font size preferred by the application user.
[read-only]
ProtectedDataAvailableBoolean. Whether content protection is available.
[read-only]
static
ProtectedDataDidBecomeAvailableNSString. Indicates that the state of protected data has changed.
[read-only]
static
ProtectedDataWillBecomeUnavailableNSString. Indicates that the state of protected data has changed.
ScheduledLocalNotificationsUILocalNotification[]. An array of UILocalNotifications that are currently scheduled.
[read-only]
static
SharedApplicationUIApplication. Points to the main application class.
ShortcutItemsUIApplicationShortcutItem[]. Gets or sets the list of Quick Action shortcuts that the developer defined in code, as distinct from those defined in the Info.plist file.
[read-only]
static
SignificantTimeChangeNotificationNSString. Notification constant for SignificantTimeChange
[read-only]
static
StateRestorationBundleVersionKeyNSString. Represents the value associated with the constant UIApplicationStateRestorationBundleVersionKey
[read-only]
static
StateRestorationSystemVersionKeyNSString. Represents the value associated with the constant UIApplicationStateRestorationSystemVersionKey
[read-only]
static
StateRestorationTimestampKeyNSString. Represents the value associated with the constant UIApplicationStateRestorationTimestampKey
[read-only]
static
StateRestorationUserInterfaceIdiomKeyNSString. Represents the value associated with the constant UIApplicationStateRestorationUserInterfaceIdiomKey
[read-only]
StatusBarFrameRectangleF. The Frame of the status bar.
[read-only]
static
StatusBarFrameUserInfoKeyNSString. Represents the value associated with the constant UIApplicationStatusBarFrameUserInfoKey
StatusBarHiddenBoolean. Whether the status bar is visible.
StatusBarOrientationUIInterfaceOrientation. The orientation of the status bar.
[read-only]
StatusBarOrientationAnimationDurationDouble. The length of the animation used when the status bar rotates.
[read-only]
static
StatusBarOrientationUserInfoKeyNSString. Represents the value associated with the constant UIApplicationStatusBarOrientationUserInfoKey
StatusBarStyleUIStatusBarStyle. The current UIStatusBarStyle.
[read-only]
static
UITrackingRunLoopModeNSString. Represents the value associated with the constant UITrackingRunLoopMode
[read-only]
static
UserDidTakeScreenshotNotificationNSString. Notification constant for UserDidTakeScreenshot
[read-only]
UserInterfaceLayoutDirectionUIUserInterfaceLayoutDirection. The layout direction (right-to-left or left-to-right) of the UI.
WeakDelegateNSObject. An object that can respond to the delegate protocol for this type
[read-only]
static
WillChangeStatusBarFrameNotificationNSString. Notification constant for WillChangeStatusBarFrame
[read-only]
static
WillChangeStatusBarOrientationNotificationNSString. Notification constant for WillChangeStatusBarOrientation
[read-only]
static
WillEnterForegroundNotificationNSString. Notification constant for WillEnterForeground
[read-only]
static
WillResignActiveNotificationNSString. Notification constant for WillResignActive
[read-only]
static
WillTerminateNotificationNSString. Notification constant for WillTerminate
[read-only]
WindowsUIWindow[]. All of the application windows.

Public Methods

BeginBackgroundTask(NSAction) : Int32
Requests that the app be allowed to process in the background.
BeginBackgroundTask(String, NSAction) : Int32
Requests that the app be allowed to process in the background.
BeginIgnoringInteractionEvents()
Stops the application from receiving touch events.
BeginReceivingRemoteControlEvents()
Indicates that the application should start listening for remote-control events.
CancelAllLocalNotifications()
Cancels the delivery of scheduled local notifications.
CancelLocalNotification(UILocalNotification)
Cancels a local notification.
CanOpenUrl(NSUrl) : Boolean
Determines whether the given URL can be opened by OpenUrl.
ClearKeepAliveTimeout()
Stops invoking the KeepAlive method defined previously with SetKeepAliveTimeout.
CompleteStateRestoration()
Indicates to the system that state restoration is complete.
EndBackgroundTask(Int32)
Indicates to the system that background processing has ended for the taskId.
EndIgnoringInteractionEvents()
Resumes receiving touch events for the application.
EndReceivingRemoteControlEvents()
Indicates that the application should nto receive further remote-control events.
static
EnsureUIThread()
Assertion to ensure that this call is being done from the UIKit thread.
ExtendStateRestoration()
Indicates that the application is restoring state asynchronously.
IgnoreSnapshotOnNextApplicationLaunch()
Instructs the system not to use a UI snapshot during relaunch.
static
Main(String[])
Launches the main application loop with the given command line parameters.
static
Main(String[], String, String)
Launches the main application loop with the given command line parameters.
static
Main(String[], Type, Type)
Launches the main application loop with the given command line parameters.
OpenUrl(NSUrl) : Boolean
Opens the specified URL, launching the app that's registered to handle the scheme.
OpenUrl(NSUrl, NSDictionary, Action<bool>)
Opens the specified URL, launching the app that's registered to handle the scheme.
OpenUrl(NSUrl, UIApplicationOpenUrlOptions, Action<bool>)
Opens the specified URL, launching the app that is registered to handle the scheme.
PresentLocationNotificationNow(UILocalNotification)
Immediately presents a local notification.
RegisterForRemoteNotifications()
Registers for receipt of push notifications using the Apple Push Service.
RegisterForRemoteNotificationTypes(UIRemoteNotificationType)
Begins the registration of the application to receive the specified types of notification from Apple Push Service.
static
RegisterObjectForStateRestoration(IUIStateRestoring, String)
Registers the uistateRestoringObject as eligible for state restoration.
RegisterUserNotificationSettings(UIUserNotificationSettings)
Registers the preferred options for user notification.
ScheduleLocalNotification(UILocalNotification)
Schedules the notification for delivery.
SendAction(Selector, NSObject, NSObject, UIEvent) : Boolean
Send an action message to the specified target.
SendEvent(UIEvent)
Sends an event to the application.
SetKeepAliveTimeout(Double, NSAction) : Boolean
Sets the specified handler as the VoIP keep alive method.
SetMinimumBackgroundFetchInterval(Double)
Activates backgound fetching.
SetNewsstandIconImage(UIImage)
Sets the icon to be used in Newsstand.
SetStatusBarHidden(Boolean, UIStatusBarAnimation)
Hides or shows the status bar.
SetStatusBarHidden(Boolean, Boolean)
Hides or shows the animation bar, and whether it should be animated.
SetStatusBarOrientation(UIInterfaceOrientation, Boolean)
Sets the status bar to orientation.
SetStatusBarStyle(UIStatusBarStyle, Boolean)
Sets the style of the status bar, optionally animating the change.
SupportedInterfaceOrientationsForWindow(UIWindow) : UIInterfaceOrientationMask
The set of interface orientations that are used for the view controllers in the specified window.
UnregisterForRemoteNotifications()
The application will no longer receive notifications from Apple Push Service.

Protected Methods

override
Dispose(Boolean)
Releases the resources used by the UIApplication object.