2020-09-15 15:19:12 -07:00
|
|
|
//
|
|
|
|
|
// ViewAppIntentHandler.swift
|
|
|
|
|
// ViewAppIntentHandler
|
|
|
|
|
//
|
|
|
|
|
// Created by Riley Testut on 7/10/20.
|
|
|
|
|
// Copyright © 2020 Riley Testut. All rights reserved.
|
|
|
|
|
//
|
|
|
|
|
|
2023-03-01 00:48:36 -05:00
|
|
|
import SideStoreCore
|
2020-09-15 15:19:12 -07:00
|
|
|
import Intents
|
|
|
|
|
|
|
|
|
|
@available(iOS 14, *)
|
2023-03-01 00:48:36 -05:00
|
|
|
public class ViewAppIntentHandler: NSObject, ViewAppIntentHandling {
|
|
|
|
|
public func provideAppOptionsCollection(for _: ViewAppIntent, with completion: @escaping (INObjectCollection<App>?, Error?) -> Void) {
|
|
|
|
|
DatabaseManager.shared.start { error in
|
|
|
|
|
if let error = error {
|
2020-09-15 15:19:12 -07:00
|
|
|
print("Error starting extension:", error)
|
|
|
|
|
}
|
2023-03-01 00:48:36 -05:00
|
|
|
|
|
|
|
|
DatabaseManager.shared.persistentContainer.performBackgroundTask { context in
|
|
|
|
|
let apps = InstalledApp.all(in: context).map { installedApp in
|
|
|
|
|
App(identifier: installedApp.bundleIdentifier, display: installedApp.name)
|
2020-09-15 15:19:12 -07:00
|
|
|
}
|
2023-03-01 00:48:36 -05:00
|
|
|
|
2020-09-15 15:19:12 -07:00
|
|
|
let collection = INObjectCollection(items: apps)
|
|
|
|
|
completion(collection, nil)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|