feat(ios): make shared image retrieval non-destructive (Phase 1C)
Stop deleting App Group metadata and image files in getSharedImageData() so retrieval is read-only while preserving the existing plugin API shape. Document removed deletion paths in the iOS share target audit.
This commit is contained in:
@@ -33,7 +33,7 @@ public class SharedImagePlugin: CAPPlugin, CAPBridgedPlugin {
|
||||
/**
|
||||
* Get shared image data from App Group UserDefaults
|
||||
* Returns base64 string and fileName, or null if no image exists
|
||||
* Clears the data after reading to prevent re-reading
|
||||
* Read-only: native metadata and file are left intact after retrieval (Phase 1C)
|
||||
*/
|
||||
@objc public func getSharedImage(_ call: CAPPluginCall) {
|
||||
guard let sharedData = SharedImageUtility.getSharedImageData() else {
|
||||
|
||||
@@ -24,7 +24,7 @@ public class SharedImageUtility {
|
||||
/**
|
||||
* Get shared image data from App Group container file
|
||||
* All images are stored as files for consistency and to avoid UserDefaults size limits
|
||||
* Clears the data after reading to prevent re-reading
|
||||
* Read-only: metadata and file are left intact after retrieval (Phase 1C)
|
||||
*
|
||||
* @returns Dictionary with "base64" and "fileName" keys, or nil if no shared image
|
||||
*/
|
||||
@@ -48,20 +48,13 @@ public class SharedImageUtility {
|
||||
return nil
|
||||
}
|
||||
|
||||
print("[ShareTarget] share retrieved shareId=\(shareId ?? "unknown") originalFilename=\(fileName) storedFilename=\(filePath)")
|
||||
let resolvedShareId = shareId ?? "unknown"
|
||||
print("[ShareTarget] shareId=\(resolvedShareId) retrieved")
|
||||
print("[ShareTarget] shareId=\(resolvedShareId) left intact after retrieval")
|
||||
|
||||
// Convert file data to base64 for JavaScript consumption
|
||||
let base64String = imageData.base64EncodedString()
|
||||
|
||||
// Clear the shared data after reading
|
||||
userDefaults.removeObject(forKey: sharedPhotoFilePathKey)
|
||||
userDefaults.removeObject(forKey: sharedPhotoFileNameKey)
|
||||
|
||||
// Remove the file
|
||||
try? FileManager.default.removeItem(at: fileURL)
|
||||
|
||||
userDefaults.synchronize()
|
||||
|
||||
|
||||
return ["base64": base64String, "fileName": fileName]
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user