How to register a URL scheme to open an application using Xcode 4?

Xcode4 asks for a huge number of arguments to make this simpler:

NSString *stringURL = @"twitterriffic://"; NSURL *url = [NSURL URLWithString:stringURL]; [[UIApplication sharedApplication] openURL:url]; 

Xcode 4 Info.plist editor

What are all these properties for? Why image? Should I repeat application id here? What role should I choose if I want someone to be able to call this URL to open my application? And what are these additional url type properties for?

I have not found a tutorial related to Xcode4 how to register such a URL scheme with Xcode 4.

+70
ios iphone xcode4 ipad
Nov 20 '11 at 13:13
source share
4 answers

Edit your AppName-Info.plist file

  • Open the "Supporting files" (folder) on the left and click "YourAppName-Info.plist"
  • Select a line of type "Package Creator Code Type" and hover over the line and click on the (+) symbol
  • This creates a new line and type "URL types"
  • Click on the aperture on the left and see point 0, and you will rename the value in point 0 to "URL Schemas", as shown
  • Then edit the field in Item 0 and enter the prototype; I typed "goomzee" as shown

Now, if I install this application on my simulator and open Safari and type "goomzee: //" in the address bar, it will launch my application.

+95
Oct 08
source share

Yes, is it not that simple?

I have outlined the steps required to register a custom URL here: Custom URLs

But essentially, the key to this is setting the "URL Types" value in your .plist file. Here's what it looks like in Xcode 5:

URL types

In this example, I registered the MKB prefix, so now I can use this new type of URL in hyperlinks on web pages and in emails (if I read the email in the iPad Mail app):

Mail app

If the user clicks on one of these links, the iPad application starts up and I can access the full string of the URL to extract other parameters from the URL (for example, "DocumentNumber = 100")

The only drawback is that I have yet to figure out how to check if the user has an iPad app installed that can recognize a specific prefix.

If this does not happen, and they click on one of these MKB: // links on their iPad, they will receive a terrible error message:

Nope

+26
Mar 13 '14 at 8:26
source share

You can continue to register your custom URL by editing the app.plist file of the application (as shown in one of the previous questions ). The new editor in Xcode 4 is supposed to be more convenient for adding entries - all it does is make the same info.plist changes that you would do manually. If you want to use the new editor, you only need to fill in the "Identifier" and "URL Schema" fields. You do not need images, an icon or additional URL properties.

Other properties (icon, etc.) are not well documented, but seem to apply only to Mac OS X and can be used in the Finder Get Info dialog box to display the types of URLs that a particular application can open. For example, see Launch Services Launch Guide .

+17
Nov 20 2018-11-11T00:
source share

What you change in this editor is also reflected in the plist file of the project file. It takes the form of ProjectName-Info.plist. Hope this helps.

0
Aug 14 2018-12-12T00:
source share



All Articles