How do I manually trigger a specific app's share extension? - ios

When I share a file via iOS' UIActivityViewController, I can press the "More" button and see a bunch of apps that I can send my file to. My question is: how can I add a button in my app that would send a file specifically to one of these apps (provided that it's installed of course)? Like a "Send to Slack" button or something like that.
Please note that I am not asking how to show a UIActivityViewController, that's working just fine. I want to programmatically send a file to one of the apps that are listed in the UIActivityViewController's Apps that can receive said file.

Related

Open iOS mail attachment directly in app bypassing "Open in..." menu

My app defines a custom document type and when I tap on an attachment my app appears in the "Open in..." menu however I was wondering if it was possible to not show this menu at all but rather open the file immediately in the app.
No, not possible. You have no control over what the Mail app shows to the user when an attachment is selected. The Mail app, like many other apps, uses a UIActivityViewController to give the user lots of other choices. Opening the attachment in your app is only one possible action a user may want to perform on the email attachment.

XCODE / IOS - How to use exclusive extension to immediately present whatsapp (.wai, .waa, .wam)

Is there any way to make work that part of the whatsapp document interaction API:
Alternatively, if you want to show only WhatsApp in the application list (instead of WhatsApp plus any other public/*-conforming apps) you can specify a file of one of aforementioned types saved with the extension that is exclusive to WhatsApp:
images - «.wai» which is of type net.whatsapp.image
videos - «.wam» which is of type net.whatsapp.movie
audio files - «.waa» which is of type net.whatsapp.audio
When triggered, WhatsApp will immediately present the user with the contact/group picker screen. The media will be automatically sent to a selected contact/group.
I don't really ask for a code example as I almost tried eveything, but more if someone ever successfully opened the whatsapp application WITHOUT passing through the share menu (with messenger tile, whatsapp, notepad...) ?
FYI: As I went through a lot of tests with this, I couldn't find any solution yet.
Whatsapp recognize the file extension, but cannot even read it. Once shared, when you click on it, it's written ".whatsapp audio file", nothing more (And it's not even shared directly).
I sent a email to whatsapp developper team, they said they have others problem to fix currently, so it's not even on their to do list.
Wait & see..

Act as exclusive handler for custom email attachment types

I am writing an IOS app that needs to be sent a specific file type via email. I have this working - I created a custom attachment type, and I handle opening it in my application delegate's openURL: function. But, when you click on the attachment in the Mail app, it gives you a horizontal list of applications to open the attachment type - such as iMessage, Mail, Notes, Messenger, and some others. My app is in there too. So to open the file in my app, you go through the following sequence:
Click on the attachment in the Mail app
The box pops up asking you to choose the app to open the attachment in
You scroll over and choose my app
The file is opened in my app.
I would like to skip steps 2 and 3. Is there any way to do this? This attachment file is something that will only be handled by my app. I'd like to register my app as the "exclusive" handler for this custom attachment type. Or something like that...
Thanks in advance.

"Open in" feature in UIActivityViewController

I need your help with UIActivityViewController.
I need to present activity controller for the file where, except for default actions, the user will be able to open the file in other apps.
I know how to do this with UIDocumentController, which shows popover with all apps able to open the file.
But how can I show all these apps in UIActivityViewController?
P.S. This behavior can be seen in Apple Mail app, for example.
Look at TTOpenInAppActivity for a way to combine both a UIActivityViewController (for normal sharing), and an 'Open in' button on that which brings up a UIDocumentInteractionController. Pre-iOS 8, that is the best way to manage this.
The function and behavior is different between UIActivityViewController and UIDocumentController.
UIActivityViewController
Presents activities that are pre-defined, you can pass an array to select which ones should be excluded among the default ones that are presented, if you want to add more activities you have to use custom activities, unfortunately these will appear bellow the rest of the activities and even more, the icon will always be gray, your app never loses control since you can use delegates and other stuff to know what is going on on those apps. (Unless you manually make an activity which opens another app)
UIDocumentController
This one asks the system for all the registered applications for a certain file extension, many apps have registered their exclusive extensions which makes it so that this app will be the only one displayed. If you pass an image, you will see all the apps that can handle this file. When using this one your app will lose control since the other app will be opened.
What is your final objective?, If you describe it with more detail we could offer you a better solution.
From what i understand, you should see yourself what type of file the user is trying to open, and then yourself open it with the most suitable one.
Since you cant really emulate what apple is doing, you should handle this problem through your interface, offer the user to "share" or to "open with" for example.
The answer is very simple. There is no way to do it. You cannot add the apps except the defaults into the UIActivityViewControllers.
You are absolutley correct, you can acheive this through the UIDocumentInteractionController.

How does one create a "file handler" in iOS, that lets you open a URL in your app if you long press on it?

For example, if you open a PDF in Safari, you have the option to open in iBooks - I believe a number of apps have this ability.
How does one "register" the ability of your app to handle such files, and is it possible so that by "long pressing" a link in Safari, you can get the option to open the URL in your app instead of in Safari?
Yes, it is possible.
look at the documentation on "Registering the File Types Your App Supports"
here is a link: https://developer.apple.com/library/ios/documentation/FileManagement/Conceptual/DocumentInteraction_TopicsForIOS/Articles/RegisteringtheFileTypesYourAppSupports.html
For the first part, you are going to want to take a look at Registering Your Support of File Types to add your app to the system list of apps that can open specific document types. That is handled by the system.
For the second part, I could be mistaken, but I don't believe you will be able to get that "long press" functionality as it would require changing Safari. If you control the content of the web page however, you could add a Custom URL Scheme to your app which would allow you to launch it from a web page.

Resources