auto run shortcut to open PB
This commit is contained in:
1 parent
32da6b41c4
commit
3bad6ffe14
2 files changed
+11
-2
No files matched your search
@@ -7,6 +7,7 @@
|
||||
|
||||
import Foundation
|
||||
import ZIPFoundation
|
||||
import UIKit
|
||||
|
||||
class PosterBoardManager {
|
||||
private static func unzipFile(at url: URL) throws -> URL {
|
||||
@@ -40,6 +41,12 @@ class PosterBoardManager {
|
||||
return destinationURL
|
||||
}
|
||||
|
||||
static func runShortcut(named name: String) {
|
||||
guard let urlEncodedName = name.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed),
|
||||
let url = URL(string: "shortcuts://run-shortcut?name=\(name)") else { return }
|
||||
UIApplication.shared.open(url, options: [:], completionHandler: nil)
|
||||
}
|
||||
|
||||
static func getDescriptorsFromTendie(_ url: URL) throws -> URL? {
|
||||
let unzippedDir = try unzipFile(at: url)
|
||||
|
||||
|
||||
@@ -60,7 +60,7 @@ struct ContentView: View {
|
||||
Button(action: {
|
||||
do {
|
||||
try PosterBoardManager.applyTendies(selectedTendies, appHash: pbHash)
|
||||
lastError = "Please open PosterBoard in the Shortcuts app and then close it from the app switcher."
|
||||
lastError = "The PosterBoard app will now open. Please close it from the app switcher."
|
||||
showSuccessAlert.toggle()
|
||||
} catch {
|
||||
lastError = error.localizedDescription
|
||||
@@ -91,7 +91,9 @@ struct ContentView: View {
|
||||
Text(lastError ?? "???")
|
||||
}
|
||||
.alert("Success!", isPresented: $showSuccessAlert) {
|
||||
Button("OK") {}
|
||||
Button("OK") {
|
||||
PosterBoardManager.runShortcut(named: "PosterBoard") // shortcut url: https://www.icloud.com/shortcuts/9035ef1d51c247dba8c9861dc10b4aa7
|
||||
}
|
||||
} message: {
|
||||
Text(lastError ?? "???")
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user