編集

次の方法で共有


UIApplicationDelegate.WillFinishLaunching(UIApplication, NSDictionary) Method

Definition

Indicates that launching has begun, but state restoration has not yet occurred.

[Foundation.Export("application:willFinishLaunchingWithOptions:")]
[ObjCRuntime.Introduced(ObjCRuntime.PlatformName.iOS, 6, 0, ObjCRuntime.PlatformArchitecture.All, null)]
public virtual bool WillFinishLaunching (UIKit.UIApplication application, Foundation.NSDictionary launchOptions);
abstract member WillFinishLaunching : UIKit.UIApplication * Foundation.NSDictionary -> bool
override this.WillFinishLaunching : 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

False if the application is unable to handle the specified url, true otherwise.

Attributes

Remarks

This is the first method called when your UIApplication has been created, and by the time this is called, the storyboard or NIB files would have been loaded. When you return from this call, the state restoration protocol will take place, and after that, the FinishedLaunching(IUIApplicationDelegate, UIApplication, NSDictionary) method will be invoked to complete the application startup.

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 launchOptionsDescription
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;
    }
}

Applies to