refactor(ios): remove AppDelegate SharedImage registration (Phase 2B-2)
Now that AppBridgeViewController registers SharedImagePlugin from capacitorDidLoad(), remove the obsolete plugin-registration logic from AppDelegate: the 5-attempt retry loop in didFinishLaunchingWithOptions, the registerSharedImagePlugin() method, and the registration-specific logging. SharedImagePlugin is now registered from a single, deterministic site. All non-registration responsibilities are unchanged: notification handling, URL and universal-link proxying, SharedPhotoReady activation logic, every lifecycle callback, the temporary app launch tracing, and all temporary share-target diagnostics remain intact. No JS or Android changes.
This commit is contained in:
@@ -22,50 +22,13 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
|
|||||||
// Initialize SQLite
|
// Initialize SQLite
|
||||||
//let sqlite = SQLite()
|
//let sqlite = SQLite()
|
||||||
//sqlite.initialize()
|
//sqlite.initialize()
|
||||||
|
|
||||||
// Register SharedImage plugin manually after bridge is ready
|
// SharedImagePlugin is registered from AppBridgeViewController.capacitorDidLoad()
|
||||||
// Try multiple times with increasing delays to ensure bridge is initialized
|
// (Phase 2B-2). The previous AppDelegate retry-based registration was removed.
|
||||||
var attempts = 0
|
|
||||||
let maxAttempts = 5
|
|
||||||
|
|
||||||
func tryRegister() {
|
|
||||||
attempts += 1
|
|
||||||
if registerSharedImagePlugin() {
|
|
||||||
print("[AppDelegate] ✅ Plugin registration successful on attempt \(attempts)")
|
|
||||||
} else if attempts < maxAttempts {
|
|
||||||
DispatchQueue.main.asyncAfter(deadline: .now() + Double(attempts) * 0.5) {
|
|
||||||
tryRegister()
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
print("[AppDelegate] ⚠️ Failed to register plugin after \(maxAttempts) attempts")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Start registration attempts
|
|
||||||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
|
|
||||||
tryRegister()
|
|
||||||
}
|
|
||||||
|
|
||||||
// Override point for customization after application launch.
|
// Override point for customization after application launch.
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
@discardableResult
|
|
||||||
private func registerSharedImagePlugin() -> Bool {
|
|
||||||
guard let window = self.window,
|
|
||||||
let bridgeVC = window.rootViewController as? CAPBridgeViewController,
|
|
||||||
let bridge = bridgeVC.bridge else {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create plugin instance
|
|
||||||
// The @objc(SharedImage) annotation makes it available as "SharedImage" to Objective-C
|
|
||||||
// which matches the JavaScript registration name
|
|
||||||
let pluginInstance = SharedImagePlugin()
|
|
||||||
bridge.registerPluginInstance(pluginInstance)
|
|
||||||
print("[AppDelegate] ✅ Registered SharedImagePlugin (exposed as 'SharedImage' via @objc annotation)")
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
func applicationWillResignActive(_ application: UIApplication) {
|
func applicationWillResignActive(_ application: UIApplication) {
|
||||||
// TEMPORARY SHARE TARGET DIAGNOSTICS
|
// TEMPORARY SHARE TARGET DIAGNOSTICS
|
||||||
|
|||||||
Reference in New Issue
Block a user