Skip to content

Commit

Permalink
Onfido supports langauge from javascript thread
Browse files Browse the repository at this point in the history
  • Loading branch information
lucaspelloni2 committed Mar 18, 2021
1 parent 1af6069 commit ee13652
Showing 1 changed file with 23 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ public String getName() {
return "OnfidoSdk";
}

/** NOTE: This indirection is used to allow unit tests to mock this method */
/**
* NOTE: This indirection is used to allow unit tests to mock this method
*/
protected Activity getCurrentActivityInParentClass() {
return super.getCurrentActivity();
}
Expand Down Expand Up @@ -86,20 +88,27 @@ public void start(final ReadableMap config, final Promise promise) {
return;
}

try {
final OnfidoConfig onfidoConfig = OnfidoConfig.builder(currentActivity)
.withSDKToken(sdkToken)
.withCustomFlow(flowStepsWithOptions)
.withLocale(Locale.GERMAN)
.build();
client.startActivityForResult(currentActivity, 1, onfidoConfig);
}
catch (final Exception e) {
currentPromise.reject("error", new Exception("Failed to show Onfido page", e));
currentPromise = null;
return;
Locale locale = Locale.ENGLISH; // default language
String language = config.getString("language"); // from js thread
if (language.equals("ger")) {
locale = Locale.GERMAN;
} else if (language.equals("ita")) {
locale = Locale.ITALIAN;
}

try {
final OnfidoConfig onfidoConfig = OnfidoConfig.builder(currentActivity)
.withSDKToken(sdkToken)
.withCustomFlow(flowStepsWithOptions)
.withLocale(locale)
.build();
client.startActivityForResult(currentActivity, 1, onfidoConfig);
} catch (final Exception e) {
currentPromise.reject("error", new Exception("Failed to show Onfido page", e));
currentPromise = null;
return;
}

} catch (final Exception e) {
e.printStackTrace();
// Wrap all unexpected exceptions.
Expand Down Expand Up @@ -166,7 +175,7 @@ public static FlowStep[] getFlowStepsFromConfig(final ReadableMap config) throws
String countryCodeString = captureDocument.getString("countryCode");
CountryCode countryCodeEnum = findCountryCodeByAlpha3(countryCodeString);

if (countryCodeEnum ==null) {
if (countryCodeEnum == null) {
System.err.println("Unexpected countryCode value: [" + countryCodeString + "]");
throw new Exception("Unexpected countryCode value.");
}
Expand Down

0 comments on commit ee13652

Please sign in to comment.