-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added working implementation for Firefox, Chrome
- Loading branch information
1 parent
536a0ef
commit 24f9ec7
Showing
6 changed files
with
104 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,21 @@ | ||
# iOSSwitchr | ||
### A simple tool to change the iOS Default Browser | ||
|
||
___ | ||
![GIF!](https://media.giphy.com/media/SURDoJI3yRCk7utlLh/giphy.gif) | ||
___ | ||
|
||
This app cannot be published on the AppStore as changing the default browser on iOS is prohibited by Apple. | ||
|
||
You either deploy it by yourself to your device from Xcode or self sign the `.ipa` downloaded from [here](https://github.com/trusk89/iOSSwitchr/releases). | ||
To install, you either deploy it by yourself to your device from Xcode OR you can use [Cydia Impactor](http://www.cydiaimpactor.com/) to install the `.ipa` directly from [here](https://github.com/trusk89/iOSSwitchr/releases)). | ||
|
||
To self sign, you can use [Cydia Impactor](http://www.cydiaimpactor.com/). | ||
___ | ||
|
||
### Known issues: | ||
1. Brave, Vivaldi, Opera don't work yet | ||
|
||
2. Some URLs (I saw the behavior only in the Messages app and in Notes) are not handled as URLs by the OS, so you need to long press on them and than select `Open Link` | ||
|
||
3. Need to do some propper organising of the classes, as everything is just thrown in there at this point | ||
___ | ||
|
||
### If you like this project, please consider staring it. Thanks! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
// | ||
// DeepLinkHandler.swift | ||
// iOSSwitchr | ||
// | ||
// Created by Alex Bartis on 13/05/2020. | ||
// Copyright © 2020 Alex Bartis. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
import UIKit | ||
|
||
class DeepLinkHandler { | ||
static func handle(urlString: String, for browserType: Browser.ID) { | ||
|
||
var newURL: URL! | ||
|
||
switch browserType { | ||
case .Firefox: | ||
if let unwrappedURL = getFirefoxURL(from: urlString) { | ||
newURL = unwrappedURL | ||
} | ||
|
||
case .Chrome: | ||
if let unwrappedURL = getChromeURL(from: urlString) { | ||
newURL = unwrappedURL | ||
} | ||
|
||
default: | ||
return | ||
} | ||
|
||
UIApplication.shared.open(newURL) | ||
} | ||
|
||
private static func getFirefoxURL(from oldURLString: String) -> URL? { | ||
let newString = "firefox://open-url?url=" + oldURLString | ||
guard let url = URL(string: newString) else { | ||
return nil | ||
} | ||
|
||
return url | ||
} | ||
|
||
private static func getChromeURL(from oldURLString: String) -> URL? { | ||
let existingScheme = oldURLString.components(separatedBy: ":").first ?? "https" | ||
let chromeScheme = existingScheme == "http" ? "googlechrome" : "googlechromes" | ||
let newURLString = oldURLString.replacingOccurrences(of: existingScheme, with: chromeScheme) | ||
|
||
guard let url = URL(string: newURLString) else { | ||
return nil | ||
} | ||
|
||
return url | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters