Notification when mounting volume on iOS

On macOS, we have didMountNotification but there doesn't seem to be an equivalent for iOS. Is there a way to be notified when a volume is mounted on iOS? I would like to use it in my iOS app I'm currently porting from macOS, which starts a synchronization from the volume (which has been previously selected in a NSOpenPanel) as soon as it's mounted.

On macOS, we have didMountNotification but there doesn't seem to be an equivalent for iOS. Is there a way to be notified when a volume is mounted on iOS?

There is not. It's reasonable enhancement request, however, I'm afraid that, unfortunately, it wouldn't be all that useful even if it did exist. That's because of issue with the next stage here:

I would like to use it in my iOS app I'm currently porting from macOS, which starts a synchronization from the volume (which has been previously selected in a NSOpenPanel) as soon as it's mounted.

On macOS, you did this by creating a security scoped bookmark to the target directory. Unfortunately, cross volume bookmark resolution is broken on iOS (r.102995804). The bookmark itself will work fine as long as the volume is mounted but this longer sequence:

  1. Mount an external volume.
  2. Bookmark an object on that share.
  3. Unmount that external volume in Files.app.
  4. Remount that external volume in Files.app.
  5. Resolve the bookmark (which will fail).

...fails on iOS 16 or later. This will occur on both network volume (smb/afp) and local volumes (APFS/HFS+/FAT).

Finally, please file a bug on this and post the bug number back here. The full details of what's going on are above, but the biggest thing you can do to help get this fixed is filing bugs on the issue. As part of that bug, please make sure you describe the "why" (what app this is in and what you're trying to do with this functionality), not just the "what". This kind of bug is really about documenting how this bug is hurting apps, not just informing us of a specific problem.

__
Kevin Elliott
DTS Engineer, CoreOS/Hardware

On macOS, we have didMountNotification but there doesn't seem to be an equivalent for iOS. Is there a way to be notified when a volume is mounted on iOS?

There is not. It's reasonable enhancement request, however, I'm afraid that it wouldn't be all that useful even if it did exist. That's because of issue with the next stage here:

I would like to use it in my iOS app I'm currently porting from macOS, which starts a synchronization from the volume (which has been previously selected in a NSOpenPanel) as soon as it's mounted.

On macOS, you did this by creating a security scoped bookmark to the target directory. Unfortunately, cross volume bookmark resolution is broken on iOS (r.102995804). The bookmark itself will work fine as long as the volume is mounted but this longer sequence:

  1. Mount an external volume.
  2. Bookmark an object on that share.
  3. Unmount that external volume in Files.app.
  4. Remount that external volume in Files.app.
  5. Resolve the bookmark (which will fail).

...fails on iOS 16 or later. This will occur on both network volumes (smb/afp) and local volumes (APFS/HFS+/FAT).

Finally, please file a bug on this and post the bug number back here. The full details of what's going on are above, but the biggest thing you can do to help get this fixed is filing bugs on the issue. As part of that bug, please make sure you describe the "why" (what app this is in and what you're trying to do with this functionality), not just the "what". This kind of bug is really about documenting how this bug is hurting apps, not just informing us of a specific problem.

__
Kevin Elliott
DTS Engineer, CoreOS/Hardware

Thanks for the detailed explanation. I filed FB16481526.

Notification when mounting volume on iOS
 
 
Q