@capgo/capacitor-share-target 8.0.24 → 8.0.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -85,8 +85,8 @@ public class CapacitorShareTargetPlugin extends Plugin {
|
|
|
85
85
|
}
|
|
86
86
|
shareData.put("files", files);
|
|
87
87
|
|
|
88
|
-
// Notify listeners
|
|
89
|
-
notifyListeners("shareReceived", shareData);
|
|
88
|
+
// Notify listeners and retain until JavaScript registers to handle cold starts
|
|
89
|
+
notifyListeners("shareReceived", shareData, true);
|
|
90
90
|
Log.d(TAG, "Share received: " + shareData.toString());
|
|
91
91
|
} catch (Exception e) {
|
|
92
92
|
Log.e(TAG, "Error handling shared content", e);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import Foundation
|
|
2
2
|
import Capacitor
|
|
3
|
+
import UIKit
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* Please read the Capacitor iOS Plugin Development Guide
|
|
@@ -7,7 +8,7 @@ import Capacitor
|
|
|
7
8
|
*/
|
|
8
9
|
@objc(CapacitorShareTargetPlugin)
|
|
9
10
|
public class CapacitorShareTargetPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
10
|
-
private let pluginVersion: String = "8.0.
|
|
11
|
+
private let pluginVersion: String = "8.0.26"
|
|
11
12
|
public let identifier = "CapacitorShareTargetPlugin"
|
|
12
13
|
public let jsName = "CapacitorShareTarget"
|
|
13
14
|
public let pluginMethods: [CAPPluginMethod] = [
|
|
@@ -25,6 +26,14 @@ public class CapacitorShareTargetPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
25
26
|
object: nil
|
|
26
27
|
)
|
|
27
28
|
|
|
29
|
+
// Also check when the app returns to foreground (share extensions often cannot open the host app)
|
|
30
|
+
NotificationCenter.default.addObserver(
|
|
31
|
+
self,
|
|
32
|
+
selector: #selector(handleAppDidBecomeActive),
|
|
33
|
+
name: UIApplication.didBecomeActiveNotification,
|
|
34
|
+
object: nil
|
|
35
|
+
)
|
|
36
|
+
|
|
28
37
|
// Check for shared data on app launch
|
|
29
38
|
checkForSharedContent()
|
|
30
39
|
}
|
|
@@ -105,8 +114,12 @@ public class CapacitorShareTargetPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
105
114
|
userDefaults.removeObject(forKey: key)
|
|
106
115
|
userDefaults.synchronize()
|
|
107
116
|
|
|
108
|
-
// Notify listeners
|
|
109
|
-
notifyListeners("shareReceived", data: shareEvent)
|
|
117
|
+
// Notify listeners and retain until JavaScript registers to handle cold starts
|
|
118
|
+
notifyListeners("shareReceived", data: shareEvent, retainUntilConsumed: true)
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
@objc private func handleAppDidBecomeActive(_ notification: Notification) {
|
|
122
|
+
checkForSharedContent()
|
|
110
123
|
}
|
|
111
124
|
|
|
112
125
|
@objc func getPluginVersion(_ call: CAPPluginCall) {
|