nimbbl-mobile-react-native-sdk 1.0.1 → 1.1.0
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.
|
@@ -8,6 +8,7 @@ class NimbblReactNativeSDK: RCTEventEmitter, NimbblCheckoutSDKDelegate {
|
|
|
8
8
|
|
|
9
9
|
private var config: [String: Any] = [:]
|
|
10
10
|
private var isInitialized = false
|
|
11
|
+
private var hasListeners = false
|
|
11
12
|
|
|
12
13
|
override init() {
|
|
13
14
|
super.init()
|
|
@@ -33,6 +34,14 @@ class NimbblReactNativeSDK: RCTEventEmitter, NimbblCheckoutSDKDelegate {
|
|
|
33
34
|
return false
|
|
34
35
|
}
|
|
35
36
|
|
|
37
|
+
override func startObserving() {
|
|
38
|
+
hasListeners = true
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
override func stopObserving() {
|
|
42
|
+
hasListeners = false
|
|
43
|
+
}
|
|
44
|
+
|
|
36
45
|
@objc
|
|
37
46
|
func testModule(_ resolve: @escaping RCTPromiseResolveBlock, rejecter reject: @escaping RCTPromiseRejectBlock) {
|
|
38
47
|
// print("NimbblReactNativeSDK testModule called")
|
|
@@ -189,11 +198,15 @@ class NimbblReactNativeSDK: RCTEventEmitter, NimbblCheckoutSDKDelegate {
|
|
|
189
198
|
|
|
190
199
|
func onPaymentSuccess(_ response: [AnyHashable : Any]) {
|
|
191
200
|
// print("Payment success received with response: \(response)")
|
|
192
|
-
|
|
201
|
+
if hasListeners {
|
|
202
|
+
sendEvent(withName: "payment_success", body: response)
|
|
203
|
+
}
|
|
193
204
|
}
|
|
194
205
|
|
|
195
206
|
func onError(_ error: [AnyHashable : Any]) {
|
|
196
207
|
// print("Payment error received: \(error)")
|
|
197
|
-
|
|
208
|
+
if hasListeners {
|
|
209
|
+
sendEvent(withName: "payment_failed", body: error)
|
|
210
|
+
}
|
|
198
211
|
}
|
|
199
212
|
}
|