Skip to content

Commit

Permalink
fixing android integration issues
Browse files Browse the repository at this point in the history
  • Loading branch information
shachartransmit committed Jun 11, 2024
1 parent 1353d61 commit 201c519
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 5 deletions.
17 changes: 16 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,19 @@ repositories {
maven {
url('https://transmit.jfrog.io/artifactory/transmit-security-gradle-release-local/')
}
}
}


Initialize using strings.xml configuration:
To do this, update the strings.xml file in your Application with the following content. The CLIENT_ID should be replaced with your client ID

<resources>
<!-- Transmit Security Credentials -->
<string name="transmit_security_app_id">"default_application"</string>
<string name="transmit_security_client_id">"CLIENT_ID"</string>
<string name="transmit_security_base_url">https://api.transmitsecurity.io/</string>
</resources>

Call the dedicated Android function to initialize the SDK. Open your MainApplication.kt file and add the following to the bottom of the function onCreate()
TsIdentityOrchestrationModule.initializeAndroidSDK(this)

Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.tsidentityorchestration

import android.content.Context
import com.facebook.react.bridge.Arguments
import com.facebook.react.bridge.Promise
import com.facebook.react.bridge.ReactApplicationContext
Expand Down Expand Up @@ -30,8 +31,10 @@ class TsIdentityOrchestrationModule(private val reactContext: ReactApplicationCo

@ReactMethod
fun initializeSDK(promise: Promise) {
TSIdo.initializeSDK(reactContext)
promise.resolve(true)
promise.reject(
"TSIDOModule",
"On Android, please call the initializeAndroidSDK function from your Application class"
)
}

@ReactMethod
Expand Down Expand Up @@ -213,5 +216,9 @@ class TsIdentityOrchestrationModule(private val reactContext: ReactApplicationCo

companion object {
const val NAME = "TsIdentityOrchestration"

fun initializeAndroidSDK(context: Context) {
TSIdo.initializeSDK(context)
}
}
}
3 changes: 2 additions & 1 deletion example/android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<manifest xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools">

<uses-permission android:name="android.permission.INTERNET" />

<application
tools:replace="android:allowBackup"
android:name=".MainApplication"
android:label="@string/app_name"
android:icon="@mipmap/ic_launcher"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class MainActivity : ReactActivity() {
* rendering of the component.
*/
override fun getMainComponentName(): String = "TsIdentityOrchestrationExample"

/**
* Returns the instance of the [ReactActivityDelegate]. We use [DefaultReactActivityDelegate]
* which allows you to enable New Architecture with a single boolean flags [fabricEnabled]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint.load
import com.facebook.react.defaults.DefaultReactHost.getDefaultReactHost
import com.facebook.react.defaults.DefaultReactNativeHost
import com.facebook.soloader.SoLoader
import com.tsidentityorchestration.TsIdentityOrchestrationModule

class MainApplication : Application(), ReactApplication {

Expand Down Expand Up @@ -39,5 +40,7 @@ class MainApplication : Application(), ReactApplication {
// If you opted-in for the New Architecture, we load the native entry point for this app.
load()
}

TsIdentityOrchestrationModule.initializeAndroidSDK(this)
}
}
3 changes: 3 additions & 0 deletions example/android/app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
<resources>
<string name="app_name">TsIdentityOrchestrationExample</string>
<string name="transmit_security_app_id">"default_application"</string>
<string name="transmit_security_client_id">"CLIENT_ID"</string>
<string name="transmit_security_base_url">https://api.transmitsecurity.io/</string>
</resources>

0 comments on commit 201c519

Please sign in to comment.