Jordan
Jordan

Reputation: 21760

Change Default Browser Programmatically Mac OSX

How would you change the default browser programmatically on Mac OSX.

For example from safari to chrome, or chrome to firefox?

Thanks

Upvotes: 2

Views: 2535

Answers (1)

xnyhps
xnyhps

Reputation: 3316

You should use

LSSetDefaultHandlerForURLScheme(
             CFStringRef inURLScheme, CFStringRef inHandlerBundleID) 

See also Launch Service Reference Docs.

Use @"http" for the inURLScheme, and figure out the bundle identifiers of Firefox, Chrome etc. to use.

You can also check which are installed using

LSCopyAllHandlersForURLScheme(CFStringRef inURLScheme)

Upvotes: 4

Related Questions