this might fix the hanging issue on iOS 18+, needs more testing.
This commit is contained in:
parent
a93e165f85
commit
a01ea301f5
1 changed files with 35 additions and 3 deletions
|
|
@ -9,6 +9,19 @@ import Foundation
|
||||||
import UIKit
|
import UIKit
|
||||||
import Telegraph
|
import Telegraph
|
||||||
import Zip
|
import Zip
|
||||||
|
import SwiftUI
|
||||||
|
import SafariServices
|
||||||
|
|
||||||
|
struct SafariWebView: UIViewControllerRepresentable {
|
||||||
|
let url: URL
|
||||||
|
|
||||||
|
func makeUIViewController(context: Context) -> SFSafariViewController {
|
||||||
|
return SFSafariViewController(url: url)
|
||||||
|
}
|
||||||
|
|
||||||
|
func updateUIViewController(_ uiViewController: SFSafariViewController, context: Context) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func downgradeAppToVersion(appId: String, versionId: String, ipaTool: IPATool) {
|
func downgradeAppToVersion(appId: String, versionId: String, ipaTool: IPATool) {
|
||||||
let path = ipaTool.downloadIPAForVersion(appId: appId, appVerId: versionId)
|
let path = ipaTool.downloadIPAForVersion(appId: appId, appVerId: versionId)
|
||||||
|
|
@ -35,6 +48,9 @@ func downgradeAppToVersion(appId: String, versionId: String, ipaTool: IPATool) {
|
||||||
let appVersion = infoPlist["CFBundleShortVersionString"] as! String
|
let appVersion = infoPlist["CFBundleShortVersionString"] as! String
|
||||||
print("appBundleId: \(appBundleId)")
|
print("appBundleId: \(appBundleId)")
|
||||||
print("appVersion: \(appVersion)")
|
print("appVersion: \(appVersion)")
|
||||||
|
|
||||||
|
let finalURL = "https://api.palera.in/genPlist?bundleid=\(appBundleId)&name=\(appBundleId)&version=\(appVersion)&fetchurl=http://127.0.0.1:9090/signed.ipa"
|
||||||
|
let installURL = "itms-services://?action=download-manifest&url=" + finalURL.addingPercentEncoding(withAllowedCharacters: .alphanumerics)!
|
||||||
|
|
||||||
DispatchQueue.global(qos: .background).async {
|
DispatchQueue.global(qos: .background).async {
|
||||||
let server = Server()
|
let server = Server()
|
||||||
|
|
@ -44,15 +60,31 @@ func downgradeAppToVersion(appId: String, versionId: String, ipaTool: IPATool) {
|
||||||
let signedIPAData = try Data(contentsOf: destinationUrl)
|
let signedIPAData = try Data(contentsOf: destinationUrl)
|
||||||
return HTTPResponse(body: signedIPAData)
|
return HTTPResponse(body: signedIPAData)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
server.route(.GET, "install", { _ in
|
||||||
|
print("Serving install page")
|
||||||
|
let installPage = """
|
||||||
|
<script type="text/javascript">
|
||||||
|
window.location = "\(installURL)"
|
||||||
|
</script>
|
||||||
|
"""
|
||||||
|
return HTTPResponse(.ok, headers: ["Content-Type": "text/html"], content: installPage)
|
||||||
|
})
|
||||||
|
|
||||||
try! server.start(port: 9090)
|
try! server.start(port: 9090)
|
||||||
print("Server has started listening")
|
print("Server has started listening")
|
||||||
|
|
||||||
DispatchQueue.main.async {
|
DispatchQueue.main.async {
|
||||||
print("Requesting app install")
|
print("Requesting app install")
|
||||||
let finalURL = "https://api.palera.in/genPlist?bundleid=\(appBundleId)&name=\(appBundleId)&version=\(appVersion)&fetchurl=http://127.0.0.1:9090/signed.ipa"
|
let majoriOSVersion = Int(UIDevice.current.systemVersion.components(separatedBy: ".").first!)!
|
||||||
let finalURLfr = "itms-services://?action=download-manifest&url=" + finalURL.addingPercentEncoding(withAllowedCharacters: .alphanumerics)!
|
if majoriOSVersion >= 18 {
|
||||||
UIApplication.shared.open(URL(string: finalURLfr)!)
|
// iOS 18+ ( idk why this is needed but it seems to fix it for some people )
|
||||||
|
let safariView = SafariWebView(url: URL(string: "http://127.0.0.1:9090/install")!)
|
||||||
|
UIApplication.shared.windows.first?.rootViewController?.present(UIHostingController(rootView: safariView), animated: true, completion: nil)
|
||||||
|
} else {
|
||||||
|
// iOS 17-
|
||||||
|
UIApplication.shared.open(URL(string: installURL)!)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
while server.isRunning {
|
while server.isRunning {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue