Post

Replies

Boosts

Views

Activity

Reply to LockedCameraCapture - Lock Screen Camera Capture UI Question
Thanks for the quick reply. it should be given to your Control in the Widget Extension as the App Intent that needs to be run. I think I'm doing this too. Here the code of my control: struct LockedCameraWidgetExtensionControl: ControlWidget { var body: some ControlWidgetConfiguration { StaticControlConfiguration( kind: "com.Yuju.LockedCameraPlayground.LockedCameraWidgetExtension") { ControlWidgetButton(action: MyAppCaptureIntent()) { Label("Capture", systemImage: "camera") } } } } And since we are here, this is my ViewFinder: struct LockedCameraExtensionViewFinder: UIViewControllerRepresentable { let session: LockedCameraCaptureSession var sourceType: UIImagePickerController.SourceType = .camera init(session: LockedCameraCaptureSession) { self.session = session } func makeUIViewController(context: Self.Context) -> UIImagePickerController { let imagePicker = UIImagePickerController() imagePicker.sourceType = sourceType imagePicker.mediaTypes = [UTType.image.identifier, UTType.video.identifier] imagePicker.cameraDevice = .rear return imagePicker } func updateUIViewController(_ uiViewController: UIImagePickerController, context: Self.Context) { } }
Jun ’24
Reply to LockedCameraCapture - Lock Screen Camera Capture UI Question
Somehow related, I'm trying to build an example app to get familiar with this new extension. I followed the steps in the docs but I think I'm missing something. I added the Control through a Widget Extension, and I see that the perform method is called in my Intent, however I'm missing the part where this perform method would open the UI to capture the photos. This is my Intent: struct MyAppCaptureIntent: CameraCaptureIntent { static var title: LocalizedStringResource = "MyAppCaptureIntent" typealias AppContext = MyAppContext static let description = IntentDescription("Capture photos with MyApp.") @MainActor func perform() async throws -> some IntentResult { let dialog = IntentDialog("Intent result") do { if let context = try await MyAppCaptureIntent.appContext { return .result() } } catch { // Handle error condition. } return .result() } } struct MyAppContext: Decodable, Encodable { var data = ContextData() } struct ContextData: IntentResult, Decodable, Encodable { var value: Never? { nil } } How do I connect this with my LockedCameraCaptureExtension?
Jun ’24