otpless-headless-rn 1.0.1 → 1.0.3

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.1.2")
77
+ implementation ("io.github.otpless-tech:otpless-headless-sdk:0.1.7")
78
78
  }
79
79
 
80
80
  if (isNewArchitectureEnabled()) {
@@ -2,6 +2,8 @@ package com.otplessheadlessrn
2
2
 
3
3
  import android.app.Activity
4
4
  import android.content.Intent
5
+ import androidx.appcompat.app.AppCompatActivity
6
+ import androidx.lifecycle.lifecycleScope
5
7
  import com.facebook.react.bridge.ActivityEventListener
6
8
  import com.facebook.react.bridge.Callback
7
9
  import com.facebook.react.bridge.ReactApplicationContext
@@ -15,8 +17,6 @@ import com.otpless.v2.android.sdk.dto.OtplessResponse
15
17
  import com.otpless.v2.android.sdk.dto.ResponseTypes
16
18
  import com.otpless.v2.android.sdk.main.OtplessSDK
17
19
  import com.otpless.v2.android.sdk.utils.OtplessUtils
18
- import kotlinx.coroutines.CoroutineScope
19
- import kotlinx.coroutines.Dispatchers
20
20
  import kotlinx.coroutines.Job
21
21
  import kotlinx.coroutines.launch
22
22
  import org.json.JSONException
@@ -130,8 +130,12 @@ class OtplessHeadlessRNModule(private val reactContext: ReactApplicationContext)
130
130
  OtplessSDK.startAsync(request = otplessRequest, this@OtplessHeadlessRNModule::sendHeadlessEventCallback)
131
131
  } else {
132
132
  otplessJob?.cancel()
133
- otplessJob = CoroutineScope(Dispatchers.IO).launch {
134
- OtplessSDK.start(request = otplessRequest, this@OtplessHeadlessRNModule::sendHeadlessEventCallback)
133
+ currentActivity?.let {
134
+ otplessJob = (it as AppCompatActivity).lifecycleScope.launch {
135
+ OtplessSDK.start(request = otplessRequest, this@OtplessHeadlessRNModule::sendHeadlessEventCallback)
136
+ }
137
+ } ?: run {
138
+ OtplessSDK.startAsync(request = otplessRequest, this@OtplessHeadlessRNModule::sendHeadlessEventCallback)
135
139
  }
136
140
  }
137
141
  }
@@ -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', '1.0.5'
20
+ s.dependency 'OtplessBM/Core', '1.0.8'
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": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "description": "react native plugin for otpless headless android and ios",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",