Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
9c53b71
fix: setup sdk function working now
aaditya-smallcase May 30, 2025
b30f6fa
feat: remove old example app and add new smart investing app
indrajit-roy-sc Jul 20, 2025
f4d0333
chore: android working state with 0.79.4
indrajit-roy-sc Jul 20, 2025
6acd2e4
chore: ios working state with 0.79.4
indrajit-roy-sc Jul 20, 2025
2f9c755
feat: implement core functionality for smart investing app
indrajit-roy-sc Jul 20, 2025
129e071
chore: revert back iOS min version and SCGateway dependency to match
indrajit-roy-sc Jul 24, 2025
24b1ca8
chore: update Podfile.lock
indrajit-roy-sc Jul 24, 2025
94a5d70
feat(analytics): Adding events capturing through new RCTBridgeModule
dporwal-shipit Jul 29, 2025
75bd9c3
feat(analytics): Adding events capturing through new RCTBridgeModule
dporwal-shipit Jul 29, 2025
0fc855d
feature(analytics): working state
dporwal-shipit Jul 30, 2025
145a91d
chore: update SCGateway dependency to version 4.1.5 in Podfile.lock
indrajit-roy-sc Aug 1, 2025
c70b0b1
chore: update iOS run script to list available devices
indrajit-roy-sc Aug 1, 2025
63378d4
revert: change impl. back to stable version
indrajit-roy-sc Aug 1, 2025
4eb3933
feature(analytics): updated code to capture events.
dporwal-shipit Aug 5, 2025
0e0091a
feature(analytics): updated code to capture events.
dporwal-shipit Aug 5, 2025
44ad07b
feat(analytics):- remove Mixpanel from SCLoans and substitute with ne…
dporwal-shipit Aug 8, 2025
2a2b64d
app building
dporwal-shipit Aug 11, 2025
f82d8c1
developing android event flow
dporwal-shipit Aug 12, 2025
2a319f7
feature(analytics): working state android and ios scgateway emitters
dporwal-shipit Aug 12, 2025
08de62a
feature(analytics): Working state android scloans events incoming
dporwal-shipit Aug 18, 2025
42eb202
feature(analytics): working state ios events emission-capturing
dporwal-shipit Aug 26, 2025
ca7ed39
feature(analytics): working state android events emission-capturing
dporwal-shipit Aug 26, 2025
8008365
refactor(analytics): restructure event bridging logic for improved ma…
dporwal-shipit Aug 30, 2025
767a0c2
refactor(analytics): restructure loans event bridging logic for impro…
dporwal-shipit Aug 31, 2025
46d9821
feature(analytics): making changes as requested in PR reviews
dporwal-shipit Sep 4, 2025
3691d60
feature(analytics): making changes as per PR request reviews
dporwal-shipit Sep 5, 2025
9ee02e7
feature(analytics): making changes as per PR request reviews
dporwal-shipit Sep 5, 2025
2b62d03
refactor(SCGatewayEvents): streamline initialization and subscription…
indrajit-roy-sc Sep 5, 2025
b55d7e3
refactor(analytics): refactoring the native files in bridge to forwar…
dporwal-shipit Sep 6, 2025
d29aba7
refactor(analytics): refactoring the code, shifted App.tsx from class…
dporwal-shipit Sep 6, 2025
9d19442
refactor(analytics): working state of android scgateway & scloans
dporwal-shipit Sep 7, 2025
2832b51
refactor(analytics): working state of ios scgateway & scloans
dporwal-shipit Sep 7, 2025
27eb4fb
refactor(analytics): making use of native sdk exposed properties dire…
dporwal-shipit Sep 7, 2025
1e7f2a0
refactor(analytics): standardize class structure with formatting and …
dporwal-shipit Sep 7, 2025
a17eac1
chore(analytics): Merge upgrade/react-native-0.79.4 into branch upgra…
dporwal-shipit Sep 7, 2025
8292030
refactor: improve event emitters and clean up codebase
dporwal-shipit Sep 8, 2025
4f1a28e
refactor: we no longer need try-catch in onCatalystInstanceDestroy
dporwal-shipit Sep 8, 2025
4fe94b8
refactor: we no longer need try-catch in onCatalystInstanceDestroy
dporwal-shipit Sep 8, 2025
4949c3e
refactor: renaming to ensure consistency across ios/android
dporwal-shipit Sep 8, 2025
3891eee
changed the PRODUCT_BUNDLE_IDENTIFIER and updated build.gradle with n…
dporwal-shipit Sep 8, 2025
b26c64b
making changes as per PR reviews
dporwal-shipit Sep 8, 2025
eff311e
making changes as per PR
dporwal-shipit Sep 9, 2025
8697b0b
Merge remote-tracking branch 'origin/development' into upgrade-react-…
dporwal-shipit Sep 9, 2025
09f4c52
2nd emitter got added while testing in XCode-VSCode, removed
dporwal-shipit Sep 9, 2025
25e9221
making changes as per PR reviews
dporwal-shipit Sep 10, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,8 @@ def kotlin_version = getExtOrDefault('kotlinVersion')
dependencies {
//noinspection GradleDynamicVersion
implementation 'com.facebook.react:react-native:+' // From node_modules
implementation 'com.smallcase.gateway:sdk:4.3.0'
implementation 'com.smallcase.loans:sdk:3.1.1'
implementation "com.smallcase.gateway:sdk-release-scg-v5-0-0-loans-v4-0-0-1df0c05:4.3.0-3183-release"
implementation "com.smallcase.loans:sdk-release-scg-v5-0-0-loans-v4-0-0-1df0c05:3.1.1-81-release"
implementation "androidx.core:core-ktx:1.3.1"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@

// SCGatewayBridgeEmitter.kt
package com.reactnativesmallcasegateway

import android.util.Log
import com.facebook.react.bridge.*
import com.facebook.react.bridge.UiThreadUtil
import com.facebook.react.modules.core.DeviceEventManagerModule
import com.smallcase.gateway.data.listeners.Notification
import com.smallcase.gateway.data.listeners.NotificationCenter
import com.smallcase.gateway.portal.ScgNotification
import com.smallcase.gateway.portal.SmallcaseGatewaySdk

class SCGatewayBridgeEmitter(private val reactContext: ReactApplicationContext) :
ReactContextBaseJavaModule(reactContext) {

companion object {
const val TAG = "SCGatewayBridgeEmitter"
}

private var notificationObserver: ((Notification) -> Unit)? = null

private val isListening: Boolean
get() = notificationObserver != null

init {
UiThreadUtil.runOnUiThread { startListening() }
}

override fun getName(): String = "SCGatewayBridgeEmitter"

override fun onCatalystInstanceDestroy() {
super.onCatalystInstanceDestroy()
if (isListening) {
notificationObserver?.let { observer ->
NotificationCenter.removeObserver(observer)
}
notificationObserver = null
Log.d(TAG, "Successfully cleaned up notification observer")
}
}

@ReactMethod
fun startListening(promise: Promise? = null) {
Log.d(TAG, "startListening called")

if (isListening) {
Log.d(TAG, "Already listening to events")
promise?.resolve("Already listening")
return
}

UiThreadUtil.runOnUiThread {
Log.d(TAG, "Starting listener on thread: ${Thread.currentThread().name}")

notificationObserver = { notification ->
Log.d(TAG, "Received notification: ${notification.name}")
processScgNotification(notification)
}

notificationObserver?.let { observer ->
NotificationCenter.addObserver(observer)
Log.d(TAG, "Successfully started listening for notifications")
promise?.resolve("Started listening successfully")
} ?: run {
promise?.reject("START_LISTENING_ERROR", "Failed to create observer")
}
}
}

@ReactMethod
fun stopListening(promise: Promise) {
if (!isListening) {
promise.resolve("Not listening")
return
}

UiThreadUtil.runOnUiThread {
notificationObserver?.let { observer ->
NotificationCenter.removeObserver(observer)
notificationObserver = null
promise.resolve("Stopped listening successfully")
} ?: run {
promise.resolve("No observer to remove")
}
}
}

private fun processScgNotification(notification: Notification) {
val jsonString = notification.userInfo?.get(ScgNotification.STRINGIFIED_PAYLOAD_KEY) as? String
if (jsonString == null) {
Log.e(TAG, "SCGatewayBridgeEmitter: Invalid notification object - expected JSON string")
return
}

sendEvent(SmallcaseGatewaySdk.SCG_NOTIFICATION_NAME, jsonString)
}

private fun sendEvent(eventName: String, jsonString: String) {
try {
if (reactContext.hasActiveCatalystInstance()) {
reactContext
.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java)
.emit(eventName, jsonString)
} else {
Log.w(TAG, "React context not active, cannot send event: $eventName")
}
} catch (e: Exception) {
Log.e(TAG, "Failed to send event: $eventName", e)
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
// SCLoansBridgeEmitter.kt
package com.reactnativesmallcasegateway

import android.util.Log
import com.facebook.react.bridge.*
import com.facebook.react.bridge.UiThreadUtil
import com.facebook.react.modules.core.DeviceEventManagerModule
import com.smallcase.loans.core.external.ScLoan
import com.smallcase.loans.core.external.ScLoanNotification
import com.smallcase.loans.data.listeners.Notification
import com.smallcase.loans.data.listeners.NotificationCenter

class SCLoansBridgeEmitter(private val reactContext: ReactApplicationContext):
ReactContextBaseJavaModule(reactContext) {

companion object {
const val TAG = "SCLoansBridgeEmitter"
}

private var notificationObserver: ((Notification) -> Unit)? = null

private val isListening: Boolean
get() = notificationObserver != null

init {
UiThreadUtil.runOnUiThread {
startListening()
}
}

override fun getName(): String = "SCLoansBridgeEmitter"

override fun onCatalystInstanceDestroy() {
super.onCatalystInstanceDestroy()
if (isListening) {
notificationObserver?.let { observer ->
NotificationCenter.removeObserver(observer)
}
notificationObserver = null
Log.d(TAG, "Successfully cleaned up notification observer")
}
}

@ReactMethod
fun startListening(promise: Promise ? = null) {
Log.d(TAG, "startListening called")

if (isListening) {
Log.d(TAG, "Already listening to events")
promise?.resolve("Already listening")
return
}

UiThreadUtil.runOnUiThread {
Log.d(TAG, "Starting listener on thread: ${Thread.currentThread().name}")

notificationObserver = { notification ->
Log.d(TAG, "Received notification: ${notification.name}")
processScLoansNotification(notification)
}

notificationObserver?.let { observer ->
NotificationCenter.addObserver(observer)
Log.d(TAG, "Successfully started listening for notifications")
promise?.resolve("Started listening successfully")
} ?: run {
promise?.reject("START_LISTENING_ERROR", "Failed to create observer")
}
}
}

@ReactMethod
fun stopListening(promise: Promise) {
if (!isListening) {
promise.resolve("Not listening")
return
}

UiThreadUtil.runOnUiThread {
notificationObserver?.let { observer ->
NotificationCenter.removeObserver(observer)
notificationObserver = null
promise.resolve("Stopped listening successfully")
} ?: run {
promise.resolve("No observer to remove")
}
}
}

private fun processScLoansNotification(notification: Notification) {
val jsonString =
notification.userInfo?.get(ScLoanNotification.STRINGIFIED_PAYLOAD_KEY) as? String
if (jsonString == null) {
Log.e(
TAG,
"SCLoansBridgeEmitter: Invalid notification object - expected JSON string"
)
return
}

sendEvent(ScLoan.SCLOANS_NOTIFICATION_NAME, jsonString)
}

private fun sendEvent(eventName: String, jsonString: String) {
try {
if (reactContext.hasActiveCatalystInstance()) {
reactContext
.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java)
.emit(eventName, jsonString)
} else {
Log.w(TAG, "React context not active, cannot send event: $eventName")
}
} catch (e: Exception) {
Log.e(TAG, "Failed to send event: $eventName", e)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ 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<InitialisationResponse> {
Expand All @@ -85,7 +84,6 @@ class SmallcaseGatewayModule(reactContext: ReactApplicationContext) : ReactConte

@ReactMethod
fun triggerTransaction(transactionId: String, utmParams: ReadableMap?, brokerList: ReadableArray?, promise: Promise) {
Log.d(TAG, "triggerTransaction: start")

var safeBrokerList = listOf<String>()

Expand Down Expand Up @@ -161,7 +159,6 @@ 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 {
override fun onFailure(errorCode: Int, errorMessage: String) {
Expand Down Expand Up @@ -191,7 +188,6 @@ class SmallcaseGatewayModule(reactContext: ReactApplicationContext) : ReactConte
}
}
}
Log.d(TAG, "launchSmallplugWithBranding: start")

var partnerProps: SmallplugPartnerProps? = SmallplugPartnerProps(headerColor = "#2F363F", backIconColor = "ffffff")

Expand Down Expand Up @@ -224,7 +220,6 @@ class SmallcaseGatewayModule(reactContext: ReactApplicationContext) : ReactConte

@ReactMethod
fun archiveSmallcase(iscid: String, promise: Promise) {
Log.d(TAG, "markSmallcaseArchive: start")

SmallcaseGatewaySdk.markSmallcaseArchived(iscid, object : DataListener<SmallcaseGatewayDataResponse> {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ import com.facebook.react.uimanager.ViewManager

class SmallcaseGatewayPackage : ReactPackage {
override fun createNativeModules(reactContext: ReactApplicationContext): List<NativeModule> {
return listOf(SmallcaseGatewayModule(reactContext))
return listOf(
SmallcaseGatewayModule(reactContext),
SCGatewayBridgeEmitter(reactContext),
SCLoansBridgeEmitter(reactContext)
)
}

override fun createViewManagers(reactContext: ReactApplicationContext): List<ViewManager<*, *>> {
Expand Down
20 changes: 20 additions & 0 deletions ios/SCGatewayBridgeEmitter.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//
// SCGatewayBridgeEmitter.m
// SCGateway
//
// Created by Dhruv Porwal
// Copyright © 2025 smallcase. All rights reserved.
//

#import <React/RCTBridgeModule.h>
#import "SmallcaseGateway-Bridging-Header.h"

@interface RCT_EXTERN_REMAP_MODULE(SCGatewayBridgeEmitter, SCGatewayEmitter, NSObject)

RCT_EXTERN_METHOD(startListening:(RCTPromiseResolveBlock)resolve
rejecter:(RCTPromiseRejectBlock)reject)

RCT_EXTERN_METHOD(stopListening:(RCTPromiseResolveBlock)resolve
rejecter:(RCTPromiseRejectBlock)reject)

@end
Loading