How to share PDF/Mobi files to another app using Xamarin iOS?

MelodyMelody INMember ✭✭
edited June 2017 in Xamarin.iOS

I am using the below code to share the files to other apps using xamarin iOS. but i didnt get any response when click share. Is there any other option to share files to other apps using Xamarin iOS?
Ref: http://xamarinhelp.com/share-dialog-xamarin-forms/

`

    UIViewController GetVisibleViewController()
    {
        var rootController = UIApplication.SharedApplication.KeyWindow.RootViewController;

        if (rootController.PresentedViewController == null)
            return rootController;

        if (rootController.PresentedViewController is UINavigationController)
        {
            return ((UINavigationController)rootController.PresentedViewController).TopViewController;
        }

        if (rootController.PresentedViewController is UITabBarController)
        {
            return ((UITabBarController)rootController.PresentedViewController).SelectedViewController;
        }

        return rootController.PresentedViewController;
    }

public async Task Show(string title, string message, string filePath)
    {
        var items = new NSObject[] { NSObject.FromObject(title), NSUrl.FromFilename(filePath) };
        var activityController = new UIActivityViewController(items, null);
        var vc = GetVisibleViewController();

        NSString[] excludedActivityTypes = null;

        if (excludedActivityTypes != null && excludedActivityTypes.Length > 0)
            activityController.ExcludedActivityTypes = excludedActivityTypes;

        if (UIDevice.CurrentDevice.CheckSystemVersion(8, 0))
        {
            if (activityController.PopoverPresentationController != null)
            {
                activityController.PopoverPresentationController.SourceView = vc.View;
            }
        }
        await vc.PresentViewControllerAsync(activityController, true);
    }`
Tagged:

Answers

Sign In or Register to comment.