Prerequisites: React Native uses Android and iOS native SDKs to integrate kevin. infrastructure. Before proceeding further, please import SDK dependencies as it is described in the corresponding installation sections.
In order to use kevin. SDK in your React Native application you need to initialize kevin. plugin and set up platform-specific components.
Android
Create a class in Android native project that will hold kevin. SDK integration code.
KevinModule.kt
class KevinModule internal constructor(context: ReactApplicationContext?) :
ReactContextBaseJavaModule(context) {
init {
context?.addActivityEventListener(this)
// Setup your custom theme which extends Theme.Kevin.Base
Kevin.setTheme(R.style.Theme_Kevin_Base)
// Set optional locale, default is phone locale
Kevin.setLocale(Locale("en"))
// Initialize required plugins with your callback urls
KevinAccountsPlugin.configure(
KevinAccountsConfiguration.builder()
.setCallbackUrl("https://your.callback.url")
.build()
)
KevinPaymentsPlugin.configure(
KevinPaymentsConfiguration.builder()
.setCallbackUrl("https://your.callback.url")
.build()
)
}
}
Additionally, for React Native to be able to call Kotlin native code, you will need to create a package registration class for your native code and add it to ReactPackage list in MainApplication.java
KevinPackage.kt
class KevinPackage : ReactPackage {
override fun createViewManagers(reactContext: ReactApplicationContext): List<ViewManager<*, *>> {
return emptyList()
}
override fun createNativeModules(
reactContext: ReactApplicationContext
): List<NativeModule> {
val modules: MutableList<NativeModule> = java.util.ArrayList<NativeModule>()
modules.add(KevinModule(reactContext))
return modules
}
}