Skip to content

Commit ab5f830

Browse files
authored
Merge pull request #3 from getyoti/ED-545
[ED-545] Forcing Yoti app to be opened when Yoti SDK button is pressed.
2 parents 1421c48 + e010ae4 commit ab5f830

File tree

4 files changed

+17
-5
lines changed

4 files changed

+17
-5
lines changed

sample-app/src/main/java/com/yoti/mobile/android/sdk/sampleapp/MainActivity.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ public void onStartScenarioError(YotiSDKException cause) {
4444
@Override
4545
public void onYotiAppNotInstalledError(YotiSDKNoYotiAppException cause) {
4646
//The Yoti app is not installed, let's deal with it
47+
yotiSDKButton.setVisibility(View.VISIBLE);
48+
progress.setVisibility(View.GONE);
49+
message.setText(R.string.loc_no_yoti_app_error);
4750
}
4851
});
4952

sample-app/src/main/res/values/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
<string name="share_my_phone">Share my phone</string>
55

66
<string name="loc_error_unknow">Something went wrong :(</string>
7+
<string name="loc_no_yoti_app_error">The Yoti app is not install in this device</string>
78
<string name="loc_error_not_completed_on_yoti">Process not completed on the Yoti App</string>
89
<string name="loc_phone_number">Your phone number is : %s</string>
910
</resources>

yoti-sdk/src/main/java/com/yoti/mobile/android/sdk/YotiSDKButton.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,12 +104,10 @@ public void onClick(View v) {
104104

105105
YotiSDKLogger.error(cause.getMessage(), cause);
106106

107-
if (mOnYotiButtonClickListener != null) {
108-
mOnYotiButtonClickListener.onStartScenarioError(cause);
109-
}
110-
111107
if (mOnYotiAppNotInstalledListener != null && cause instanceof YotiSDKNoYotiAppException) {
112108
mOnYotiAppNotInstalledListener.onYotiAppNotInstalledError((YotiSDKNoYotiAppException) cause);
109+
} else if (mOnYotiButtonClickListener != null) {
110+
mOnYotiButtonClickListener.onStartScenarioError(cause);
113111
}
114112
}
115113
}

yoti-sdk/src/main/java/com/yoti/mobile/android/sdk/kernelSDK/KernelSDKIntentService.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import java.security.NoSuchAlgorithmException;
1919
import java.security.cert.CertificateException;
2020

21+
import static com.yoti.mobile.android.sdk.YotiAppDefs.YOTI_APP_PACKAGE;
2122
import static com.yoti.mobile.android.sdk.YotiSDKDefs.APP_ID_PARAM;
2223
import static com.yoti.mobile.android.sdk.YotiSDKDefs.APP_NAME_PARAM;
2324
import static com.yoti.mobile.android.sdk.YotiSDKDefs.CALLBACK_PARAM;
@@ -129,7 +130,16 @@ private void handleActionStartScenario(String useCaseId, ResultReceiver resultRe
129130

130131
resultReceiver.send(0, null);
131132

132-
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
133+
Intent intent;
134+
intent = getPackageManager().getLaunchIntentForPackage(YOTI_APP_PACKAGE);
135+
136+
if (intent == null) {
137+
// Yoti app is not installed, let's open the website
138+
intent = new Intent(Intent.ACTION_VIEW, uri);
139+
} else {
140+
intent.setData(uri);
141+
}
142+
133143
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
134144
startActivity(intent);
135145
}

0 commit comments

Comments
 (0)