I have a SwiftUI app (XCode 14 / iOS 15+) that tries to receive fmp12 files sent from the FileMaker app (using the share sheet). I got to the point that my app is shown in the share sheet and gets started. What I cannot achieve is access to the file.
Following some tutorials and Apple's documentation I imported "com.filemaker.fmp12" as an imported type identifier in my plist.info and added it to Document Types.
first strategy: DocumentGroup
To access the file I have first tried to use a DocumentGroup in SwiftUI based on Apple's documentation here: https://developer.apple.com/documentation/swiftui/documentgroup
@main
struct KioskBridgeApp: App {
var body: some Scene {
DocumentGroup(viewing: FMP12File.self) { file in
KioskBridgeView(file: file.fileURL?.absoluteString ?? "undefined")
}
}
While this works when I send an fmp12 file with the files app, it does not work when I send it from FileMaker: Then it always starts with the Document Browser. The document browser also opens when I start the app without sending anything to it and I could not find a hint how to suppress that.
So I developed the feeling that I might be on the wrong track entirely with DocumentGroup here and so tried I strategy number 2:
second strategy: App delegate
Using an Application Delegate as suggested here https://stackoverflow.com/a/46572886 and as for the Adaptor here: SwiftUI app life cycle iOS14 where to put AppDelegate code? and here https://developer.apple.com/documentation/swiftui/uiapplicationdelegateadaptor
class MyAppDelegate: NSObject, UIApplicationDelegate {
func application(_ application: UIApplication, open url: URL, sourceApplication: String?, annotation: Any) -> Bool {
print("application opened with \(url.absoluteString)")
return true
}
@main
struct DelegateTestApp: App {
@UIApplicationDelegateAdaptor(MyAppDelegate.self) var appDelegate
var body: some Scene {
WindowGroup {
ContentView()
}
}
}
But this delegate is never called, not even when I open my app using the files app.
I am fairly new to iOS development, so even after hours of reading I am not even sure that any of those strategies is even the right approach. Any help would be highly appreciated.