iOS - AppDelegate not called from sharing an image

Hi,


I declared the type "public.image" in Info/ Document Types:

- name: Image file

- Types: public.image

- in additional document type properties:

- CFBundleTypeRole: Viewer

- LSHandlerRank: Alternate


In addition, in info.plist, "Supports opening documents in place" is "YES"


When I long press on an image from my iPhone, I can select my app in the sharing menu, app is launching but the function that should be called in AppDelegate is not called:


func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
print("open url")
AudioServicesPlayertSound(SystemSoundID(kSystemSoundID_Vibrate))
    return true }`

Any clue ?


XCode 11.1, iOS 13.1.3


My test app has only the code and settings mentioned above.


Thanks,

Nicolas

Replies

A possible reason why it should not be called, in doc:


Instance Methodapplication(_:open:options:)


Asks the delegate to open a resource specified by a URL, and provides a dictionary of launch options.


Discussion

This method is not called if your implementations return

false
from both the
application(_:willFinishLaunchingWithOptions:)
and
application(_:didFinishLaunchingWithOptions:)
methods. (If only one of the two methods is implemented, its return value determines whether this method is called.) If your app implements the
applicationDidFinishLaunching(_:)
method instead of
application(_:didFinishLaunchingWithOptions:)
, this method is called to open the specified URL after the app has been initialized.


Could you check ?

Thanks for your help.


I saw this possible reason in the documentation; I only have the function

application(_:didFinishLaunchingWithOptions:)

that returns true:


func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        // Override point for customization after application launch.
        print("did finish launching")
       
        return true
    }

Unless some problem in the URL itself, I cannot see other reason.

Would you have (or know where it would be available) an example of a xCode project with the few lines of code that are working for that purpose, so that I can check if it works for me, and in that case what are the differences with my few lines of code ?


Thanks

Nicolas