When clicking the 'share' button in iOS Safari (either from the toolbar, or by long-pressing a link), I would like my app to be visible as an "Open in..." option (eg. "Open in News"), so that my app β which is another type of web browser β can open whatever http://
or https://
URL is shared by Safari.
I've registered the document type 'URL' (which I believe is the correct type β please correct me if this assumption is wrong!) in my info.plist
file's CFBundleDocumentTypes
as best as I can guess from Apple's 'Registering the File Types Your App Supports' documentation, their Technical Q&A, and these related StackOverflow posts 1 2 3:
<key>CFBundleDocumentTypes</key>
<array>
<dict>
<key>CFBundleTypeIconFiles</key>
<array>
<string>appIcon320</string>
<string>appIcon64</string>
</array>
<key>CFBundleTypeName</key>
<string>URL</string>
<key>CFBundleTypeRole</key>
<string>Editor</string> <!-- Note: I have also tried 'Viewer' -->
<key>LSHandlerRank</key>
<string>Owner</string> <!-- Note: I have also tried 'Default' -->
<key>LSItemContentTypes</key>
<array>
<string>public.url</string>
</array>
</dict>
</array>
I have also written this stub method in AppDelegate.swift
(although I think it is in fact irrelevant to the success of this first stage of getting my app to appear as an "Open in..." option):
func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any] = [:]) -> Bool {opening-in-app-getting-uiapplicationlaunchoptionsurlkey-from-launchoptions?rq=1
print("Received URL: \(url); from source: \(options[.sourceApplication] ?? "nil"); with annotation: \(options[.annotation] ?? "nil")")
return true
}
... However, my app is still not appearing as an "Open in..." option. I must add that the app icons are correctly bundled with the app, and that the info.plist
file opens fine in Xcode, so I can confirm that is not corrupt.
So I have three questions:
Having long-pressed on a link and tapped the 'Share...' button, is the document type shared by Safari indeed 'URL'?
Having pressed on the graphical button in Safari's toolbar which looks like π€ (confusingly also called a 'share' button), is the document type shared by Safari, as before, 'URL'?
Have I written the
CFBundleDocumentTypes
correctly for a document of URL type? Or if Safari shares something else, what is it (and how should I write it)?