Email app missing in apps to share option.

RickyNoronhaRickyNoronha INMember
edited June 2016 in Xamarin.iOS

I have build a app in xamarin.forms, I manages to get share feature working for android platform using intent filters but how do I do that for iOS? I am new to objective-c and it all seems to confuse me more. I have tried sharing a file from my app and works however I am unable to get some of the apps in the app list to share. Here I am trying to share a audio file.

Here is the code:

        var window = UIApplication.SharedApplication.KeyWindow;
        var subviews = window.Subviews;
        var view = subviews.Last();
        var frame = view.Frame;
        frame = new RectangleF(0, 0, 0, 0);

        var uidic = UIDocumentInteractionController.FromUrl(new NSUrl(path, false));
        var rc = uidic.PresentOpenInMenu(frame, view, true);

The above code works and gives me list of apps but does not show email app. Can anybody help me rectify the bug. Why wouldn't I get mail option?

Answers

  • danielparedes97danielparedes97 Member ✭✭

    Hi @RickyNoronha

    I'm also new working with objective-c, and I've managed to share an image

    I share you my code, if it helps you:

    var viewer = UIDocumentInteractionController.FromUrl(NSUrl.FromFilename(saveImagePath));
    var controller = GetVisibleViewController();
    viewer.PresentOpenInMenu(controller.View.Frame, controller.View, true);
    

    And

    private UIViewController GetVisibleViewController(UIViewController controller = null)
            {
                controller = controller ?? UIApplication.SharedApplication.KeyWindow.RootViewController;
    
                if (controller.PresentedViewController == null)
                    return controller;
    
                if (controller.PresentedViewController is UINavigationController)
                {
                    return ((UINavigationController)controller.PresentedViewController).VisibleViewController;
                }
    
                if (controller.PresentedViewController is UITabBarController)
                {
                    return ((UITabBarController)controller.PresentedViewController).SelectedViewController;
                }
    
    
    
                return GetVisibleViewController(controller.PresentedViewController);
            }
    
Sign In or Register to comment.