From c6d5876da3f3c3c44cb45152aea8c252ec81193e Mon Sep 17 00:00:00 2001 From: Jose Olarte III Date: Mon, 29 Jun 2026 18:12:35 +0800 Subject: [PATCH] refactor(ios): remove orphaned Share Extension diagnostics API Remove the getShareExtensionDiagnostics() API now that the share-target investigation is complete and it has no remaining callers. - Drop getShareExtensionDiagnostics from the plugin definition, web stub, Swift plugin method + registration, and SharedImageUtility implementation - Remove the ShareExtensionDiagnostics TypeScript interface and its now-dead import in the web stub - Remove the diagnostics-only [ShareTarget] log line and the now-unused shareExtensionLastStartKey constant in SharedImageUtility getSharedImage/hasSharedImage, SharedPhotoReady logic, ShareViewController, AppDelegate, and Android are unchanged. TypeScript type-check passes. --- ios/App/App/SharedImagePlugin.swift | 10 +------- ios/App/App/SharedImageUtility.swift | 36 ---------------------------- src/plugins/SharedImagePlugin.web.ts | 15 +----------- src/plugins/definitions.ts | 12 ---------- 4 files changed, 2 insertions(+), 71 deletions(-) diff --git a/ios/App/App/SharedImagePlugin.swift b/ios/App/App/SharedImagePlugin.swift index 06abe82c..a18c4b27 100644 --- a/ios/App/App/SharedImagePlugin.swift +++ b/ios/App/App/SharedImagePlugin.swift @@ -24,8 +24,7 @@ public class SharedImagePlugin: CAPPlugin, CAPBridgedPlugin { public var pluginMethods: [CAPPluginMethod] { return [ CAPPluginMethod(#selector(getSharedImage(_:)), returnType: .promise), - CAPPluginMethod(#selector(hasSharedImage(_:)), returnType: .promise), - CAPPluginMethod(#selector(getShareExtensionDiagnostics(_:)), returnType: .promise) + CAPPluginMethod(#selector(hasSharedImage(_:)), returnType: .promise) ] } @@ -63,12 +62,5 @@ public class SharedImagePlugin: CAPPlugin, CAPBridgedPlugin { "hasImage": hasImage ]) } - - /** - * Diagnostic snapshot of Share Extension startup and pending share state - */ - @objc public func getShareExtensionDiagnostics(_ call: CAPPluginCall) { - call.resolve(SharedImageUtility.getShareExtensionDiagnostics()) - } } diff --git a/ios/App/App/SharedImageUtility.swift b/ios/App/App/SharedImageUtility.swift index 59f08339..82e27619 100644 --- a/ios/App/App/SharedImageUtility.swift +++ b/ios/App/App/SharedImageUtility.swift @@ -14,7 +14,6 @@ public class SharedImageUtility { private static let sharedPhotoFileNameKey = "sharedPhotoFileName" private static let sharedPhotoFilePathKey = "sharedPhotoFilePath" private static let sharedPhotoShareIdKey = "sharedPhotoShareId" - private static let shareExtensionLastStartKey = "shareExtensionLastStart" private static let sharedPhotoReadyKey = "sharedPhotoReady" /// Get the App Group container URL for accessing shared files @@ -98,41 +97,6 @@ public class SharedImageUtility { return FileManager.default.fileExists(atPath: fileURL.path) } - /** - * Diagnostic snapshot of Share Extension startup and pending share state - * Read-only: does not modify App Group storage - */ - static func getShareExtensionDiagnostics() -> [String: Any] { - guard let userDefaults = UserDefaults(suiteName: appGroupIdentifier) else { - return [ - "shareExtensionLastStart": NSNull(), - "sharedPhotoShareId": NSNull(), - "sharedPhotoFilePath": NSNull(), - "fileExists": false - ] - } - - let shareExtensionLastStart = userDefaults.string(forKey: shareExtensionLastStartKey) - let shareId = userDefaults.string(forKey: sharedPhotoShareIdKey) - let filePath = userDefaults.string(forKey: sharedPhotoFilePathKey) - let fileExists: Bool - if let filePath = filePath, let containerURL = appGroupContainerURL { - let fileURL = containerURL.appendingPathComponent(filePath) - fileExists = FileManager.default.fileExists(atPath: fileURL.path) - } else { - fileExists = false - } - - print("[ShareTarget] getShareExtensionDiagnostics shareExtensionLastStart=\(shareExtensionLastStart ?? "nil") sharedPhotoShareId=\(shareId ?? "nil") sharedPhotoFilePath=\(filePath ?? "nil") fileExists=\(fileExists)") - - return [ - "shareExtensionLastStart": shareExtensionLastStart ?? NSNull(), - "sharedPhotoShareId": shareId ?? NSNull(), - "sharedPhotoFilePath": filePath ?? NSNull(), - "fileExists": fileExists - ] - } - /** * Check if shared photo ready flag is set * This flag is set by the Share Extension when image is ready diff --git a/src/plugins/SharedImagePlugin.web.ts b/src/plugins/SharedImagePlugin.web.ts index 71f021f6..d609be16 100644 --- a/src/plugins/SharedImagePlugin.web.ts +++ b/src/plugins/SharedImagePlugin.web.ts @@ -4,11 +4,7 @@ */ import { WebPlugin } from "@capacitor/core"; -import type { - SharedImagePlugin, - SharedImageResult, - ShareExtensionDiagnostics, -} from "./definitions"; +import type { SharedImagePlugin, SharedImageResult } from "./definitions"; export class SharedImagePluginWeb extends WebPlugin @@ -22,13 +18,4 @@ export class SharedImagePluginWeb async hasSharedImage(): Promise<{ hasImage: boolean }> { return { hasImage: false }; } - - async getShareExtensionDiagnostics(): Promise { - return { - shareExtensionLastStart: null, - sharedPhotoShareId: null, - sharedPhotoFilePath: null, - fileExists: false, - }; - } } diff --git a/src/plugins/definitions.ts b/src/plugins/definitions.ts index 1dd11255..f67a443c 100644 --- a/src/plugins/definitions.ts +++ b/src/plugins/definitions.ts @@ -7,13 +7,6 @@ export interface SharedImageResult { fileName: string; } -export interface ShareExtensionDiagnostics { - shareExtensionLastStart: string | null; - sharedPhotoShareId: string | null; - sharedPhotoFilePath: string | null; - fileExists: boolean; -} - export interface SharedImagePlugin { /** * Get shared image data from native layer @@ -27,9 +20,4 @@ export interface SharedImagePlugin { * Useful for quick checks before calling getSharedImage() */ hasSharedImage(): Promise<{ hasImage: boolean }>; - - /** - * Diagnostic snapshot of Share Extension startup and pending share state (iOS) - */ - getShareExtensionDiagnostics(): Promise; }