paynl-pos-sdk-react-native 0.0.41 → 0.0.43
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.
|
@@ -5,6 +5,7 @@ import android.os.Bundle
|
|
|
5
5
|
import android.util.Log
|
|
6
6
|
import com.facebook.react.bridge.Promise
|
|
7
7
|
import com.facebook.react.bridge.ReactApplicationContext
|
|
8
|
+
import com.facebook.react.bridge.LifecycleEventListener
|
|
8
9
|
import com.facebook.react.bridge.ReadableMap
|
|
9
10
|
import com.facebook.react.bridge.WritableArray
|
|
10
11
|
import com.facebook.react.bridge.WritableMap
|
|
@@ -24,14 +25,19 @@ import java.util.concurrent.ExecutorService
|
|
|
24
25
|
import java.util.concurrent.Executors
|
|
25
26
|
|
|
26
27
|
@ReactModule(name = PayNlSdkModule.NAME)
|
|
27
|
-
class PayNlSdkModule(private val reactContext: ReactApplicationContext) :
|
|
28
|
+
class PayNlSdkModule(private val reactContext: ReactApplicationContext) :
|
|
29
|
+
NativePayNlSdkSpec(reactContext), LifecycleEventListener {
|
|
28
30
|
|
|
29
|
-
|
|
30
|
-
private val executorService: ExecutorService = Executors.newSingleThreadExecutor()
|
|
31
|
+
private var posService: PosService
|
|
31
32
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
override fun getName(): String {
|
|
34
|
+
return NAME
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
init {
|
|
38
|
+
posService = PosService(reactContext.currentActivity)
|
|
39
|
+
reactContext.addLifecycleEventListener(this)
|
|
40
|
+
}
|
|
35
41
|
|
|
36
42
|
companion object {
|
|
37
43
|
const val NAME = "PaynlSdk"
|
|
@@ -306,4 +312,11 @@ class PayNlSdkModule(private val reactContext: ReactApplicationContext) : Native
|
|
|
306
312
|
override fun clearOfflineItem(id: String): Boolean {
|
|
307
313
|
return posService.clearOfflineItem(id)
|
|
308
314
|
}
|
|
315
|
+
|
|
316
|
+
override fun onHostResume() {
|
|
317
|
+
posService.setContext(reactContext.currentActivity)
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
override fun onHostDestroy() {}
|
|
321
|
+
override fun onHostPause() {}
|
|
309
322
|
}
|
|
@@ -7,6 +7,7 @@ import android.util.Log
|
|
|
7
7
|
import com.facebook.react.bridge.Promise
|
|
8
8
|
import com.facebook.react.bridge.ReactApplicationContext
|
|
9
9
|
import com.facebook.react.bridge.ReactContextBaseJavaModule
|
|
10
|
+
import com.facebook.react.bridge.LifecycleEventListener
|
|
10
11
|
import com.facebook.react.bridge.ReactMethod
|
|
11
12
|
import com.facebook.react.bridge.ReadableMap
|
|
12
13
|
import com.facebook.react.bridge.WritableArray
|
|
@@ -19,26 +20,29 @@ import com.paynl.pos.sdk.PosService
|
|
|
19
20
|
import com.paynl.pos.sdk.shared.events.PaymentEvent
|
|
20
21
|
import com.paynl.pos.sdk.shared.exceptions.SVErrorBaseException
|
|
21
22
|
import com.paynl.pos.sdk.shared.exceptions.SV_0000_UNEXPECTED_ERROR
|
|
22
|
-
import com.paynl.pos.sdk.shared.models.offline.OfflineQueueModel
|
|
23
23
|
import com.paynl.pos.sdk.shared.models.paynl.PayNlInitResult
|
|
24
24
|
import com.paynl.pos.sdk.shared.models.paynl.PayNlConfigurationBuilder
|
|
25
25
|
|
|
26
26
|
import java.text.DateFormat
|
|
27
27
|
import java.text.SimpleDateFormat
|
|
28
28
|
import java.util.concurrent.CompletableFuture
|
|
29
|
-
import java.util.concurrent.ExecutorService
|
|
30
|
-
import java.util.concurrent.Executors
|
|
31
29
|
|
|
32
30
|
@ReactModule(name = PayNlSdkModule.NAME)
|
|
33
31
|
class PayNlSdkModule(private val reactContext: ReactApplicationContext) :
|
|
34
|
-
ReactContextBaseJavaModule(reactContext) {
|
|
32
|
+
ReactContextBaseJavaModule(reactContext), LifecycleEventListener {
|
|
35
33
|
|
|
36
|
-
private var posService
|
|
34
|
+
private var posService: PosService
|
|
37
35
|
|
|
38
36
|
override fun getName(): String {
|
|
39
37
|
return NAME
|
|
40
38
|
}
|
|
41
39
|
|
|
40
|
+
init {
|
|
41
|
+
posService = PosService(reactContext.currentActivity)
|
|
42
|
+
reactContext.addLifecycleEventListener(this)
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
|
|
42
46
|
companion object {
|
|
43
47
|
const val NAME = "PaynlSdk"
|
|
44
48
|
}
|
|
@@ -334,4 +338,11 @@ class PayNlSdkModule(private val reactContext: ReactApplicationContext) :
|
|
|
334
338
|
.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java)
|
|
335
339
|
.emit("onPaymentEvent", params)
|
|
336
340
|
}
|
|
341
|
+
|
|
342
|
+
override fun onHostResume() {
|
|
343
|
+
posService.setContext(reactContext.currentActivity)
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
override fun onHostDestroy() {}
|
|
347
|
+
override fun onHostPause() {}
|
|
337
348
|
}
|