Skip to content

Commit 6e55ad5

Browse files
author
Ravi Chandrasekaran
committed
Merge branch 'CON-6105' into 'main'
Connect Android SDK 3.0.0 See merge request connect/android-sdk-legacy!38
2 parents 9e0ef47 + db3b422 commit 6e55ad5

File tree

15 files changed

+210
-174
lines changed

15 files changed

+210
-174
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# Changelog
22

3+
### 3.0.0 (August 10, 2023)
4+
5+
Enhancement:
6+
- Enhanced App To App OAuth Flow with newly added redirectUrl parameter inside Connect Android SDK to support App link and deeplink for navigation between mobile apps. For details on App To App refer [documentation here](https://developer.mastercard.com/open-banking-us/documentation/connect/mobile-sdks/)
7+
8+
Breaking changes:
9+
- Connect Android SDK support for deepLinkUrl is deprecated from this version, Please use the redirectUrl parameter instead, it will support both App link and deeplink. Please follow the readme documentation for [more details](https://github.com/Mastercard/connect-android-sdk#readme)
10+
311
### 2.3.0 (June 22, 2023)
412

513
Enhancement:

README.md

Lines changed: 90 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -9,28 +9,45 @@ The Connect mobile SDKs allow you to embed the Connect user experience anywhere
99

1010
The Connect Android SDK supports the following Android versions.
1111

12-
* Android 5.0 (Lollipop) or later
12+
* Android 5.0 (Lollipop) or later & minSdkVersion 21 or later
1313

14-
* minSdkVersion 21 or later
15-
16-
* Android Gradle Plugin v3.4.0 or greater required
17-
18-
* Gradle 5.1.1 or greater required
14+
WARNING:Support for deepLinkUrl parameters is deprecated from Connect Android SDK version 3.0.0, going forward please use the redirectUrl parameter which supports both universal and deep links. For more information see [Github documentation](https://github.com/Mastercard/connect-android-sdk/blob/main/README.md)
1915

2016

2117
## Step 1 - Add repository to your project
2218

2319
## Maven-central
2420

25-
Add the following code to the dependency section in the build.gradle file.
21+
Please modify your root-level Gradle file(build.gradle) as per below code.
2622

2723
```
28-
implementation 'com.mastercard.openbanking.connect:connect-sdk:<insert latest version>'
24+
allprojects {
25+
repositories {
26+
google()
27+
mavenCentral()
28+
}
29+
}
30+
```
31+
32+
Please modify your app-level Gradle file(build.gradle) as per below code.
33+
2934
```
35+
android {
36+
defaultConfig {
37+
minSdkVersion 21 // or greater
38+
}
39+
}
40+
dependencies {
41+
// ...
42+
implementation 'com.mastercard.openbanking.connect:connect-sdk:<insert latest version>'
43+
}
44+
```
45+
46+
Note: The latest version of the Connect Android SDK can be found in [Maven Central](https://central.sonatype.com/artifact/com.mastercard.openbanking.connect/connect-sdk/2.3.0/versions).
3047

3148
## Manual
3249

33-
* Clone the project: connect-sdk
50+
* Clone the Connect Android SDK project from [Github](https://github.com/Mastercard/connect-android-sdk)
3451

3552
* On your Android project click on File > New > Import Module > Select the path of connect sdk folder location > Finish
3653

@@ -42,71 +59,52 @@ apply from: "${rootProject.projectDir}/sonatype-publish.gradle"
4259
```
4360
* Clean and build the project
4461

45-
## Step 2 - For projects using AndroidX:
62+
## Step 2 - Update Android application settings
4663

47-
Open the gradle.properties file and set **android.enableJetifier** to **true.**
48-
49-
50-
## Step 3 - Update Android application settings
51-
52-
Add internet permissions to your AndroidManifest.xml file.
64+
The Connect Android SDK requires internet access to connect with our servers. As such, you need to add internet permissions to the AndroidManifest.xml file.
5365

5466
```
5567
<uses-permission android:name="android.permission.INTERNET">
5668
```
57-
Add activity in AndroidManifest.xml file.
58-
```
59-
<activity android:name="com.mastercard.openbanking.connect.Connect"
60-
android:launchMode="singleTask"
61-
android:exported="true">
62-
<intent-filter>
63-
<action android:name="android.intent.action.VIEW" />
64-
<category android:name="android.intent.category.DEFAULT" />
65-
<category android:name="android.intent.category.BROWSABLE" />
66-
<data android:scheme="{deep_link_app_name}"/>
67-
</intent-filter>
68-
</activity>
69-
```
70-
{deep_link_app_name} is case sensitive and should only use lower-case character
7169

70+
## Step 3 - Add code to start the Connect Android SDK
7271

73-
## Step 4 - Add code to start the Connect SDK
72+
## Connect Class
7473

7574
The Connect class contains a start method that when called, starts an activity with the supplied event handler. The SDK only allows a single instance of the Connect activity to run. If you start Connect while a Connect activity is already running, a RuntimeException is thrown.
7675

77-
```Connect.start(this, url, "{deep_link_app_name}://", eventHandler);```
76+
The Connect Android SDK’s main component is the Connect class that contains a static start method, which runs an activity that connects with the EventHandler. To access the APIs in the SDK include the following imports:
7877

79-
80-
### Connect Class
81-
82-
The Connect Android SDK’s main component is the Connect class that contains a static start method, which runs an activity that connects with the EventHandler.
78+
```
79+
import com.mastercard.openbanking.connect.Connect;
80+
import com.mastercard.openbanking.connect.EventHandler;
81+
```
8382

8483
```
8584
Java
86-
public static void start(Context context, String connectUrl, String deepLinkUrl, EventHandler eventHandler)
85+
public static void start(Context context, String connectUrl, String redirectUrl, EventHandler eventHandler)
8786
```
8887

8988
```
9089
Kotlin
91-
fun start(context: Context, connectUrl: String?, deepLinkUrl: String?, eventHandler: EventHandler?)
90+
fun start(context: Context, connectUrl: String?, redirectUrl: String?, eventHandler: EventHandler?)
9291
```
9392

94-
| Argument | Description |
93+
| Parameter | Description |
9594
| ------ | ------ |
9695
| context | The Android Context is referenced by Connect when an activity starts. |
9796
| connectUrl | The SDK loads the Connect URL. |
98-
| deepLinkUrl | The DeepLink url to redirect back to app. |
97+
| redirectUrl | App link URL/ Deep link URL to redirect back to your mobile app after completing FI’s OAuth flow. This parameter is only required for App to App. |
9998
| eventHandler | A class implementing the EventHandler interface. |
10099

101100
See [Generate 2.0 Connect URL APIs](https://developer.mastercard.com/open-banking-us/documentation/connect/generate-2-connect-url-apis/)
102101

103102

104-
105103
## EventHandler Interface
106104

107105
Throughout Connect’s flow, events about the state of the web application are sent as JSONObjects to the EventHandler methods.
108106

109-
> **_NOTE:_** The onUserEvent handler will not return anything unless you’re specifically targeting Connect 2.0.
107+
> **_NOTE:_** The onUser event handler will not return anything unless you’re specifically targeting Connect.
110108
111109
```
112110
Java
@@ -141,6 +139,55 @@ Event | Description |
141139
| onRoute | Sent when the user navigates to a new route or screen in Connect |
142140
| onUser | Called when a user performs an action. User events provide visibility into what action a user could take within the Connect application |
143141

142+
## App To App
143+
144+
## App Link Support
145+
146+
Add activity in AndroidManifest.xml file.
147+
148+
```
149+
<activity android:name="com.mastercard.openbanking.connect.Connect"
150+
android:launchMode="singleTask"
151+
android:exported="true">
152+
<intent-filter>
153+
<action android:name="android.intent.action.VIEW" />
154+
<category android:name="android.intent.category.DEFAULT" />
155+
<category android:name="android.intent.category.BROWSABLE" />
156+
<data
157+
android:scheme="https"
158+
android:host="{{yourdomain.com}}"/>
159+
</intent-filter>
160+
</activity>
161+
```
162+
163+
## Deep Link Support(Not recommended)
164+
165+
Add activity in AndroidManifest.xml file.
166+
167+
```
168+
<activity android:name="com.mastercard.openbanking.connect.Connect"
169+
android:launchMode="singleTask"
170+
android:exported="true">
171+
<intent-filter>
172+
<action android:name="android.intent.action.VIEW" />
173+
<category android:name="android.intent.category.DEFAULT" />
174+
<category android:name="android.intent.category.BROWSABLE" />
175+
<data android:scheme="{deep_link_app_name}"/>
176+
</intent-filter>
177+
</activity>
178+
```
179+
{deep_link_app_name} is case sensitive and should only use lower-case character
180+
181+
## Add code to start the Connect Android SDK
182+
183+
## App Link Support
184+
185+
```Connect.start(this, url, "https://yourdomain.com/connect", eventHandler);```
186+
187+
## Deep Link Support
188+
189+
```Connect.start(this, url, "{deep_link_app_name}://", eventHandler);```
190+
144191

145192
## Manually stop a connect activity
146193

@@ -152,7 +199,5 @@ You can manually finish a Connect activity by invoking:
152199
Connect.finishCurrentActivity()
153200
```
154201

202+
If there isn’t a current Connect activity running, then the method will throw a RuntimeException.
155203

156-
## Process Restarts
157-
158-
Android sometimes stops your application’s process and restarts it when your application is re-focused. If this happens, the Connect activity automatically finishes when the application resumes. If you want Connect to run again, call the start method. See [Connect Class.](#connect-class)

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.3.0"
63+
versionName "3.0.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.3.0'
119+
PUBLISH_VERSION = '3.0.0'
120120
PUBLISH_ARTIFACT_ID = 'connect-sdk'
121121
}
122122

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

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public class ConnectActivityTest {
4646
private static String goodUrl = "";
4747
private static final String badExpiredUrl = "https://connect2.finicity.com?consumerId=dbceec20d8b97174e6aed204856f5a55&customerId=1016927519&partnerId=2445582695152&signature=abb1762e5c640f02823c56332daede3fe2f2143f4f5b8be6ec178ac72d7dbc5a&timestamp=1607806595887&ttl=1607813795887";
4848
private WebEventIdlingResource mIdlingResource;
49-
private static String deepLinkUrl = "";
49+
private static String redirectUrl = "";
5050

5151
@Before
5252
public void setup() {
@@ -66,7 +66,7 @@ public void teardown() {
6666

6767
@Test
6868
public void test01ConnectWithExpiredUrl() {
69-
Connect.start(InstrumentationRegistry.getContext(), badExpiredUrl, deepLinkUrl, new TestEventHandler());
69+
Connect.start(InstrumentationRegistry.getContext(), badExpiredUrl, redirectUrl, new TestEventHandler());
7070

7171
mIdlingResource.waitForEvent("error");
7272
onWebView().withElement(findElement(Locator.LINK_TEXT, "Exit")).perform(webClick());
@@ -92,7 +92,7 @@ public void test02ConnectWithGoodUrlThenCancel() throws InterruptedException {
9292
public void test03ConnectWithGoodUrlThenBackButton() {
9393

9494
String url = goodUrl.replace("localhost:", "10.0.2.2:");
95-
Connect.start(InstrumentationRegistry.getContext(), url, deepLinkUrl, new TestEventHandler());
95+
Connect.start(InstrumentationRegistry.getContext(), url, redirectUrl, new TestEventHandler());
9696

9797
// Wait for Route search or let it timeout
9898
mIdlingResource.waitForEvent("search");
@@ -115,7 +115,7 @@ public void test03ConnectWithGoodUrlThenBackButton() {
115115
public void test04ConnectWithGoodUrlThenBackButtonAndCancel() {
116116

117117
String url = goodUrl.replace("localhost:", "10.0.2.2:");
118-
Connect.start(InstrumentationRegistry.getContext(), url, deepLinkUrl, new TestEventHandler());
118+
Connect.start(InstrumentationRegistry.getContext(), url, redirectUrl, new TestEventHandler());
119119

120120
// Wait for Route search or let it timeout
121121
mIdlingResource.waitForEvent("search");
@@ -129,7 +129,7 @@ public void test04ConnectWithGoodUrlThenBackButtonAndCancel() {
129129
public void test05ConnectWithGoodUrlThenPrivacyPolicy() throws InterruptedException {
130130

131131
String url = goodUrl.replace("localhost:", "10.0.2.2:");
132-
Connect.start(InstrumentationRegistry.getContext(), url, deepLinkUrl, new TestEventHandler());
132+
Connect.start(InstrumentationRegistry.getContext(), url, redirectUrl, new TestEventHandler());
133133

134134
// Wait for Route search or let it timeout
135135
mIdlingResource.waitForEvent("search");
@@ -156,7 +156,7 @@ public void test05ConnectWithGoodUrlThenPrivacyPolicy() throws InterruptedExcept
156156
public void test06ConnectWithGoodUrlThenAddBankAccount() throws InterruptedException {
157157

158158
String url = goodUrl.replace("localhost:", "10.0.2.2:");
159-
Connect.start(InstrumentationRegistry.getContext(), url, deepLinkUrl, new TestEventHandler());
159+
Connect.start(InstrumentationRegistry.getContext(), url, redirectUrl, new TestEventHandler());
160160

161161
// Wait for Route search or let it timeout
162162
mIdlingResource.waitForEvent("search");
@@ -204,7 +204,7 @@ public void test06ConnectWithGoodUrlThenAddBankAccount() throws InterruptedExcep
204204

205205
@Test
206206
public void test07ConnectWithExpiredUrlThenFinishActivity() throws InterruptedException {
207-
Connect.start(InstrumentationRegistry.getContext(), badExpiredUrl, deepLinkUrl, new TestEventHandler());
207+
Connect.start(InstrumentationRegistry.getContext(), badExpiredUrl, redirectUrl, new TestEventHandler());
208208
Thread.sleep(10000);
209209
Connect.finishCurrentActivity();
210210
}
@@ -222,12 +222,12 @@ public void test08FinishActivity() {
222222

223223
@Test
224224
public void test09AlreadyRunning() throws InterruptedException {
225-
Connect.start(InstrumentationRegistry.getContext(), badExpiredUrl, deepLinkUrl, new TestEventHandler());
225+
Connect.start(InstrumentationRegistry.getContext(), badExpiredUrl, redirectUrl, new TestEventHandler());
226226
Thread.sleep(5000);
227227

228228
// Try and start a 2nd Activity
229229
try {
230-
Connect.start(InstrumentationRegistry.getContext(), badExpiredUrl, deepLinkUrl, new TestEventHandler());
230+
Connect.start(InstrumentationRegistry.getContext(), badExpiredUrl, redirectUrl, new TestEventHandler());
231231
fail("Should have thrown runtime exception");
232232
} catch(RuntimeException e) {
233233
//success
@@ -236,7 +236,7 @@ public void test09AlreadyRunning() throws InterruptedException {
236236

237237
@Test
238238
public void test10NullEventHandler() throws InterruptedException {
239-
Connect.start(InstrumentationRegistry.getContext(), badExpiredUrl, deepLinkUrl,null);
239+
Connect.start(InstrumentationRegistry.getContext(), badExpiredUrl, redirectUrl,null);
240240
Thread.sleep(5000);
241241
}
242242

0 commit comments

Comments
 (0)