WIP: iOS Share Target Reliability #235

Draft
jose wants to merge 31 commits from fix/ios-share-target-reliability into master
4 changed files with 19 additions and 6 deletions
Showing only changes of commit a3e9a0104d - Show all commits

View File

@@ -44,10 +44,16 @@ The plugin is registered as `SharedImage` and is implemented in:
### `getSharedImage(): Promise<SharedImageResult | null>`
Returns the shared image as `{ base64, fileName }`, or `null` if none exists.
Returns the shared image as `{ base64, fileName, shareId }`, or `null` if none
exists. `shareId` is the native `sharedPhotoShareId` (UUID assigned by the
Share Extension); pass it to `markProcessed()` to signal explicit completion.
Read-only: native metadata and the file are left intact after retrieval
(Phase 1C).
> Note: On iOS the "no shared image" case resolves an object with `base64`,
> `fileName`, and `shareId` set to `null`; on web `getSharedImage()` resolves
> `null` directly.
### `hasSharedImage(): Promise<{ hasImage: boolean }>`
Returns whether a shared image file currently exists, without reading it.

View File

@@ -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
* Returns base64 string, fileName, and shareId, or null fields if no image exists
* Read-only: native metadata and file are left intact after retrieval (Phase 1C)
*/
@objc public func getSharedImage(_ call: CAPPluginCall) {
@@ -41,7 +41,8 @@ public class SharedImagePlugin: CAPPlugin, CAPBridgedPlugin {
// No shared image exists - return null (not an error)
call.resolve([
"base64": NSNull(),
"fileName": NSNull()
"fileName": NSNull(),
"shareId": NSNull()
])
return
}
@@ -49,7 +50,8 @@ public class SharedImagePlugin: CAPPlugin, CAPBridgedPlugin {
// Return the shared image data
call.resolve([
"base64": sharedData["base64"] ?? "",
"fileName": sharedData["fileName"] ?? ""
"fileName": sharedData["fileName"] ?? "",
"shareId": sharedData["shareId"] ?? ""
])
}

View File

@@ -44,7 +44,7 @@ public class SharedImageUtility {
* All images are stored as files for consistency and to avoid UserDefaults size limits
* 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
* @returns Dictionary with "base64", "fileName", and "shareId" keys, or nil if no shared image
*/
static func getSharedImageData() -> [String: String]? {
let userDefaults = UserDefaults(suiteName: appGroupIdentifier)
@@ -76,7 +76,7 @@ public class SharedImageUtility {
// Convert file data to base64 for JavaScript consumption
let base64String = imageData.base64EncodedString()
return ["base64": base64String, "fileName": fileName]
return ["base64": base64String, "fileName": fileName, "shareId": resolvedShareId]
}
/**

View File

@@ -5,6 +5,11 @@
export interface SharedImageResult {
base64: string;
fileName: string;
/**
* Identifier of the current share (iOS `sharedPhotoShareId`).
* Pass this to `markProcessed()` to signal explicit completion.
*/
shareId: string;
}
export interface SharedImagePlugin {