Forum Xamarin Xamarin.iOS

Receive multiple files selected (copy to X app)

ivnoxamivnoxam Member ✭✭

Hi! I got a problem with my app. I can successfully receive one file when a user uses my application to share with. It's done with openURL method, defined in the AppDelegate of my application.

However, this doesn't work with multiple files selected. When a user selects more than one file to share. the application still fires the openURL method, but only returns the url from the first selected (openURL doesn't have an array option), and the others just get lost in the way. I did it for Android with Intents and it works really good, even for multiple selection, but i can't make it work on iOS.

Is there any workaround to make this work or i am doing it wrong?

Thanks in advance!

Tagged:

Answers

  • JuniorJiangJuniorJiang Member, Xamarin Team Xamurai

    Hi, which ways you use to share files?You can post some code about this.

  • ivnoxamivnoxam Member ✭✭

    Hi! Of course. These are on my AppDelegate.

    public override bool OpenUrl(UIApplication application, NSUrl url, string sourceApplication, NSObject annotation)
    {
    return openLink(url);
    }

    private bool openLink(NSUrl url)
    {
    string filePath = url.AbsoluteString.Substring(7);
    var fileName = url.PathComponents[url.PathComponents.Length - 1];
    //...
    }

    This code works sending ("Copy to Myapp") one file to the application. When I select and send multiple files to the application, the method is called but only with the first file URL, the other just get lost. I need something similar to Android IntentFilter * / * with multiple files (I got no problem with Android).

    Thanks in advance!

  • ivnoxamivnoxam Member ✭✭

    Up! :)

  • ivnoxamivnoxam Member ✭✭

    Up! Anyone?

  • ivnoxamivnoxam Member ✭✭

    Up!

  • ivnoxamivnoxam Member ✭✭

    Bump! No one? :(

  • ivnoxamivnoxam Member ✭✭

    Anyone?

  • Hikari91Hikari91 ITMember ✭✭✭

    Hi,
    I need this too, anyone has any idea?

    Thank you! :smile:

  • ScudiScudi Member ✭✭
    edited April 29

    Hi,
    I am looking for this also. Hard to believe, that we are the only one in the world having this issue.
    I tried as a workaround to list all files of that inbox folder to which that url directs. But it seems that there is already just one file copied into that directory.

    public override bool OpenUrl(UIApplication app, NSUrl url, NSDictionary options)
            {           
               var files = Directory.GetFiles(url.Path.Replace(url.LastPathComponent, ""));
               foreach (var file in files)
                {
                    Console.WriteLine(file);
                }
                //.. 
            } 
    

    Maybe is there something to tweak in the info.plist to at least get all files copied into that directory? This would enable this workaround.

    Nevertheless it would be dirty, any "regular" approach would be appreciated.

  • ScudiScudi Member ✭✭

    Hi,
    I am looking for this also. Hard to believe, that we are the only one in the world having this issue.
    I tried as a workaround to list all files of that inbox folder to which that url directs. But it seems that there is already just one file copied into that directory.

    public override bool OpenUrl(UIApplication app, NSUrl url, NSDictionary options)
            {           
               var files = Directory.GetFiles(url.Path.Replace(url.LastPathComponent, ""));
               foreach (var file in files)
                {
                    Console.WriteLine(file);
                }
                //.. 
            } 
    

    Maybe is there something to tweak in the info.plist to at least get all files copied into that directory? This would enable this workaround.

    Nevertheless it would be dirty, any "regular" approach would be appreciated.

  • ScudiScudi Member ✭✭

    Hi,
    I am looking for this also. Hard to believe, that we are the only one in the world having this issue.
    I tried as a workaround to list all files of that inbox folder to which that url directs. But it seems that there is already just one file copied into that directory.

    public override bool OpenUrl(UIApplication app, NSUrl url, NSDictionary options)
            {           
               var files = Directory.GetFiles(url.Path.Replace(url.LastPathComponent, ""));
               foreach (var file in files)
                {
                    Console.WriteLine(file);
                }
                //.. 
            } 
    

    Maybe is there something to tweak in the info.plist to at least get all files copied into that directory? This would enable this workaround.

    Nevertheless it would be dirty, any "regular" approach would be appreciated.

Sign In or Register to comment.