fix(ios): local library scan fails on iOS due to missing security-scoped bookmark access

This commit is contained in:
zarzet
2026-03-08 14:57:13 +07:00
parent 2c897992c5
commit c35857bb61
10 changed files with 602 additions and 273 deletions
+41
View File
@@ -1155,6 +1155,47 @@ class PlatformBridge {
await _channel.invokeMethod('cancelLibraryScan');
}
// MARK: - iOS Security-Scoped Bookmark
/// Create a security-scoped bookmark from a filesystem path picked by
/// FilePicker on iOS. Must be called while the picker session is still active.
/// Returns base64-encoded bookmark data, or null on failure.
static Future<String?> createIosBookmarkFromPath(String path) async {
try {
final result = await _channel.invokeMethod('createIosBookmarkFromPath', {
'path': path,
});
return result as String?;
} catch (e) {
_log.w('Failed to create iOS bookmark from path: $e');
return null;
}
}
/// Resolve a base64-encoded iOS security-scoped bookmark and start accessing
/// the resource. Returns the resolved filesystem path.
/// The resource stays accessed until [stopAccessingIosBookmark] is called.
static Future<String?> startAccessingIosBookmark(String bookmark) async {
try {
final result = await _channel.invokeMethod('startAccessingIosBookmark', {
'bookmark': bookmark,
});
return result as String?;
} catch (e) {
_log.w('Failed to start accessing iOS bookmark: $e');
return null;
}
}
/// Stop accessing the currently active iOS security-scoped resource.
static Future<void> stopAccessingIosBookmark() async {
try {
await _channel.invokeMethod('stopAccessingIosBookmark');
} catch (e) {
_log.w('Failed to stop accessing iOS bookmark: $e');
}
}
/// Read metadata from a single audio file
static Future<Map<String, dynamic>?> readAudioMetadata(
String filePath,