mirror of
https://github.com/SideStore/SideStore.git
synced 2026-02-12 16:23:32 +01:00
feat: merge #282 as an unstable feature
This commit is contained in:
26
AltStore/Extensions/UIApplication+Alert.swift
Normal file
26
AltStore/Extensions/UIApplication+Alert.swift
Normal file
@@ -0,0 +1,26 @@
|
||||
//
|
||||
// UIApplication+Alert.swift
|
||||
// SideStore
|
||||
//
|
||||
// Created by naturecodevoid on 5/20/23.
|
||||
// Copyright © 2023 SideStore. All rights reserved.
|
||||
//
|
||||
|
||||
extension UIApplication {
|
||||
static func alertOk(title: String?, message: String?) {
|
||||
let alert = UIAlertController(title: title, message: message, preferredStyle: .alert)
|
||||
alert.addAction(UIAlertAction(title: NSLocalizedString("Ok", comment: ""), style: .default))
|
||||
|
||||
DispatchQueue.main.async {
|
||||
let keyWindow = UIApplication.shared.windows.filter { $0.isKeyWindow }.first
|
||||
if var topController = keyWindow?.rootViewController {
|
||||
while let presentedViewController = topController.presentedViewController {
|
||||
topController = presentedViewController
|
||||
}
|
||||
topController.present(alert, animated: true)
|
||||
} else {
|
||||
print("No key window!")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,7 @@
|
||||
import UIKit
|
||||
import AltStoreCore
|
||||
import EmotionalDamage
|
||||
import minimuxer
|
||||
|
||||
@available(iOS 13, *)
|
||||
final class SceneDelegate: UIResponder, UIWindowSceneDelegate
|
||||
@@ -92,6 +93,7 @@ private extension SceneDelegate
|
||||
{
|
||||
guard let components = URLComponents(url: context.url, resolvingAgainstBaseURL: false) else { return }
|
||||
guard let host = components.host?.lowercased() else { return }
|
||||
let queryItems = components.queryItems?.reduce(into: [String: String]()) { $0[$1.name.lowercased()] = $1.value } ?? [:]
|
||||
|
||||
switch host
|
||||
{
|
||||
@@ -107,7 +109,6 @@ private extension SceneDelegate
|
||||
{
|
||||
case "/success": result = .success(())
|
||||
case "/failure":
|
||||
let queryItems = components.queryItems?.reduce(into: [String: String]()) { $0[$1.name] = $1.value } ?? [:]
|
||||
guard
|
||||
let errorDomain = queryItems["errorDomain"],
|
||||
let errorCodeString = queryItems["errorCode"], let errorCode = Int(errorCodeString),
|
||||
@@ -125,7 +126,6 @@ private extension SceneDelegate
|
||||
}
|
||||
|
||||
case "install":
|
||||
let queryItems = components.queryItems?.reduce(into: [String: String]()) { $0[$1.name.lowercased()] = $1.value } ?? [:]
|
||||
guard let downloadURLString = queryItems["url"], let downloadURL = URL(string: downloadURLString) else { return }
|
||||
|
||||
DispatchQueue.main.async {
|
||||
@@ -133,13 +133,34 @@ private extension SceneDelegate
|
||||
}
|
||||
|
||||
case "source":
|
||||
let queryItems = components.queryItems?.reduce(into: [String: String]()) { $0[$1.name.lowercased()] = $1.value } ?? [:]
|
||||
guard let sourceURLString = queryItems["url"], let sourceURL = URL(string: sourceURLString) else { return }
|
||||
|
||||
DispatchQueue.main.async {
|
||||
NotificationCenter.default.post(name: AppDelegate.addSourceDeepLinkNotification, object: nil, userInfo: [AppDelegate.addSourceDeepLinkURLKey: sourceURL])
|
||||
}
|
||||
|
||||
case "sidejit-enable":
|
||||
guard UnstableFeatures.enabled(.jitUrlScheme) else { return UIApplication.alertOk(title: "JIT URL scheme unstable feature is not enabled", message: nil) }
|
||||
|
||||
if let bundleID = queryItems["bid"] {
|
||||
DispatchQueue.main.async {
|
||||
do {
|
||||
try debug_app(bundleID)
|
||||
} catch {
|
||||
UIApplication.alertOk(title: "An error occurred when enabling JIT", message: error.localizedDescription)
|
||||
}
|
||||
}
|
||||
} else if let processID = queryItems["pid"] {
|
||||
DispatchQueue.main.async {
|
||||
do {
|
||||
guard let processID = UInt32(processID) else { return UIApplication.alertOk(title: "An error occurred when enabling JIT", message: "Process ID is not a valid unsigned integer") }
|
||||
try attach_debugger(processID)
|
||||
} catch {
|
||||
UIApplication.alertOk(title: "An error occurred when enabling JIT", message: error.localizedDescription)
|
||||
}
|
||||
}
|
||||
} else { return UIApplication.alertOk(title: "An error occurred when enabling JIT", message: "Please specify a bundle ID using the `bid` query parameter or a process ID using `pid` query parameter") }
|
||||
|
||||
default: break
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,8 @@ enum AvailableUnstableFeature: String, CaseIterable {
|
||||
//
|
||||
// Unstable features must have a GitHub Issue for tracking progress, PRs and feedback/commenting.
|
||||
|
||||
case jitUrlScheme = "0"
|
||||
|
||||
/// Dummy variant to ensure there is always at least one variant. DO NOT USE!
|
||||
case dummy = "dummy"
|
||||
|
||||
@@ -20,6 +22,7 @@ enum AvailableUnstableFeature: String, CaseIterable {
|
||||
// If your unstable feature is stable enough to be used by nightly users who are not alpha testers or developers,
|
||||
// you may want to have it available in the "Unstable Features" menu in Settings (outside of dev mode). To do so, add this:
|
||||
//case .yourFeature: return true
|
||||
case .jitUrlScheme: return true
|
||||
|
||||
default: return false
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user