CPApplicationDelegate.FinishedLaunching Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Overloads
FinishedLaunching(UIApplication) |
Method invoked after the application has launched to configure the main window and view controller. |
FinishedLaunching(UIApplication, NSDictionary) |
Method invoked after the application has launched to configure the main window and view controller. |
FinishedLaunching(UIApplication)
Method invoked after the application has launched to configure the main window and view controller.
[Foundation.Export("applicationDidFinishLaunching:")]
public virtual void FinishedLaunching (UIKit.UIApplication application);
abstract member FinishedLaunching : UIKit.UIApplication -> unit
override this.FinishedLaunching : UIKit.UIApplication -> unit
Parameters
- application
- UIApplication
Reference to the UIApplication that invoked this delegate method.
- Attributes
Remarks
This method should create and configure the toplevel window, make it visible. The toplevel window should have a UIViewController.
This method is deprecated, you should use the overload that takes a launchOptions instead.
Applies to
FinishedLaunching(UIApplication, NSDictionary)
Method invoked after the application has launched to configure the main window and view controller.
[Foundation.Export("application:didFinishLaunchingWithOptions:")]
public virtual bool FinishedLaunching (UIKit.UIApplication application, Foundation.NSDictionary launchOptions);
abstract member FinishedLaunching : UIKit.UIApplication * Foundation.NSDictionary -> bool
override this.FinishedLaunching : UIKit.UIApplication * Foundation.NSDictionary -> bool
Parameters
- application
- UIApplication
Reference to the UIApplication that invoked this delegate method.
- launchOptions
- NSDictionary
An NSDictionary with the launch options, can be null. Possible key values are UIApplication's LaunchOption static properties.
Returns
- Attributes
Remarks
This method should create and configure the toplevel window, make it visible. The toplevel window should have a UIViewController.
The following example shows a minimal implementation:
[Register ("AppDelegate")]
public partial class AppDelegate : UIApplicationDelegate
{
UIWindow window;
public override bool FinishedLaunching (UIApplication app, NSDictionary options)
{
window = new UIWindow (UIScreen.MainScreen.Bounds);
window.RootViewController = new UIViewController ();
window.MakeKeyAndVisible ();
return true;
}
}
The dictionary launchOptions if set, might contain zero or more information bits. You can use the following keys to retrieve information from it:
Dictionary Key for launchOptions | Description |
---|---|
LaunchOptionsUrlKey | The application was launched in response to open a URL. the value associated with the key contains the URL to open. |
LaunchOptionsAnnotationKey | 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. |
LaunchOptionsLocalNotificationKey | The value of this key will be a UILocalNotification instance. This key will be present on the launch options if a local notification was delivered and the application was not running. |
LaunchOptionsLocationKey | Application was started up in response to a location event. The value of this key will be an NSNumber. The application should respond by creating a CLLocationManager instance to and get the information from that object. |
LaunchOptionsNewsstandDownloadsKey | This key indicates that Newsstand has completed downloading the requested data. The value in the dictionary for this key, contains an array of strings that represent T:Newsstand.NKAssetDownload objects. |
LaunchOptionsRemoteNotificationKey | The value associated with this key will be an NSDictionary with the payload from the remote notification that was received. |
LaunchOptionsSourceApplicationKey | The value associated with the key is the bundle-id of the application that launched this application. |
LaunchOptionsBluetoothPeripheralsKey | If this key is present, this means that the Bluetooth subsystem has launched the application to restore a previous operation that was being done by an CBPeripheralManager objects. The value of the key is an array of strings, each being the keys that you used when you created a CBPeripheralManager. |
LaunchOptionsBluetoothCentralsKey | If this key is present, this means that the Bluetooth subsystem has launched the application to restore a previous operation that was being done by an CBCentralManager objects. The value of the key is an array of strings, each being the keys that you used when you created a CBPeripheralManager. |
If the application is designed to handle urls, it should lookup the LaunchOptionsUrlKey key in the launchOptions to extract the url that is being launched, and return true at the end of the method to indicate that the application is able to load that url, or false if it is not.
[Register ("AppDelegate")]
public partial class AppDelegate : UIApplicationDelegate
{
UIWindow window;
public override bool WillFinishLaunching (UIApplication app, NSDictionary options)
{
if (options != null){
NSObject urlObject;
if (options.TryGetValue (UIApplication.LaunchOptionsUrlKey, out urlObject)){
var url = urlObject as NSUrl;
// Examine the url here
return CanHandle (url);
}
}
return true;
}
}
The following example shows how to retrieve the UILocatioNotification at startup.
[Register ("AppDelegate")]
public partial class AppDelegate : UIApplicationDelegate
{
UIWindow window;
public override bool FinishedLaunching (UIApplication app, NSDictionary options)
{
window = new UIWindow (UIScreen.MainScreen.Bounds);
window.RootViewController = new UIViewController ();
window.MakeKeyAndVisible ();
if (options != null){
NSObject result;
if (options.TryGetValue (UIApplication.LaunchOptionsLocalNotificationKey, out result)){
UILocalNotification notification = result as UILocalNotification;
Console.WriteLine ("Got a local notification: {0}", notification);
}
}
return true;
}
}