Use Chrome as the default browser on iOS

Recently Google released their beloved Chrome browser for iOS, which supports advanced features like Chrome for your desktop computer. The most interesting among them are the smart suggestions while typing in the omnibox as well as synchronized bookmarks, history and passwords, where especially the latter is a pain to enter on mobile devices, when using long and cryptic passwords.

It all sounds pretty awesome, but there is one problem with that: the default browser for iOS is still Safari. And I guess Apple has no interest in changing that. Luckily Raphael Caixeta came up with a few lines of code, that app developers can add to their application, so that at least those will support opening links on Chrome for iOS where installed. If the user doesn't have Chrome installed, it will gracefully fall back to Safari.

As a developer you simply have to use the following snippet, whenever you want to open an URL with an external web browser:

NSString *url = @"";

// Open with Google Chrome if possible
if ([[UIApplication sharedApplication] canOpenURL:[NSURL   URLWithString:@"googlechrome:"]]) {
     [[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:@"googlechrome://%@", url]]];
} else {
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://%@", url]]];

For jailbroken devices there is another option: Browser Chooser, developed by Ryan Petrich. You can get it by adding as a repo to Cydia (Manage > Sources > Edit > Add) and then simply search for Browser Chooser.

No comments:

Post a Comment