How to receive sharing content in my app? - ios

I would like to add my app to the UIActivityViewController in other apps. How can I add/register my app to allow other apps to send content to my app? How should I receive this content?

Thank you very much to all of you that answered to my question.
With your answers I realized I have to use a Shared Extension. I have found a really nice video that explains how I have to handle the received information: https://www.youtube.com/watch?v=TBC2m8BbcCE. Maybe it could be useful for somewhere in the future.

In your Xcode project, go to file > new > target and select "Share Extension".
Your Share Extension is the extension that will provide an option in the share sheet inside other apps.
To learn more about share extensions, check out Apple's guide.

Related

My App Inside WhatsApp's Share Extension

Hello when i am in WhatsApp and i want share a image, its going to open Share Extension with many apps like Slack. And when i am in App Photos and i want share a image, its going to opens Share Extension with apps like Flicker but isn't Slack. So my question is, can i add my own app to Whatsapp's Share Extension? and How can i catch it in my own app with Swift?
Yes, you can. So actually it will not be your main app,but it will be an extension to your main app.
Share extensions are made for the exact same purpose.
Kindly check for "Share Extension"
Following link may help you.
https://developer.apple.com/library/content/documentation/General/Conceptual/ExtensibilityPG/Share.html#//apple_ref/doc/uid/TP40014214-CH12-SW1

How to make your app available in UIActivityViewcontroller listed activities

How to make your app available in UIActivityViewcontroller listed activities.
Im unable to find the exact name of this feature.
Here is what I wanna do. My app is a social app where whenever other apps will share the content in UIActivityViewController I want my app to appear in the activities list.
I Apologise that I have no idea about what it is called. Anyone can please help me out.
it's called App Extension, you can use share extensions to share the data between the extension and your app. For more information refer the App Extensions Guide

Can I show an App Extension with an UIDocumentationInteractionController?

I' using an UIDocumentationInteractionController to show all compatible apps which can open the files stored in my app. It has always worked well, however I have noticed that with iOS 8 it shows only the apps and not the App Extensions. In the official documentation I can't find anything about that. Is it a bug or a deliberate thing? Do we need to use the UIActivityViewController instead?
As far as IOS 8.1 UIActivityViewController is the only extension point for the share & action extensions. so yes, if you wish to allow share extensions you must switch to UIActivityViewController.
You can read about it in this blog post:
http://getnotebox.com/developer/uiactivityviewcontroller-ios-8/
Here is a pretty good guide on using UIActivityViewController:
http://nshipster.com/uiactivityviewcontroller/

How to get listed in the share menu?

I'm creating a messaging app and I would like to enable other apps to share text to my app via the share menu option.
How do I get my app listed in there?
This is the menu I would like to get listed in:
In iOS 8, Apple has now enabled a way for you to add your application to a user's Share Sheet as one of many features of Extensibility, which aims to make your app available to the user even when closed.
You can read a lot more about share extensions here, or go straight to Apple's pre-release documentation to dive into the code.
Update: Above link of Apple documentation is not working, check here App Extension Programming Guide: Share
You can do this by adding a few entries into your apps info.plist.
Here's a post that should answer this for you.
slashdot post
also here another link
You can't automatically be added to the UIActivityViewController in other apps. The only things that appear on that "share menu" are a few predefined apps that Apple has added support for, as well as any other app specific activities an app decides to add.
You can setup your app to appear in a list of apps for opening a file but that is not the same as what you are asking for here.

Is it possible to add an app to the native share dialog?

I am assuming it is not possible to add apps to the native share dialog, like the one used in the Camera Roll. However I see screenshots around with different apps in the dialog.
Is it only apps that are integrated in the OS that can be in this dialog? Or is it possible with some scheme or something?
I have researched the possibilities of UIDocumentInteractionController mentioned by 'The Tiger' and came to the conclusion that it is not possible.
I have looked at the Apple Documentation, declaring the Document Types in the info.plist works for other apps but not for Mail, Images / Camera Roll / etc; the native share dialogs.
Edit:
I really don't get the downvotes....
Here are some references that say it is not possible:
https://devforums.apple.com/thread/140939?tstart=0
why-cant-i-register-my-ios-application-to-handle-the-image-file-type
register-app-to-open-image-files
associate-audio-and-video-types-with-iphone-app
add-a-file-association-with-tiff-files-on-ios
associate-image-file-types-utis-with-ios-app-doesnt-show-open-in-in-m
You need to subclass UIActivity to achieve this.
Theres an example for Dropbox:
https://github.com/goosoftware/GSDropboxActivity
Register your app as supporting the file types that you want to open and add the code to open them. See Document Interaction Programming Topics.

Resources