From 2887808b17e0c7cd9f71598960ba62219b9174a3 Mon Sep 17 00:00:00 2001 From: Sourav Bapari Date: Wed, 26 Nov 2025 00:12:27 +0530 Subject: [PATCH 1/2] Fix ReactApplicationContext isshue --- README.md | 64 ++++++++++--------- .../SmallcaseGatewayModule.kt | 39 ++++++----- 2 files changed, 57 insertions(+), 46 deletions(-) diff --git a/README.md b/README.md index 80a9d484..30bb04b3 100644 --- a/README.md +++ b/README.md @@ -35,13 +35,20 @@ Add these lines to your project level `build.gradle` ```groovy allprojects { repositories { - // .. you other repositories + // .. your existing repositories + + // Starting from version 2.3.0 all versions of the sdk are now hosted on a public repository + maven { + url "https://artifactory.smallcase.com/artifactory/SCGateway" + } + + // Only for versions < 2.3.0 maven { - url "http://artifactory.smallcase.com/artifactory/gradle-dev-local" + url "https://artifactory.smallcase.com/artifactory/gradle-dev-local" credentials { username "react_native_user" password "reactNativeUser123" - } + } } } } @@ -50,30 +57,30 @@ allprojects { add these lines in `AndroidManifest.xml` in the main `` tag ```xml - - - - - - - - + + + + + + + - - - - - - - - - + + + + + + + ``` @@ -83,15 +90,14 @@ add these lines in `AndroidManifest.xml` in the main `` tag // import gateway into your file import SmallcaseGateway from "react-native-smallcase-gateway"; -// configure environment await SmallcaseGateway.setConfigEnvironment({ isLeprechaun: true, isAmoEnabled: true, - gatewayName: "smallcase-website", + gatewayName: "", + // `environmentName` should always be PROD, regardless of your environment environmentName: SmallcaseGateway.ENV.PROD, - brokerList: ["kite", "aliceblue", "trustline"], + brokerList: [], }); - // initialize session await SmallcaseGateway.init(sdkToken); diff --git a/android/src/main/java/com/reactnativesmallcasegateway/SmallcaseGatewayModule.kt b/android/src/main/java/com/reactnativesmallcasegateway/SmallcaseGatewayModule.kt index da28ad8b..e4fb11dd 100644 --- a/android/src/main/java/com/reactnativesmallcasegateway/SmallcaseGatewayModule.kt +++ b/android/src/main/java/com/reactnativesmallcasegateway/SmallcaseGatewayModule.kt @@ -67,6 +67,7 @@ class SmallcaseGatewayModule(reactContext: ReactApplicationContext) : ReactConte @ReactMethod fun init(sdkToken: String, promise: Promise) { + Log.d(TAG, "init: start") val initReq = InitRequest(sdkToken) SmallcaseGatewaySdk.init(authRequest = initReq, gatewayInitialisationListener = object : DataListener { @@ -84,6 +85,7 @@ class SmallcaseGatewayModule(reactContext: ReactApplicationContext) : ReactConte @ReactMethod fun triggerTransaction(transactionId: String, utmParams: ReadableMap?, brokerList: ReadableArray?, promise: Promise) { + Log.d(TAG, "triggerTransaction: start") var safeBrokerList = listOf() @@ -92,7 +94,7 @@ class SmallcaseGatewayModule(reactContext: ReactApplicationContext) : ReactConte } - val activity = currentActivity; + val activity = reactApplicationContext.currentActivity; if (activity != null) { val utm = readableMapToStrHashMap(utmParams) SmallcaseGatewaySdk.triggerTransaction(utmParams = utm, @@ -118,10 +120,10 @@ class SmallcaseGatewayModule(reactContext: ReactApplicationContext) : ReactConte @ReactMethod fun triggerMfTransaction(transactionId: String, promise: Promise) { - if(currentActivity != null) { + if(reactApplicationContext.currentActivity != null) { SmallcaseGatewaySdk.triggerMfTransaction( - activity = currentActivity!!, + activity = reactApplicationContext.currentActivity!!, transactionId = transactionId, listener = object : MFHoldingsResponseListener { @@ -142,7 +144,7 @@ class SmallcaseGatewayModule(reactContext: ReactApplicationContext) : ReactConte @ReactMethod fun showOrders(promise: Promise) { - val activity = currentActivity; + val activity = reactApplicationContext.currentActivity; if (activity != null) { SmallcaseGatewaySdk.showOrders(activity = activity, showOrdersResponseListener = object : DataListener { override fun onSuccess(response: Any) { @@ -159,8 +161,9 @@ class SmallcaseGatewayModule(reactContext: ReactApplicationContext) : ReactConte @ReactMethod fun launchSmallplug(targetEndpoint: String, params: String, promise: Promise) { + Log.d(TAG, "launchSmallplug: start") - SmallcaseGatewaySdk.launchSmallPlug(currentActivity!!, SmallplugData(targetEndpoint, params), object : SmallPlugResponseListener { + SmallcaseGatewaySdk.launchSmallPlug(reactApplicationContext.currentActivity!!, SmallplugData(targetEndpoint, params), object : SmallPlugResponseListener { override fun onFailure(errorCode: Int, errorMessage: String) { val err = createErrorJSON(errorCode, errorMessage, null) @@ -195,6 +198,7 @@ class SmallcaseGatewayModule(reactContext: ReactApplicationContext) : ReactConte } } } + Log.d(TAG, "launchSmallplugWithBranding: start") var partnerProps: SmallplugPartnerProps? = SmallplugPartnerProps(headerColor = "#2F363F", backIconColor = "ffffff") @@ -209,7 +213,7 @@ class SmallcaseGatewayModule(reactContext: ReactApplicationContext) : ReactConte } catch (e: Throwable) { } - SmallcaseGatewaySdk.launchSmallPlug(currentActivity!!, SmallplugData(targetEndpoint, params), object : SmallPlugResponseListener { + SmallcaseGatewaySdk.launchSmallPlug(reactApplicationContext.currentActivity!!, SmallplugData(targetEndpoint, params), object : SmallPlugResponseListener { override fun onFailure(errorCode: Int, errorMessage: String) { val err = createErrorJSON(errorCode, errorMessage, null) promise.reject("error", err) @@ -224,6 +228,7 @@ class SmallcaseGatewayModule(reactContext: ReactApplicationContext) : ReactConte @ReactMethod fun archiveSmallcase(iscid: String, promise: Promise) { + Log.d(TAG, "markSmallcaseArchive: start") SmallcaseGatewaySdk.markSmallcaseArchived(iscid, object : DataListener { @@ -240,7 +245,7 @@ class SmallcaseGatewayModule(reactContext: ReactApplicationContext) : ReactConte @ReactMethod fun logoutUser(promise: Promise) { - val activity = currentActivity; + val activity = reactApplicationContext.currentActivity; if (activity != null) { SmallcaseGatewaySdk.logoutUser(activity = activity, logoutListener = object : SmallcaseLogoutListener { override fun onLogoutSuccessfull() { @@ -257,7 +262,7 @@ class SmallcaseGatewayModule(reactContext: ReactApplicationContext) : ReactConte @ReactMethod fun triggerLeadGen(userDetails: ReadableMap, utmData: ReadableMap) { - val activity = currentActivity; + val activity = reactApplicationContext.currentActivity; if (activity != null) { SmallcaseGatewaySdk.triggerLeadGen(activity = activity, utmParams = readableMapToStrHashMap(utmData), params = readableMapToStrHashMap(userDetails)) } @@ -265,7 +270,7 @@ class SmallcaseGatewayModule(reactContext: ReactApplicationContext) : ReactConte @ReactMethod fun triggerLeadGenWithStatus(userDetails: ReadableMap, promise: Promise) { - val activity = currentActivity + val activity = reactApplicationContext.currentActivity if (activity != null) { SmallcaseGatewaySdk.triggerLeadGen(activity, readableMapToStrHashMap(userDetails), object : LeadGenResponseListener { @@ -278,10 +283,10 @@ class SmallcaseGatewayModule(reactContext: ReactApplicationContext) : ReactConte @ReactMethod fun triggerLeadGenWithLoginCta(userDetails: ReadableMap, utmData: ReadableMap, showLoginCta: Boolean, promise: Promise) { - if(currentActivity != null) { + if(reactApplicationContext.currentActivity != null) { SmallcaseGatewaySdk.triggerLeadGen( - activity = currentActivity!!, + activity = reactApplicationContext.currentActivity!!, params = readableMapToStrHashMap(userDetails), utmParams = readableMapToStrHashMap(utmData), retargeting = null, @@ -296,7 +301,7 @@ class SmallcaseGatewayModule(reactContext: ReactApplicationContext) : ReactConte @ReactMethod fun setupLoans(config: ReadableMap, promise: Promise) { - val appCompatActivity = currentActivity as? AppCompatActivity ?: return + val appCompatActivity = reactApplicationContext.currentActivity as? AppCompatActivity ?: return val hashMap = readableMapToStrHashMap(config) val gateway = hashMap["gatewayName"] val environment = hashMap["environment"] @@ -324,7 +329,7 @@ class SmallcaseGatewayModule(reactContext: ReactApplicationContext) : ReactConte @ReactMethod fun apply(loanConfig: ReadableMap, promise: Promise) { - val appCompatActivity = currentActivity as? AppCompatActivity ?: return + val appCompatActivity = reactApplicationContext.currentActivity as? AppCompatActivity ?: return val hashMap = readableMapToStrHashMap(loanConfig) val interactionToken = hashMap["interactionToken"] if(interactionToken == null) { @@ -345,7 +350,7 @@ class SmallcaseGatewayModule(reactContext: ReactApplicationContext) : ReactConte @ReactMethod fun pay(loanConfig: ReadableMap, promise: Promise) { - val appCompatActivity = currentActivity as? AppCompatActivity ?: return + val appCompatActivity = reactApplicationContext.currentActivity as? AppCompatActivity ?: return val hashMap = readableMapToStrHashMap(loanConfig) val interactionToken = hashMap["interactionToken"] if(interactionToken == null) { @@ -366,7 +371,7 @@ class SmallcaseGatewayModule(reactContext: ReactApplicationContext) : ReactConte @ReactMethod fun withdraw(loanConfig: ReadableMap, promise: Promise) { - val appCompatActivity = currentActivity as? AppCompatActivity ?: return + val appCompatActivity = reactApplicationContext.currentActivity as? AppCompatActivity ?: return val hashMap = readableMapToStrHashMap(loanConfig) val interactionToken = hashMap["interactionToken"] if(interactionToken == null) { @@ -387,7 +392,7 @@ class SmallcaseGatewayModule(reactContext: ReactApplicationContext) : ReactConte @ReactMethod fun service(loanConfig: ReadableMap, promise: Promise) { - val appCompatActivity = currentActivity as? AppCompatActivity ?: return + val appCompatActivity = reactApplicationContext.currentActivity as? AppCompatActivity ?: return val hashMap = readableMapToStrHashMap(loanConfig) val interactionToken = hashMap["interactionToken"] if(interactionToken == null) { @@ -408,7 +413,7 @@ class SmallcaseGatewayModule(reactContext: ReactApplicationContext) : ReactConte @ReactMethod fun triggerInteraction(loanConfig: ReadableMap, promise: Promise) { - val appCompatActivity = currentActivity as? AppCompatActivity ?: return + val appCompatActivity = reactApplicationContext.currentActivity as? AppCompatActivity ?: return val hashMap = readableMapToStrHashMap(loanConfig) val interactionToken = hashMap["interactionToken"] if(interactionToken == null) { From bab281c28a9f84682da74ab5699259ccb0c95e1b Mon Sep 17 00:00:00 2001 From: Sourav Bapari Date: Wed, 26 Nov 2025 00:17:21 +0530 Subject: [PATCH 2/2] Update SmallcaseGatewayModule.kt --- .../SmallcaseGatewayModule.kt | 39 +++++++++++-------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/android/src/main/java/com/reactnativesmallcasegateway/SmallcaseGatewayModule.kt b/android/src/main/java/com/reactnativesmallcasegateway/SmallcaseGatewayModule.kt index da28ad8b..e4fb11dd 100644 --- a/android/src/main/java/com/reactnativesmallcasegateway/SmallcaseGatewayModule.kt +++ b/android/src/main/java/com/reactnativesmallcasegateway/SmallcaseGatewayModule.kt @@ -67,6 +67,7 @@ class SmallcaseGatewayModule(reactContext: ReactApplicationContext) : ReactConte @ReactMethod fun init(sdkToken: String, promise: Promise) { + Log.d(TAG, "init: start") val initReq = InitRequest(sdkToken) SmallcaseGatewaySdk.init(authRequest = initReq, gatewayInitialisationListener = object : DataListener { @@ -84,6 +85,7 @@ class SmallcaseGatewayModule(reactContext: ReactApplicationContext) : ReactConte @ReactMethod fun triggerTransaction(transactionId: String, utmParams: ReadableMap?, brokerList: ReadableArray?, promise: Promise) { + Log.d(TAG, "triggerTransaction: start") var safeBrokerList = listOf() @@ -92,7 +94,7 @@ class SmallcaseGatewayModule(reactContext: ReactApplicationContext) : ReactConte } - val activity = currentActivity; + val activity = reactApplicationContext.currentActivity; if (activity != null) { val utm = readableMapToStrHashMap(utmParams) SmallcaseGatewaySdk.triggerTransaction(utmParams = utm, @@ -118,10 +120,10 @@ class SmallcaseGatewayModule(reactContext: ReactApplicationContext) : ReactConte @ReactMethod fun triggerMfTransaction(transactionId: String, promise: Promise) { - if(currentActivity != null) { + if(reactApplicationContext.currentActivity != null) { SmallcaseGatewaySdk.triggerMfTransaction( - activity = currentActivity!!, + activity = reactApplicationContext.currentActivity!!, transactionId = transactionId, listener = object : MFHoldingsResponseListener { @@ -142,7 +144,7 @@ class SmallcaseGatewayModule(reactContext: ReactApplicationContext) : ReactConte @ReactMethod fun showOrders(promise: Promise) { - val activity = currentActivity; + val activity = reactApplicationContext.currentActivity; if (activity != null) { SmallcaseGatewaySdk.showOrders(activity = activity, showOrdersResponseListener = object : DataListener { override fun onSuccess(response: Any) { @@ -159,8 +161,9 @@ class SmallcaseGatewayModule(reactContext: ReactApplicationContext) : ReactConte @ReactMethod fun launchSmallplug(targetEndpoint: String, params: String, promise: Promise) { + Log.d(TAG, "launchSmallplug: start") - SmallcaseGatewaySdk.launchSmallPlug(currentActivity!!, SmallplugData(targetEndpoint, params), object : SmallPlugResponseListener { + SmallcaseGatewaySdk.launchSmallPlug(reactApplicationContext.currentActivity!!, SmallplugData(targetEndpoint, params), object : SmallPlugResponseListener { override fun onFailure(errorCode: Int, errorMessage: String) { val err = createErrorJSON(errorCode, errorMessage, null) @@ -195,6 +198,7 @@ class SmallcaseGatewayModule(reactContext: ReactApplicationContext) : ReactConte } } } + Log.d(TAG, "launchSmallplugWithBranding: start") var partnerProps: SmallplugPartnerProps? = SmallplugPartnerProps(headerColor = "#2F363F", backIconColor = "ffffff") @@ -209,7 +213,7 @@ class SmallcaseGatewayModule(reactContext: ReactApplicationContext) : ReactConte } catch (e: Throwable) { } - SmallcaseGatewaySdk.launchSmallPlug(currentActivity!!, SmallplugData(targetEndpoint, params), object : SmallPlugResponseListener { + SmallcaseGatewaySdk.launchSmallPlug(reactApplicationContext.currentActivity!!, SmallplugData(targetEndpoint, params), object : SmallPlugResponseListener { override fun onFailure(errorCode: Int, errorMessage: String) { val err = createErrorJSON(errorCode, errorMessage, null) promise.reject("error", err) @@ -224,6 +228,7 @@ class SmallcaseGatewayModule(reactContext: ReactApplicationContext) : ReactConte @ReactMethod fun archiveSmallcase(iscid: String, promise: Promise) { + Log.d(TAG, "markSmallcaseArchive: start") SmallcaseGatewaySdk.markSmallcaseArchived(iscid, object : DataListener { @@ -240,7 +245,7 @@ class SmallcaseGatewayModule(reactContext: ReactApplicationContext) : ReactConte @ReactMethod fun logoutUser(promise: Promise) { - val activity = currentActivity; + val activity = reactApplicationContext.currentActivity; if (activity != null) { SmallcaseGatewaySdk.logoutUser(activity = activity, logoutListener = object : SmallcaseLogoutListener { override fun onLogoutSuccessfull() { @@ -257,7 +262,7 @@ class SmallcaseGatewayModule(reactContext: ReactApplicationContext) : ReactConte @ReactMethod fun triggerLeadGen(userDetails: ReadableMap, utmData: ReadableMap) { - val activity = currentActivity; + val activity = reactApplicationContext.currentActivity; if (activity != null) { SmallcaseGatewaySdk.triggerLeadGen(activity = activity, utmParams = readableMapToStrHashMap(utmData), params = readableMapToStrHashMap(userDetails)) } @@ -265,7 +270,7 @@ class SmallcaseGatewayModule(reactContext: ReactApplicationContext) : ReactConte @ReactMethod fun triggerLeadGenWithStatus(userDetails: ReadableMap, promise: Promise) { - val activity = currentActivity + val activity = reactApplicationContext.currentActivity if (activity != null) { SmallcaseGatewaySdk.triggerLeadGen(activity, readableMapToStrHashMap(userDetails), object : LeadGenResponseListener { @@ -278,10 +283,10 @@ class SmallcaseGatewayModule(reactContext: ReactApplicationContext) : ReactConte @ReactMethod fun triggerLeadGenWithLoginCta(userDetails: ReadableMap, utmData: ReadableMap, showLoginCta: Boolean, promise: Promise) { - if(currentActivity != null) { + if(reactApplicationContext.currentActivity != null) { SmallcaseGatewaySdk.triggerLeadGen( - activity = currentActivity!!, + activity = reactApplicationContext.currentActivity!!, params = readableMapToStrHashMap(userDetails), utmParams = readableMapToStrHashMap(utmData), retargeting = null, @@ -296,7 +301,7 @@ class SmallcaseGatewayModule(reactContext: ReactApplicationContext) : ReactConte @ReactMethod fun setupLoans(config: ReadableMap, promise: Promise) { - val appCompatActivity = currentActivity as? AppCompatActivity ?: return + val appCompatActivity = reactApplicationContext.currentActivity as? AppCompatActivity ?: return val hashMap = readableMapToStrHashMap(config) val gateway = hashMap["gatewayName"] val environment = hashMap["environment"] @@ -324,7 +329,7 @@ class SmallcaseGatewayModule(reactContext: ReactApplicationContext) : ReactConte @ReactMethod fun apply(loanConfig: ReadableMap, promise: Promise) { - val appCompatActivity = currentActivity as? AppCompatActivity ?: return + val appCompatActivity = reactApplicationContext.currentActivity as? AppCompatActivity ?: return val hashMap = readableMapToStrHashMap(loanConfig) val interactionToken = hashMap["interactionToken"] if(interactionToken == null) { @@ -345,7 +350,7 @@ class SmallcaseGatewayModule(reactContext: ReactApplicationContext) : ReactConte @ReactMethod fun pay(loanConfig: ReadableMap, promise: Promise) { - val appCompatActivity = currentActivity as? AppCompatActivity ?: return + val appCompatActivity = reactApplicationContext.currentActivity as? AppCompatActivity ?: return val hashMap = readableMapToStrHashMap(loanConfig) val interactionToken = hashMap["interactionToken"] if(interactionToken == null) { @@ -366,7 +371,7 @@ class SmallcaseGatewayModule(reactContext: ReactApplicationContext) : ReactConte @ReactMethod fun withdraw(loanConfig: ReadableMap, promise: Promise) { - val appCompatActivity = currentActivity as? AppCompatActivity ?: return + val appCompatActivity = reactApplicationContext.currentActivity as? AppCompatActivity ?: return val hashMap = readableMapToStrHashMap(loanConfig) val interactionToken = hashMap["interactionToken"] if(interactionToken == null) { @@ -387,7 +392,7 @@ class SmallcaseGatewayModule(reactContext: ReactApplicationContext) : ReactConte @ReactMethod fun service(loanConfig: ReadableMap, promise: Promise) { - val appCompatActivity = currentActivity as? AppCompatActivity ?: return + val appCompatActivity = reactApplicationContext.currentActivity as? AppCompatActivity ?: return val hashMap = readableMapToStrHashMap(loanConfig) val interactionToken = hashMap["interactionToken"] if(interactionToken == null) { @@ -408,7 +413,7 @@ class SmallcaseGatewayModule(reactContext: ReactApplicationContext) : ReactConte @ReactMethod fun triggerInteraction(loanConfig: ReadableMap, promise: Promise) { - val appCompatActivity = currentActivity as? AppCompatActivity ?: return + val appCompatActivity = reactApplicationContext.currentActivity as? AppCompatActivity ?: return val hashMap = readableMapToStrHashMap(loanConfig) val interactionToken = hashMap["interactionToken"] if(interactionToken == null) {