Forum Xamarin.iOS

Open images/files in Xamarin iOS

RandomiseRandomise Member ✭✭

Hello,

I have this code to open images/files in Xamarin.

await Launcher.OpenAsync(new OpenFileRequest { File = new ReadOnlyFile(_db.GetPhoto(id)[0].Path) });

It works well in Android but with iOS it opens the share function kind of like this:

How to make it work like Android, allows to choose what app to launch with?

Thank you!

Best Answer

Answers

  • LandLuLandLu Member, Xamarin Team Xamurai

    OpenAsync(OpenFileRequest) will open a file in applications that support this kind of content.
    This is the design on iOS which will list applications here:

    It means you could open it with sms, mail or notes.

  • RandomiseRandomise Member ✭✭

    I took a screenshot from what I actually get when I try to open an image in iOS with this function:

    As you can see I can't open it with gallery or anything like in Android :(

  • LandLuLandLu Member, Xamarin Team Xamurai

    I saw the Albums application on your picture.
    You could click the More button to see other applications which support to open this file. Then click the edit button to make more applications displayed on the list.

  • RandomiseRandomise Member ✭✭

    Thank's a lot for taking the time to help me.
    It is the Albums Share application, and on the edit button I have nothing more than theses

  • LandLuLandLu Member, Xamarin Team Xamurai

    It is the Albums Share application

    We could open it with Photos application via clicking the icon.

    and on the edit button I have nothing more than theses

    It means there're no other applications which could open this kind of file. This is the UIDocumentInteractionController when you want to open files with other applications on iOS. It's different from Android.
    https://stackoverflow.com/questions/7156932/open-file-in-another-app

  • RandomiseRandomise Member ✭✭

    There is no Photos application icon that appear, I want to be able to open it with the basic iOS gallery/photo application, I can't do that with OpenAsync in iOS?

  • LandLuLandLu Member, Xamarin Team Xamurai

    I tried a picture file on my side. It seems the system Photos won't be shown up.
    If you want to store pictures to gallery why not try api directly:
    https://forums.xamarin.com/discussion/108717/save-imagestream-to-gallery-in-xamarin-ios

  • RandomiseRandomise Member ✭✭

    It stores to gallery but I want the user to be able to open it by tapping on it, how can I do that if not with OpenAsync? I also want the user to be able to open pdf, docx file etc... openAsync works great in Android but it seems like in iOS it only opens the share function

  • RandomiseRandomise Member ✭✭

    Thanks you, it worked :)

Sign In or Register to comment.