Skip to content

Commit 9e0ef47

Browse files
author
Bruce McFadden
committed
Merge branch 'CON-OptionalDeeplink' into 'main'
[CON-6080]Added optional deeplinkUrl param to support navigation back to app See merge request connect/android-sdk-legacy!37
2 parents 966759d + 2588ec6 commit 9e0ef47

File tree

5 files changed

+50
-13
lines changed

5 files changed

+50
-13
lines changed

CHANGELOG.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# Changelog
22

3-
### 2.2.0 (June 13, 2023)
3+
### 2.3.0 (June 22, 2023)
44

5-
Breaking Change:
6-
- Added deeplink support to navigate it back to app (App to App Authentication).
5+
Enhancement:
6+
- Added optional deeplinkUrl param to support navigation back to app (App to App Authentication).
77

88
### 2.1.0 (June 3, 2023)
99

README.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,12 @@ The Connect Android SDK supports the following Android versions.
2020

2121
## Step 1 - Add repository to your project
2222

23-
## Gradle
23+
## Maven-central
2424

25-
Add the following code to the dependency section in the build.gradle file. To install a specific version, replace “+” with the preferred version number:
25+
Add the following code to the dependency section in the build.gradle file.
2626

2727
```
28-
dependencies {
29-
implementation 'com.mastercard.openbanking.connect:connect-sdk:+'
30-
}
28+
implementation 'com.mastercard.openbanking.connect:connect-sdk:<insert latest version>'
3129
```
3230

3331
## Manual

connect-sdk/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ android {
6060
minSdkVersion 21
6161
targetSdkVersion 30
6262
versionCode 105
63-
versionName "2.2.0"
63+
versionName "2.3.0"
6464

6565
if (!properties.isEmpty()) {
6666
resValue "string", "partnerId", properties.getProperty("PARTNER_ID", "")
@@ -116,7 +116,7 @@ dependencies {
116116

117117
ext {
118118
PUBLISH_GROUP_ID = 'com.mastercard.openbanking.connect'
119-
PUBLISH_VERSION = '2.2.0'
119+
PUBLISH_VERSION = '2.3.0'
120120
PUBLISH_ARTIFACT_ID = 'connect-sdk'
121121
}
122122

connect-sdk/src/androidTest/java/com/mastercard/openbanking/connect/ConnectActivityTest.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,21 @@ public void test10NullEventHandler() throws InterruptedException {
240240
Thread.sleep(5000);
241241
}
242242

243+
@Test
244+
public void test11ConnectWithGoodUrlWithoutDeeplink() throws InterruptedException {
245+
246+
String url = goodUrl.replace("localhost:", "10.0.2.2:");
247+
Connect.start(InstrumentationRegistry.getContext(), url, new TestEventHandler());
248+
249+
mIdlingResource.waitForEvent("search");
250+
onWebView().withElement(findElement(Locator.CLASS_NAME, "icon-nav_exit_button")).perform(webClick());
251+
252+
Thread.sleep(1000);
253+
254+
onWebView().withElement(findElement(Locator.LINK_TEXT, "Exit")).perform(webClick());
255+
256+
}
257+
243258
private void generateConnectUrl() {
244259
if (goodUrl.isEmpty()) {
245260
// Use countdown latch to wait for chain of Finicity API's Auth, Customer, Consumer, Generate to complete asynchronously.
@@ -270,6 +285,7 @@ public void onSuccess(String link) {
270285

271286
}
272287

288+
273289
public class TestEventHandler implements EventHandler {
274290
private static final String TAG = "TestEventHandler";
275291

connect-sdk/src/main/java/com/mastercard/openbanking/connect/Connect.java

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
import java.util.TimerTask;
2323

2424
public class Connect extends Activity {
25-
private static final String SDK_VERSION = "2.2.0";
25+
private static final String SDK_VERSION = "2.3.0";
2626

2727
private static final String ALREADY_RUNNING_ERROR_MSG = "There is already another Connect Activity running. " +
2828
"Only 1 is allowed at a time. Please allow the current activity to finish " +
@@ -38,6 +38,24 @@ public class Connect extends Activity {
3838
private static ConnectJsInterface jsInterface;
3939
public static Boolean runningUnitTest = false;
4040

41+
public static void start(Context context, String connectUrl, EventHandler eventHandler) {
42+
if (Connect.CONNECT_INSTANCE != null) {
43+
throw new RuntimeException(ALREADY_RUNNING_ERROR_MSG);
44+
}
45+
46+
Intent connectIntent = new Intent(context, Connect.class);
47+
if (runningUnitTest) {
48+
connectIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
49+
}
50+
connectIntent.putExtra(Connect.CONNECT_URL_INTENT_KEY, connectUrl);
51+
52+
// Set EventListener
53+
Connect.EVENT_HANDLER = eventHandler;
54+
55+
context.startActivity(connectIntent);
56+
}
57+
58+
4159
public static void start(Context context, String connectUrl, String deepLinkUrl, EventHandler eventHandler) {
4260
if (Connect.CONNECT_INSTANCE != null) {
4361
throw new RuntimeException(ALREADY_RUNNING_ERROR_MSG);
@@ -268,8 +286,13 @@ protected void stopPingTimer() {
268286

269287
protected void pingConnect() {
270288
String deepLinkUrl = getIntent().getStringExtra(CONNECT_DEEPLINK_URL_INTENT_KEY);
271-
String javascript = "window.postMessage({ type: 'ping', sdkVersion: '" + SDK_VERSION + "', platform: 'Android',deepLinkUrl: '" + deepLinkUrl + "' }, '*')";
272-
if (mMainWebView != null) {
289+
String javascript;
290+
if(deepLinkUrl != null){
291+
javascript = "window.postMessage({ type: 'ping', sdkVersion: '" + SDK_VERSION + "', platform: 'Android',deepLinkUrl: '" + deepLinkUrl + "' }, '*')";
292+
}else{
293+
javascript = "window.postMessage({ type: 'ping', sdkVersion: '" + SDK_VERSION + "', platform: 'Android' }, '*')";
294+
}
295+
if (mMainWebView != null) {
273296
mMainWebView.evaluateJavascript(javascript, null);
274297
}
275298
}

0 commit comments

Comments
 (0)