In my Iphone app, I want to open json files that I have earlier saved. The function I mention below to open the file is not firing when I share a file to my app.
I have implemented this in the info.plist file and this seems to work, because in Files I can share a .json file to may app.
<key>CFBundleDocumentTypes</key>
<array>
<dict>
<key>CFBundleTypeName</key>
<string>JSON Document</string>
<key>LSHandlerRank</key>
<string>Alternate</string>
<key>LSItemContentTypes</key>
<array>
<string>public.json</string>
</array>
</dict>
</array>
I have added the function to open the file in my AppDelegate file.
func application(_ application: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
// Handle the file at the given URL
// You can perform actions based on the file type or content
print("Opening file!")
}
(the implementation is actually longer to work on the file).
When I share a file to my app, the app itself is opening but this method 'application' is never called.
I'm not sure whether I'm overlooking something. I have searched quite a while to see what I'm missing.
Any help is greatly appreciated!
Emile