otpless-headless-rn 2.0.3 → 2.0.4

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.
@@ -74,7 +74,7 @@ dependencies {
74
74
  //noinspection GradleDynamicVersion
75
75
  implementation "com.facebook.react:react-native:+"
76
76
  implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
77
- implementation ("io.github.otpless-tech:otpless-headless-sdk:0.3.8")
77
+ implementation ("io.github.otpless-tech:otpless-headless-sdk:0.6.4")
78
78
  }
79
79
 
80
80
  if (isNewArchitectureEnabled()) {
@@ -19,6 +19,8 @@ import com.otpless.v2.android.sdk.dto.OtplessResponse
19
19
  import com.otpless.v2.android.sdk.dto.ResponseTypes
20
20
  import com.otpless.v2.android.sdk.main.OtplessSDK
21
21
  import com.otpless.v2.android.sdk.utils.OtplessUtils
22
+ import kotlinx.coroutines.CoroutineScope
23
+ import kotlinx.coroutines.Dispatchers
22
24
  import kotlinx.coroutines.Job
23
25
  import kotlinx.coroutines.launch
24
26
  import org.json.JSONException
@@ -68,12 +70,22 @@ class OtplessHeadlessRNModule(private val reactContext: ReactApplicationContext)
68
70
 
69
71
  @ReactMethod
70
72
  fun initialize(appId: String, loginUri: String? = null) {
71
- currentActivity?.let {
72
- OtplessSDK.initialize(
73
- appId = appId,
74
- activity = it,
75
- loginUri = loginUri
76
- )
73
+ (currentActivity as? AppCompatActivity)?.lifecycleScope?.let { scope ->
74
+ scope.launch(Dispatchers.IO) {
75
+ OtplessSDK.initialize(
76
+ appId = appId,
77
+ activity = currentActivity!!,
78
+ loginUri = loginUri
79
+ )
80
+ }
81
+ } ?: run {
82
+ CoroutineScope(Dispatchers.IO).launch {
83
+ OtplessSDK.initialize(
84
+ appId = appId,
85
+ activity = currentActivity!!,
86
+ loginUri = loginUri
87
+ )
88
+ }
77
89
  }
78
90
  }
79
91
 
@@ -136,16 +148,18 @@ class OtplessHeadlessRNModule(private val reactContext: ReactApplicationContext)
136
148
  otplessRequest.setTemplateId(templateId)
137
149
  }
138
150
 
139
- if (isOtpPresent) {
140
- OtplessSDK.startAsync(request = otplessRequest, this@OtplessHeadlessRNModule::sendHeadlessEventCallback)
141
- } else {
142
- otplessJob?.cancel()
143
- currentActivity?.let {
151
+ otplessJob?.cancel()
152
+ currentActivity?.let {
153
+ if (isOtpPresent) (it as AppCompatActivity).lifecycleScope.launch(Dispatchers.IO) {
154
+ OtplessSDK.start(request = otplessRequest, this@OtplessHeadlessRNModule::sendHeadlessEventCallback)
155
+ } else {
144
156
  otplessJob = (it as AppCompatActivity).lifecycleScope.launch {
145
157
  OtplessSDK.start(request = otplessRequest, this@OtplessHeadlessRNModule::sendHeadlessEventCallback)
146
158
  }
147
- } ?: run {
148
- OtplessSDK.startAsync(request = otplessRequest, this@OtplessHeadlessRNModule::sendHeadlessEventCallback)
159
+ }
160
+ } ?: run {
161
+ CoroutineScope(Dispatchers.IO).launch {
162
+ OtplessSDK.start(request = otplessRequest, this@OtplessHeadlessRNModule::sendHeadlessEventCallback)
149
163
  }
150
164
  }
151
165
  }
@@ -187,7 +201,11 @@ class OtplessHeadlessRNModule(private val reactContext: ReactApplicationContext)
187
201
 
188
202
  override fun onNewIntent(intent: Intent?) {
189
203
  intent ?: return
190
- OtplessSDK.onNewIntentAsync(intent)
204
+ (currentActivity as? AppCompatActivity)?.let { ac ->
205
+ ac.lifecycleScope.launch(Dispatchers.IO) {
206
+ OtplessSDK.onNewIntent(intent)
207
+ }
208
+ }
191
209
  }
192
210
 
193
211
  @ReactMethod
@@ -17,7 +17,7 @@ Pod::Spec.new do |s|
17
17
  s.source_files = "ios/**/*.{h,m,mm,swift}"
18
18
 
19
19
  s.dependency "React-Core"
20
- s.dependency 'OtplessBM/Core', '2.0.3'
20
+ s.dependency 'OtplessBM/Core', '2.0.7'
21
21
  s.swift_versions = ['5.5']
22
22
 
23
23
  # Don't install the dependencies when we run `pod install` in the old architecture.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "otpless-headless-rn",
3
- "version": "2.0.3",
3
+ "version": "2.0.4",
4
4
  "description": "react native plugin for otpless headless android and ios",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",