FR: iOS custom file type open handler

the current version of the patch i’m using is here:

and then i have this code in StandaloneApp.cpp:

#if JucePlugin_Build_Standalone && JUCE_IOS

  void urlOpened(const juce::URL &url) override {
    // we have to read our url as an InputStream, otherwise
    // we won't have access to the underlying bookmark data.
    auto is = url.createInputStream(
        juce::URL::InputStreamOptions(juce::URL::ParameterHandling::inAddress));

    // so we read from the url and write to a temp file
    // with the same extension.
    auto tmp = juce::TemporaryFile(url.getLocalFile().getFileExtension());
    auto tmpFile = tmp.getFile();
    auto os = juce::FileOutputStream(tmpFile);
    os.writeFromInputStream(*is, -1);

    // call flush so the file is readable!
    os.flush();

    // and now we can do something with our tmpFile
    doSomething(tmpFile);
    // note that our tmpFile will be cleaned up by going out
    // of scope.
  }

#endif

i also had to setup CFBundleDocumentTypes and UTExportedTypeDeclarations for the new filetypes/extensions i was adding - the setup guide from the OP does a good job of explaining this iirc.

4 Likes