Files
SideStore/AltStoreCore/Intents/ViewAppIntentHandler.swift

33 lines
1.0 KiB
Swift
Raw Normal View History

//
// ViewAppIntentHandler.swift
// ViewAppIntentHandler
//
// Created by Riley Testut on 7/10/20.
// Copyright © 2020 Riley Testut. All rights reserved.
//
import Intents
import AltStoreCore
public class ViewAppIntentHandler: NSObject, ViewAppIntentHandling
{
public func provideAppOptionsCollection(for intent: ViewAppIntent, with completion: @escaping (INObjectCollection<App>?, Error?) -> Void)
{
DatabaseManager.shared.start { (error) in
if let error = error
{
print("Error starting extension:", error)
}
DatabaseManager.shared.persistentContainer.performBackgroundTask { (context) in
let apps = InstalledApp.all(in: context).map { (installedApp) in
return App(identifier: installedApp.bundleIdentifier, display: installedApp.name)
}
let collection = INObjectCollection(items: apps)
completion(collection, nil)
}
}
}
}