LockedCameraCapture Does Not Launch The App from Lock Screen

My implementation of LockedCameraCapture does not launch my app when tapped from locked screen. But when the same widget is in the Control Center, it launches the app successfully.

Standard Xcode target template:

Lock_Screen_Capture.swift

@main
struct Lock_Screen_Capture: LockedCameraCaptureExtension {
    var body: some LockedCameraCaptureExtensionScene {
        LockedCameraCaptureUIScene { session in
            Lock_Screen_CaptureViewFinder(session: session)
        }
    }
}

Lock_Screen_CaptureViewFinder.swift:

import SwiftUI
import UIKit
import UniformTypeIdentifiers
import LockedCameraCapture

struct Lock_Screen_CaptureViewFinder: 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.movie.identifier]
        imagePicker.cameraDevice = .rear
 
        return imagePicker
    }
 
    func updateUIViewController(_ uiViewController: UIImagePickerController, context: Self.Context) {
    }
}

Then I have my widget:

struct CameraWidgetControl: ControlWidget {
    var body: some ControlWidgetConfiguration {
        StaticControlConfiguration(
            kind: "com.myCompany.myAppName.lock-screen") {
                ControlWidgetButton(action: MyAppCaptureIntent()) {
                    Label("Capture", systemImage: "camera.shutter.button.fill")
                }
        }
    }
}

My AppIntent:

struct MyAppContext: Codable {}

struct MyAppCaptureIntent: CameraCaptureIntent {
    
    typealias AppContext = MyAppContext
    static let title: LocalizedStringResource = "MyAppCaptureIntent"
    static let description = IntentDescription("Capture photos and videos with MyApp.")


    @MainActor
    func perform() async throws -> some IntentResult {
        .result()
    }
}

The Issue

LockedCameraCapture Widget does not launch my app when tapped from locked screen. You get the Face ID prompt and takes you to just Home Screen. But when the same widget is in the Control Center, it launches the app successfully.

Error Message

When tapped on Lock Screen, I get the following error code:

LaunchServices: store ‹private > or url ‹private > was nil: Error Domain=NSOSStatusErrorDomain Code=-54 "process may not map database"
UserInfo=&NSDebugDescription=process may not map database, _LSLine=72, _LSFunction=_LSServer_GetServerStoreForConnectionWithCompletionHandler}

Attempt to map database failed: permission was denied. This attempt will not be retried.

Failed to initialize client context with error Error Domain=NSOSStatusErrorDomain Code=-54 "process may not map database"
UserInfo=&NSDebugDescription=process may not map database, _LSLine=72, _LSFunction=_LSServer_GetServerStoreForConnectionWithCompletionHandler}

Things I tried

  • Widget image displays correctly
  • App ID and the Provisioning Profile seem to be fine since they work fine when the same code injected in to AVCam sample app and when used the same App ID's.
  • AppIntent file contains the target memberships of the Lock Screen capture and Widget
  • Apple compiles without errors or warnings.
Answered by sle39lvr in 861859022

I was able to resolve this issue by adding:

NSCameraUsageDescription
NSLocationWhenInUseUsageDescription
NSPhotoLibraryUsageDescription

to the info.plist of the locked camera capture target.

Accepted Answer

I was able to resolve this issue by adding:

NSCameraUsageDescription
NSLocationWhenInUseUsageDescription
NSPhotoLibraryUsageDescription

to the info.plist of the locked camera capture target.

LockedCameraCapture Does Not Launch The App from Lock Screen
 
 
Q