3

I would like to open zip files with my app and configured the following:

Document Types enter image description here

This leads to the desired appearing of my app in other app's share sheet. But when I tap my app in that share sheet, my app is opened, but the following method in my AppDelegate is never called:

func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool

It's a iOS 13 application - what am I missing here?

swalkner
  • 16,679
  • 31
  • 123
  • 210
  • 1
    Haven't tested but afaik, if the app is not launched then it will be available in `application(_:didFinishLaunchingWithOptions)`. If app is in background then `application(_:open:options:)` should be called. – staticVoidMan Nov 25 '19 at 10:20
  • the app is running, then I'm switching to another app, open share sheet and select my app, so it should be running in background – swalkner Nov 25 '19 at 10:21
  • What about `application(_:continue:restorationHandler:)`? – staticVoidMan Nov 25 '19 at 10:24
  • just returns `true`, but isn't called either – swalkner Nov 25 '19 at 10:25
  • so none of the 3 methods are called: `application(_:didFinishLaunchingWithOptions)` / `application(_:open:options:)` / `application(_:continue:restorationHandler:)`? – staticVoidMan Nov 25 '19 at 10:26
  • exactly, yes. In the logs I see `Can't end BackgroundTask: no background task exists with identifier 1 (0x1), or it may have already been ended. Break in UIApplicationEndBackgroundTaskError() to debug.` – swalkner Nov 25 '19 at 10:35
  • iOS 13 bug? Ref: https://stackoverflow.com/a/58083223/2857130 – staticVoidMan Nov 25 '19 at 10:38
  • the question is if this is related (can't imagine as then no app could handle files...) or if I'm still missing something (pretty sure) – swalkner Nov 25 '19 at 10:39
  • @swalkner I might be wrong here but I dont know if Apple allows passing zip files between apps. Have you tried it with a simple image. See if that works first. – AD Progress Nov 30 '19 at 14:19
  • https://stackoverflow.com/a/58625433/341994 – matt Nov 30 '19 at 20:34
  • Does this answer your question? [Method 'application:openURL:options:' is not called](https://stackoverflow.com/questions/58624786/method-applicationopenurloptions-is-not-called) – Hejazi Dec 17 '19 at 11:28

1 Answers1

10

If your app is using scenes, then instead of application(_:open:options:) from UIApplicationDelegate protocol, iOS will call scene(_:openURLContexts:) from UISceneDelegate.

https://developer.apple.com/documentation/uikit/uiscenedelegate/3238059-scene

Also probably it's better to change com.pkware.Zip-archive to com.pkware.zip-archive as it's defined as lowercase in the list of System-Declared UTIs

grandboum
  • 622
  • 4
  • 5