0

I would like to make my app appear in the UIActivityViewController for text sharing, like in Mail, iMessage, Notes, Gmail etc etc.

For example, when user tapback on selected text and hit the 'Share' button from any app like in the attachment: enter image description here

I would like my app to appear in the UIActivityViewController and when the user selects my app, to launch it with the ability to handle that selected text.

enter image description here

So what I have tried: Search in Apple documentation.

  • Searched for relevant UTI but I understood that the UTIs are used only for files and not for a simple NSString (Correct me if I'm wrong). I have worked with UTI's for images, text files, pdf etc, but I have no solution for being shared with highlight text.
  • Read about UIDocumentInteractionController and again, it won't help me, because its for using to handling files.
  • I have tried to implement Share Extension, but this is not the solution that i want, I don't need the post popup and moreover than that I need to launch my app after sharing like in Mail, Notes, iMessage does (Regarding to Apple documentation we can't launch the contain app through Share extension only through Today extension).
  • Of course, I have searched a lot in StackOverFlow, didn't find solution for that question.

So any solutions? Thanks!

MKaro
  • 156
  • 1
  • 9
  • Hey @MKaro Did you find the solution for this, I am facing the same challenges. Please help me here if you already resolved. – Santosh Singh Jul 11 '20 at 12:42
  • 1
    Hey @SantoshSingh, you may try this answer https://stackoverflow.com/a/62781853/5727805 LMK if it helped you. – MKaro Jul 14 '20 at 21:12

1 Answers1

0

If you want to share text through UIActivityViewController you have to use Share Extension. To make your app appear in UIActivityViewController to share text you have to add this code/Key to your Info.plist of Share Extension:-

<key>NSExtension</key>
<dict>
    <key>NSExtensionAttributes</key>
    <dict>
        <key>NSExtensionActivationRule</key>
        <dict>
            <key>NSExtensionActivationSupportsText</key>
            <true/>
        </dict>
        <key>RequestsOpenAccess</key>
        <true/>
    </dict>
    <key>NSExtensionMainStoryboard</key>
    <string>MainInterface</string>
    <key>NSExtensionPointIdentifier</key>
    <string>com.apple.share-services</string>
</dict>

by this your app will appear in UIActivityViewController and able to text sharing.

and to avoid Post Popup you have to design MainInterface.storyboard according your requirements.

Pramod
  • 787
  • 1
  • 7
  • 16