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 Foundation
|
||||||
import ZIPFoundation
|
import ZIPFoundation
|
||||||
|
import UIKit
|
||||||
|
|
||||||
class PosterBoardManager {
|
class PosterBoardManager {
|
||||||
private static func unzipFile(at url: URL) throws -> URL {
|
private static func unzipFile(at url: URL) throws -> URL {
|
||||||
@@ -40,6 +41,12 @@ class PosterBoardManager {
|
|||||||
return destinationURL
|
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? {
|
static func getDescriptorsFromTendie(_ url: URL) throws -> URL? {
|
||||||
let unzippedDir = try unzipFile(at: url)
|
let unzippedDir = try unzipFile(at: url)
|
||||||
|
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ struct ContentView: View {
|
|||||||
Button(action: {
|
Button(action: {
|
||||||
do {
|
do {
|
||||||
try PosterBoardManager.applyTendies(selectedTendies, appHash: pbHash)
|
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()
|
showSuccessAlert.toggle()
|
||||||
} catch {
|
} catch {
|
||||||
lastError = error.localizedDescription
|
lastError = error.localizedDescription
|
||||||
@@ -91,7 +91,9 @@ struct ContentView: View {
|
|||||||
Text(lastError ?? "???")
|
Text(lastError ?? "???")
|
||||||
}
|
}
|
||||||
.alert("Success!", isPresented: $showSuccessAlert) {
|
.alert("Success!", isPresented: $showSuccessAlert) {
|
||||||
Button("OK") {}
|
Button("OK") {
|
||||||
|
PosterBoardManager.runShortcut(named: "PosterBoard") // shortcut url: https://www.icloud.com/shortcuts/9035ef1d51c247dba8c9861dc10b4aa7
|
||||||
|
}
|
||||||
} message: {
|
} message: {
|
||||||
Text(lastError ?? "???")
|
Text(lastError ?? "???")
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user