Skip to content

Commit d223b2f

Browse files
authored
Update README.md with Kotlin examples (#23)
1 parent dac6561 commit d223b2f

File tree

1 file changed

+34
-4
lines changed

1 file changed

+34
-4
lines changed

README.md

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,47 +109,77 @@ Version 5.0.0 of the TruValidate Device Risk SDK for Android supports Android 5.
109109
To integrate into native apps:
110110
111111
1. In your Application class, import the `FraudForceManager` and `FraudForceConfiguration` objects.
112-
112+
113+
Java
113114
```
114115
import com.iovation.mobile.android.FraudForceConfiguration;
115116
import com.iovation.mobile.android.FraudForceManager;
116117
```
118+
Kotlin
119+
```
120+
import com.iovation.mobile.android.FraudForceConfiguration
121+
import com.iovation.mobile.android.FraudForceManager
122+
```
123+
117124
118125
2. Create a configuration object with your subscriber key, and enable or disable network calls to TransUnion servers. Entering the subscriber key is strongly recommended for all integrations, and it is required for network connections.
119126
120127
> __NOTE__ Please review the Network Calls section of this document before enabling network calls.
121128
122129
> __IMPORTANT__ Please contact your TransUnion customer success team representative to receive your subscriber key.
123-
130+
131+
Java
124132
```
125133
FraudForceConfiguration configuration = new FraudForceConfiguration.Builder()
126134
.subscriberKey([YOUR-SUBSCRIBER-KEY-HERE])
127135
.enableNetworkCalls(true) // Defaults to false if left out of configuration
128136
.build();
129137
```
138+
Kotlin
139+
```
140+
val configuration = FraudForceConfiguration.Builder()
141+
.subscriberKey([YOUR-SUBSCRIBER-KEY-HERE])
142+
.enableNetworkCalls(true)
143+
.build()
144+
```
130145
131146
3. Initialize the FraudForceManager class using the generated FraudForceConfiguration object, and the application context.
132147
148+
Java
133149
```
134150
FraudForceManager fraudForceManager = FraudForceManager.INSTANCE;
135151
fraudForceManager.initialize(configuration, context);
136152
```
153+
Kotlin
154+
```
155+
FraudForceManager.initialize(configuration, applicationContext)
156+
```
137157
138158
4. Call the `refresh()` method in the same Activity/Fragment/ViewModel where `getBlackbox()` will be called. The integrating application only needs to call this method on the Fragments where the `getBlackbox()` method will be called.
139159
140160
> __NOTE__: This method calls updates the geolocation and network information, if enabled.
141161
142162
> __NOTE__: As with initialization, pass the application context when refreshing.
143-
163+
164+
Java
144165
```
145166
FraudForceManager.INSTANCE.refresh(context);
146167
```
168+
Kotlin
169+
```
170+
FraudForceManager.refresh(applicationContext)
171+
```
147172
148173
5. To generate the blackbox, call the getBlackbox(Context context) function on an instance of FraudForceManager. This method is a **blocking** call so it is **recommended** to call it on a background thread/coroutine.
149174
175+
Java
150176
```
151177
String blackbox = FraudForceManager.INSTANCE.getBlackbox(context);
152178
```
179+
Kotlin
180+
```
181+
val blackbox : String = FraudForceManager.getBlackbox(applicationContext)
182+
```
153183
154184
## Integrating into Hybrid Apps
155185
@@ -249,7 +279,7 @@ The SDK includes the ability to make a network call to TransUnion TruValidate's
249279
250280
2. From the directory where you unzipped fraudforce-lib-release-5.0.0.zip or cloned the repo, open the **android-studio-sample-app** directory.
251281
252-
3. In the project navigation view, open `src/main/java/com/iovation/mobile/android/sample/MainActivity.java`
282+
3. In the project navigation view, open `app/src/main/java/com/iovation/mobile/android/sample/MainActivity.java` to run the Java sample app. To run the Kotlin sample app, open `kotlinApp/src/main/java/com/iovation/mobile/android/sample/MainActivity.kt`.
253283
254284
4. Right-click the file editing view and select _Run Main Activity_.
255285

0 commit comments

Comments
 (0)