Registering an iOS extension to a URL scheme - ios

I don't think this is possible but I've not been able to find anything conclusive.
Ideally I would like to register my Action Extension to be launched by a specific scheme - instead of my main application. I want this because of the benefit of being able to return to the previous application after completion.
Thanks.

As i understand your question, you want to accept specific schemes in your application but want only extension to be configured to it.
Well this is fairly possible. You can create extension for your application and add URL schemes to the extension only. Remove specific URL schemes from your apps plist and add it to the extensions plist.

Related

How can I open my app directly from the iOS Share Sheet?

Update: don't have time yet to test provided answer, but will keep this answer updated as I try different things.
In the iOS 14 Simulator, when I open the share sheet and click their Share Target, the Apple News app is launched immediately and they check if the shared URL has been added to their index.
My question is how are they launching their app immediately without any user interaction?
A gif is worth about 100,000 words: https://giphy.com/gifs/HPzTNyWGDDMVwASQ9z
I would imagine it may be some combination of registering a Universal Link and then programmatically triggering that from the Share Extension View Controller, but I’m wondering if anyone has any better ideas.
A couple of other places I've asked:
Swift Subreddit
iOS Programming Subreddit
This is just an open URL call to a news app. Prior to iOS 14, it was named as copy to app name.
To achieve this you need to specify the supported document type for your application in plist using key CFBundleDocumentTypes.
Refer to apple documentation for more info:
https://help.apple.com/xcode/mac/current/#/devddd273fdd
There is a change in share sheet option listings.
case 1: When your application doesn't support any kind of extension. And have supported document add to plist. Your application will appear in the share sheet for supporting documents. On tap, your application gets an OpenURL call with the URL of the document shared.
case 2: Your application supports share extension or action extension, then your open URL call option for your application will not appear in the share sheet. if the share extension and action extension activation predicate are not satisfied and the document shared is supported by your application that option will appear the same as case 1. (Summary: if share extension or action extension is listed in share sheet then open URL option will not be listed.)
Note: Limitation of openURL call is, it supports only a single URL. For example, you are sharing multiple files, your application OpenURL option will appear. But on tap, your application will receive only one URL.
If your requirement is sharing only a single URL and your application doesn't have a share extension and action extension. Then key CFBundleDocumentTypes is your friend.

willBeginSendingToApplication not called when open EverNote or any other extention

I have a feature to open docs in other apps from iPhone and iPad app.
Also a flag is set whether to allow this action or not. Few apps can be white listed.
When any app is chosen to open doc
- (void)documentInteractionController:(UIDocumentInteractionController *)controller willBeginSendingToApplication:(NSString *)application
is called.
In this method I can check whether to allow for chosen app or not.
Issue is for Note, Evernote we get two options 1- its extension 2- Open in.
Above method is called for 2 option.
But extensions are launched directly.
I din't found any other delegate method called for this.
Hopefully you figured something out, but my org faced a similar issue and the MDMs we work with don't have an easy solution. We've decided on the following approach.
Always use UIDocumentInteractionController instead of UIActivityViewController
Whenever UIDocumentInteractionController is opened reinit and set the URL to dummy content
Conform to UIDocumentInteractionControllerDelegate and check the application parameter in willBeginSendingToApplication against your whitelist
If application is part of the whitelist then change the value of controller.url to the correct content
The downsides of this approach are that only open-in will work (extensions will always get dummy content) and the user experience isn't great. But if you're building an enterprise app and must prevent data leakage then this is probably the safest way to go.
You can also check out this article for private APIs to hide third-party apps and extensions, mostly in UIActivityViewController:
How to exclude Notes and Reminders apps from the UIActivityViewController?
Unfortunately the way this works seems to have changed between iOS 8 and 9, and again with 10, so it's not optimal. I recommend passing dummy content.

Custom URL Scheme and http

Using my iPhone i noticed that when i open a youtube link like http://m.youtube.com/..., this is redirect to the native Youtube app.
I would like to do the same thing but using my custom url scheme, so i would like to have a custom url, if my app is installed in the device this is redirected in it, or if it's not installed, to do something else.
I've tried to register as a custom url scheme the "http://" url scheme, but the is not listening for these urls.
edit-
I've already tried to register my custom url scheme, i want to use an html page, in that page i want to put my custom url scheme, but the problem is that i can't detect, from the web page, if the app is installed in the device
Take a look to the Associated Domains.
If I understand well your question you need to define your own domain that will be associated to your app. Every time an app will find that specific domain the OS will check if any installed app can handle it.
You need to add the capabilities as specified by Apple here
Hope it helps
For that you need to create your custom URL Schema for that you can open via another app.
Following is the Tutorial where you can create your own URL Schema and use into your app.
Here is tutorial.
You can define custom url schemes that will open your app, but you can't make your app the designated handler for certain domain names so that opening that domain in Safari will launch your app automatically.
And One thing for more detail this solution given into this question also.
Happy coding.
You need to add your custom URL schemes in Info.plist. With this schema you can launch your app.

Is it possible to have access to the image specified in CFBundleURLIconFile via URL scheme from a different iOS app?

is it possible to access the icon specified with CFBundleURLIconFile in the info.plist file from a different application? Does application sandboxing prevent it? If so,what is the purpose of this key(in an iOS app of course)?
Thanks
As stated in CoreFoundationKeys docs: "CFBundleURLTypes contains an array of dictionaries, each of which describes the URL schemes (http, ftp, and so on) supported by the application. The purpose of this key is similar to that of “CFBundleDocumentTypes,” but it describes URL schemes instead of document types."
The purpose is to permit applications to register for some type of documents allowing an app to handle the opening of files from other installed app (you surely met the "Open In..." button, for example in Mail when you receive a file).
More on this in the Document Interaction Programming Topics for iOS.
EDIT:
Sorry, I forgot to answer to your main question: AFAIK the only way to access that key is through UIDocumentInteractionController.

Is there a list of iOS apps that can be called using custom URLs?

It is possible to launch your own app via custom URL scheme as described at http://iosdevelopertips.com/cocoa/launching-your-own-application-via-a-custom-url-scheme.html for example. Is there a list of the apps that use this mechanism somewhere already? A list of custom URLs available to date? If you have or know an app that uses this mechanism, adding it here will also help.
See http://wiki.akosma.com/IPhone_URL_Schemes
http://www.onemillionappschemes.com, an open source Custom URL scheme site where you can contribute URLS (by scanning your iTunes library) and where you can pick up everything that has been found so far

Resources