Instance Method

application:openURL:sourceApplication:annotation:

Asks the delegate to open a resource identified by a URL.

Declaration

- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation;

Parameters

application

Your singleton app object.

url

The URL resource to open. This resource can be a network resource or a file. For information about the Apple-registered URL schemes, see Apple URL Scheme Reference.

sourceApplication

The bundle ID of the app that is requesting your app to open the URL (url).

annotation

A Property list supplied by the source app to communicate information to the receiving app.

Return Value

YES if the delegate successfully handled the request or NO if the attempt to open the URL resource failed.

Discussion

Your implementation of this method should open the specified URL and update its user interface accordingly. If your app had to be launched to open the URL, the app calls the application:willFinishLaunchingWithOptions: and application:didFinishLaunchingWithOptions: methods first, followed by this method. The return values of those methods can be used to prevent this method from being called. (If the app is already running, only this method is called.)

If the URL refers to a file that was opened through a document interaction controller, the annotation parameter may contain additional data that the source app wanted to send along with the URL. The format of this data is defined by the app that sent it but the data must consist of objects that can be put into a property list.

Files sent to your app through AirDrop or a document interaction controller are placed in the Documents/Inbox directory of your app’s home directory. Your app has permission to read and delete files in this directory but does not have permission to write to them. If you want to modify a file, you must move it to a different directory first. In addition, files in that directory are usually encrypted using data protection. If the file is protected and the user locks the device before this method is called, you will be unable to read the file’s contents immediately. In that case, you should save the URL and try to open the file later rather than return NO from this method. Use the protectedDataAvailable property of the app object to determine if data protection is currently enabled.

There is no matching notification for this method.

See Also

Deprecated Symbols

- application:didRegisterUserNotificationSettings:

Called to tell the delegate the types of local and remote notifications that can be used to get the user’s attention.

Deprecated
- application:didReceiveLocalNotification:

Sent to the delegate when a running app receives a local notification.

Deprecated
- application:didReceiveRemoteNotification:

Called when your app has received a remote notification.

Deprecated
- application:handleActionWithIdentifier:forLocalNotification:completionHandler:

Called when your app has been activated because user selected a custom action from the alert panel of a local notification.

Deprecated
- application:handleActionWithIdentifier:forLocalNotification:withResponseInfo:completionHandler:

Called when your app has been activated by the user selecting an action from a local notification.

Deprecated
- application:handleActionWithIdentifier:forRemoteNotification:completionHandler:

Tells the app delegate to perform the custom action specified by a remote notification.

Deprecated
- application:handleActionWithIdentifier:forRemoteNotification:withResponseInfo:completionHandler:

Called when your app has been activated by the user selecting an action from a remote notification.

Deprecated
- application:handleOpenURL:

Asks the delegate to open a resource identified by URL.

Deprecated

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software