Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 46933
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T16:02:36+00:00 2026-05-10T16:02:36+00:00

How do you set your Cocoa application as the default web browser? I want

  • 0

How do you set your Cocoa application as the default web browser?

I want to create an application that is launched by default when the user clicks on an HTTP or HTTPS link in other applications (Mail, iChat etc.).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T16:02:37+00:00Added an answer on May 10, 2026 at 4:02 pm

    There are four steps to making an app that can act as the default web browser. The first three steps allow your app to act as a role handler for the relevant URL schemes (HTTP and HTTPS) and the final step makes it the default role handler for those schemes.

    1) Add the URL schemes your app can handle to your application’s info.plist file

    To add support for http:// and https:// you’d need to add the following to your application’s info.plist file. This tells the OS that your application is capable of handling HTTP and HTTP URLs.

    <key>CFBundleURLTypes</key> <array>     <dict>         <key>CFBundleURLName</key>         <string>http URL</string>         <key>CFBundleURLSchemes</key>         <array>             <string>http</string>         </array>     </dict>     <dict>         <key>CFBundleURLName</key>         <string>Secure http URL</string>         <key>CFBundleURLSchemes</key>         <array>             <string>https</string>         </array>     </dict> </array> 

    2) Write an URL handler method

    This method will be called by the OS when it wants to use your application to open a URL. It doesn’t matter which object you add this method to, that’ll be explicitly passed to the Event Manager in the next step. The URL handler method should look something like this:

    - (void)getUrl:(NSAppleEventDescriptor *)event      withReplyEvent:(NSAppleEventDescriptor *)replyEvent {   // Get the URL   NSString *urlStr = [[event paramDescriptorForKeyword:keyDirectObject]      stringValue];    //TODO: Your custom URL handling code here } 

    3) Register the URL handler method

    Next, tell the event manager which object and method to call when it wants to use your app to load an URL. In the code here I’m passed self as the event handler, assuming that we’re calling setEventHandler from the same object that defines the getUrl:withReplyEvent: method.

    You should add this code somewhere in your application’s initialisation code.

    NSAppleEventManager *em = [NSAppleEventManager sharedAppleEventManager]; [em    setEventHandler:self    andSelector:@selector(getUrl:withReplyEvent:)    forEventClass:kInternetEventClass    andEventID:kAEGetURL]; 

    Some applications, including early versions of Adobe AIR, use the alternative WWW!/OURL AppleEvent to request that an application opens URLs, so to be compatible with those applications you should also add the following:

    [em   setEventHandler:self    andSelector:@selector(getUrl:withReplyEvent:)    forEventClass:'WWW!'    andEventID:'OURL']; 

    4) Set your app as the default browser

    Everything we’ve done so far as told the OS that your application is a browser, now we need to make it the default browser.

    We’ve got to use the Launch Services API to do this. In this case we’re setting our app to be the default role handler for HTTP and HTTPS links:

    CFStringRef bundleID = (CFStringRef)[[NSBundle mainBundle] bundleIdentifier]; OSStatus httpResult = LSSetDefaultHandlerForURLScheme(CFSTR('http'), bundleID); OSStatus httpsResult = LSSetDefaultHandlerForURLScheme(CFSTR('https'), bundleID); //TODO: Check httpResult and httpsResult for errors 

    (It’s probably best to ask the user’s permission before changing their default browser.)

    Custom URL schemes

    It’s worth noting that you can also use these same steps to handle your own custom URL schemes. If you’re creating a custom URL scheme it’s a good idea to base it on your app’s bundle identifier to avoid clashes with other apps. So if your bundle ID is com.example.MyApp you should consider using x-com-example-myapp:// URLs.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 118k
  • Answers 118k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Found the problem. loadNewVideo('11mrMppgfrQ','0'); play(); were calling before function onYouTubePlayerReady(playerId)… May 11, 2026 at 11:37 pm
  • Editorial Team
    Editorial Team added an answer Briefly, it's to make the class abstract, so that it… May 11, 2026 at 11:37 pm
  • Editorial Team
    Editorial Team added an answer Something like: Collections.sort(records, new Comparator<List<String>>() { public int compare(List<String> o1,… May 11, 2026 at 11:37 pm

Related Questions

How do you set up your .NET development tree? I use a structure like
I'm struggling to implement ACL in CakePHP. After reading the documentation in the cake
So I'm newly in charge of projects at my company (We're still only 2
Inspired by this CodingHorror article, Protecting Your Cookies: HttpOnly How do you set this

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.