How to add an iOS Share Extension

MagnusKronaMagnusKrona SEMember ✭✭

I'm trying to add an iOS Share Extension to my app. I'm using Visual Studio. What i have done is:

  1. Added a new Share extension project to my solution.
  2. Added a reference to the Share extension project in the main app project
  3. Changed the CFBundleIdentifier to match the main app identifier + the extension name
  4. Runs the project in the simulator (also tested on device)
  5. Open up Safari and click the Share icon.
  6. Select more. My extension shows up. Adding my extension.
  7. Selecting my extension and expecting the Share form to show up.
  8. Nothing happens and Safari hangs.

What am I missing here? I'm running version Xamarin.iOS 8.10.0.0 and Xamarin version 3.11.458.0

Posts

  • IvanIcinIvanIcin USMember ✭✭✭

    The default viewcontroller created in MainInterface.storyboard is transparent, so you see a transparent viewcontroller over the screen and as you haven't put any views in it you can't dismiss it.

  • ChristianFischerChristianFischer DEMember ✭✭

    @MagnusKrona Did you solve the issue? I expierence the same behavior... @IvanIcin I inspected my MainInterface.storyboard file but I don't see any transparent Colors. The viewController has one view inside and it has backgroundColor set to calibratedWhite...
    Can somebody help me????

  • TedRogersTedRogers USMember ✭✭✭✭
    edited May 2017

    @MagnusKrona @ChristianFischer you guys don't mention whether you are using a ShareViewController derived from SLComposeServiceViewController or creating your own UI?

    I just created an out of the box share extension that uses SLComposeServiceViewController and it shows up. Only thing I changed was the NSExtensionActivationRule.

    Also, just derived from UIViewController to use my own UI and that worked find as well.

    Added my project.

  • ChristianFischerChristianFischer DEMember ✭✭

    @TedRogers Hi Ted, sorry for the late Reply. My share Extension is deriving from SLComposeServiceViewController but the Problem was a missing key/value pair in the info.plist file regarding the NSExtenstionActivation :-(

  • Sahadev_GuptaSahadev_Gupta INMember ✭✭✭

    @TedRogers
    Hello sir, I've run your project but it didn't work for me. I can't see my app in the share menu.
    Can you help me

  • TedRogersTedRogers USMember ✭✭✭✭

    @Sahadev_Gupta What are you trying to share. I just tried this on my iPhone running iOS 11.1.2 and it showed up fine. The NSExtensionActivationRule in my sample is setup for files. If for example, your tried to share a photo from the Photos app it would not show up.

  • Sahadev_GuptaSahadev_Gupta INMember ✭✭✭

    @TedRogers said:
    @Sahadev_Gupta What are you trying to share. I just tried this on my iPhone running iOS 11.1.2 and it showed up fine. The NSExtensionActivationRule in my sample is setup for files. If for example, your tried to share a photo from the Photos app it would not show up.

    Yes i'm trying to share photo's to my app but i can't find my app in the share option.

  • Sahadev_GuptaSahadev_Gupta INMember ✭✭✭

    @TedRogers thank you. It work for me. I just cleaned my project and everything works fine then. But can you tell me how to fetch the image URL from this share extension

  • nithinshiriyanithinshiriya USMember ✭✭

    @TedRogers I have tried your project. But i don't see the app in photo library and then click on share. Do you have updated solution or github solution?

  • MarcoSalvatoriMarcoSalvatori USMember ✭✭✭
    edited February 14

    sorry, but the solution proposed here (https://codemilltech.com/sending-files-to-a-xamarin-forms-app-part-1-ios/) is still supported? it doesn't work for me ... it doesn't allow my APP to receive files ...

    i work with image:
    <dict> <key>CFBundleTypeName</key> <string>Immagini</string> <key>CFBundleTypeExtensions</key> <string>jpg</string> <key>CFBundleTypeRole</key> <string>Viewer</string> <key>LSHandlerRank</key> <string>Alternate</string> <key>LSItemContentTypes</key> <array> <string>public.png</string> <string>public.jpg</string> <string>public.image</string> </array> </dict>

Sign In or Register to comment.