Is it possible to use the sharing panel to share a file?
I’m guessing I could upload a file to a server and pass the URL, but I’d like to be able to share the file itself.
Optionally I can send some text representing the file but then I suspect anyone receiving it will have a mess to deal with.
dim controller as UIActivityViewController
dim url as Foundation.NSURL = Foundation.NSURL.FileURLWithPath(myFile.Path)
controller = new UIActivityViewController(NSArray.CreateWithObject(url),nil)
//present with nil completion handler
self.PresentViewController(controller, True, nil)
Do you know if there are any limitations or restriction on where the file can be located to to this?
Thank you very much for taking the time to write it up.
You might have to do it in Xcode to make your plist correct since I’m pretty sure its just modifying the plist. But I haven’t done this in Xojo before.
That was a good reference and helped me understand what I need to do. I did use Xcode and it was a PITA and didn’t work.
I did, however find this link and could hack that to work.
Almost
Now I can send myself the file and it shows up with my application icon (cool).
By messages, it won’t open.
By mail, I can tap on it, and can get to my app via the More… button.
how do I get my app to show up in the default list as there is no ambiguity with the file extension
when I do send it to my app, I have zero idea how to get an event to fire with any data that I can process.
In the open event of the app, create a Foundation.NSDictionary object from the pointer passed to you. This will be the launch options dictionary. Then you need to inspect this key to get the URL of the file to open: UIApplicationLaunchOptionsURLKey | Apple Developer Documentation
The string value is “UIApplicationLaunchOptionsURLKey” which you can find with a swift playground in Xcode.
Untested but should be something like:
dim d as new Foundation.NSDictionary(launchOptionsHandle)
dim fileURL as new Foundation.NSURL(d.Value("UIApplicationLaunchOptionsURLKey"))
dim f as new xojo.io.folderitem(fileURL.path) //might be absoluteString, I don't remember
// process the file
You also need to have some error checking so this doesnt crash if the key isnt present. But that shouldnt be difficult
That looks like it’s on the right track, but this line fails, and I can’t figure out what the key value should be. Ptr to what?
The compiler complains about the text literal.
Dim fileURL As New Foundation.NSURL(d.Value("UIApplicationLaunchOptionsURLKey"))
Hmmm. I’m using his code, which I’ve downloaded recently (most current?) but I can’t find that class in there anywhere. I do see other threads referencing it too.
This stuff really does need to be integrated right into Xojo.