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 = @"mobilejazz.cat";// Open with Google Chrome if possibleif ([[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 rpetri.ch/repo as a repo to Cydia (Manage > Sources > Edit > Add) and then simply search for Browser Chooser.
No comments:
Post a Comment