iOS Native Content Sharing Halp Plz

The final word, currently, is that the Sharing feature is totally unavailable to an AUv3.

You can open a Files instance, though. You just have to remember that you can’t go above the main UIView of the AUv3. The sandboxing prevents this. Any modal window, including Files, must be owned by the editor. In real JUCE terms, you do it like this:

exporter.reset(new FileChooser("Export to...", tmp, "", true, false,
			JUCEApplicationBase::isStandaloneApp() ? NULL : this));
			exporter->launchAsync (FileBrowserComponent::saveMode |
							       FileBrowserComponent::canSelectDirectories |
								   FileBrowserComponent::filenameBoxIsReadOnly,
								   [&tmp] (const FileChooser& chooser)
			{
				if (chooser.getResult().exists())
				{
					auto chosen = chooser.getResult();
					if (chosen.isDirectory())
					{
						bool result = tmp.copyFileTo(chosen);
						if (result && tmp.hasFileExtension("zip")) tmp.deleteFile();
					}
				}
			});

This triggers an std::unique_ptr<FileChooser> named exporter for saving asynchronously (it is very slow if you don’t do it async) that is owned by the window it is spawned in. You put your operations in the lambda.

AFAIK, this is the only way to safely move files in and out of the AUv3’s sandbox. The major downside is that, since the editor (or whatever component you triggered it from) owns the FIles instance, the Files doesn’t go fullscreen modal. It is only modal to your AUv3’s frame.

Note in particular that JUCEApplicationBase::isStandaloneApp(). If you’re doing only AUv3 and not a standalone, that’s where the trick is. NULL is “open a Files instance normally.” This will be fullscreen. “this” is the component where you’re triggering the Files instance from. In an AUv3 situation, it has to be this way. NULL will result in either a crash or nothing happening.

If you get any of the Audio Damage apps that have a Files dialogue (currently Enso, Quanta, and Continua) you can see how this works in real life. That bit of code above is taken directly from Continua’s “Export” function in the Presets menu.

2 Likes