0

I searched the web up and down but could not find one example. Apple's docs says it is to define launch options. But what are these? What would be a harmless/basic option to include?

Hamish
  • 78,605
  • 19
  • 187
  • 280
Ralf
  • 3
  • 3

2 Answers2

0

From the Apple docs on UIApplicationDelegate:

Open a URL that was sent to your app. If there is a URL to open, the system calls the application:openURL:options: method of your app delegate. You can also tell if there is a URL to open by looking in the launch options dictionary for the UIApplicationLaunchOptionsURLKey key.

Therefore, the options parameter is for the system to provide, when your app is being opened with a URL that has been sent to it. You don't have to pass anything when you call it, so you can just provide an empty dictionary for the options if you're just using it to open an external URL (although you may want to pass your bundle ID for the UIApplicationLaunchOptionsSourceApplicationKey key).

EDIT

Thinking about it further, this is completely the wrong way of opening an external URL from your app. It's just a delegate method for the system to call to allow your app to open a URL (like from the Safari action sheet). You want:

[[UIApplication sharedApplication] openURL:url];
Hamish
  • 78,605
  • 19
  • 187
  • 280
  • Thanks for the answer, but Xcode warns if it is nil and wants a nonnull argument: http://i.imgur.com/HDO6o1o.png – Ralf Jan 20 '16 at 19:00
  • wait a sec, if you're using this to open a URL, you're going about it in the wrong way. You want `[[UIApplication sharedApplication] openURL:url]` – Hamish Jan 20 '16 at 19:15
0
+-------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------+
| UIApplicationOpenURLOptionsSourceApplicationKey | NSString containing the bundle ID of the originating application                                                                             |
+-------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------+
| UIApplicationOpenURLOptionsAnnotationKey        | property-list typed object corresponding to what the originating application passed in UIDocumentInteractionController's annotation property |
+-------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------+
| UIApplicationOpenURLOptionsOpenInPlaceKey       | bool NSNumber, set to YES if the file needs to be copied before use                                                                          |
+-------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------+

I have provided an answer to a similar question here: https://stackoverflow.com/a/39447154/6821647

Community
  • 1
  • 1
scol
  • 131
  • 4