Skip to content

Commit 05364d3

Browse files
authored
Merge pull request #278 from proyecto26/develop
Release 3.6.1
2 parents 623f34a + b6a193b commit 05364d3

File tree

10 files changed

+78
-40
lines changed

10 files changed

+78
-40
lines changed

.github/pull_request_template.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ To help the rest of the community review your change, please follow the instruct
99

1010
## PR Checklist
1111

12-
- [ ] The PR title follows our guidelines: https://github.com/proyecto26/react-native-inappbrowser/blob/master/CONTRIBUTING.md#pull-request-process.
12+
- [ ] The PR title follows our guidelines: https://github.com/proyecto26/react-native-inappbrowser/blob/main/CONTRIBUTING.md#pull-request-process.
1313
- [ ] There is an issue for the bug/feature this PR is for. To avoid wasting your time, it's best to open a suggestion issue first and wait for approval before working on it.
1414
- [ ] All existing tests are passing
1515
- [ ] Tests for the changes are included

CHANGELOG.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,15 @@ in case of vulnerabilities.
2222

2323
## [Unreleased]
2424

25+
## [3.6.1] - 2021-06-27
26+
27+
### Added
28+
- Add try catch block to `CustomTabs` logic to validate the url.
29+
2530
## [3.6.0] - 2021-06-25
2631

2732
### Added
28-
- Add `navigationBarColor` and `navigationBarDividerColor` by [@jdnichollsc](https://github.com/jdnichollsc).
33+
- Add `navigationBarColor` and `navigationBarDividerColor` options by [@jdnichollsc](https://github.com/jdnichollsc).
2934
- Add try catch block to `Safari View Controller` logic by [@Opstrup](https://github.com/Opstrup) ([#216](https://github.com/proyecto26/react-native-inappbrowser/pull/216)).
3035

3136
### Fixed
@@ -187,7 +192,8 @@ Missing tags for previous versions 🤷‍♂
187192
- Fix `EventBusException` on **Android** by [@Almouro](https://github.com/Almouro) ([9cf4cbb](https://github.com/proyecto26/react-native-inappbrowser/commit/9cf4cbb58d55c8b534dabac6791e6a2a5428253f)).
188193

189194

190-
[Unreleased]: https://github.com/proyecto26/react-native-inappbrowser/compare/v3.6.0...HEAD
195+
[Unreleased]: https://github.com/proyecto26/react-native-inappbrowser/compare/v3.6.1...HEAD
196+
[3.6.1]: https://github.com/proyecto26/react-native-inappbrowser/compare/v3.6.0...v3.6.1
191197
[3.6.0]: https://github.com/proyecto26/react-native-inappbrowser/compare/v3.5.1...v3.6.0
192198
[3.5.1]: https://github.com/proyecto26/react-native-inappbrowser/compare/v3.5.0...v3.5.1
193199
[3.5.0]: https://github.com/proyecto26/react-native-inappbrowser/compare/v3.4.0...v3.5.0

README.md

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,17 @@
3333
<img width="400px" src="https://github.com/proyecto26/react-native-inappbrowser/blob/main/img/inappbrowser.png?raw=true">
3434
</p>
3535

36-
## Demo
36+
## Who is using InAppBrowser?
3737

3838
Do you want to see this package in action? Check these awesome projects, yay! 🎉
3939
- [MyApp](https://github.com/proyecto26/MyApp) - A template to create awesome Apps easily ⚡️
4040
- [OLIO](https://olioex.com) - Share more. Waste less.
4141
- [Alpe Audio](https://www.alpeaudio.com) - Courses On The Go.
42+
- [VibePay](https://vibepay.com) - A simple, smarter, better way to get paid.
43+
- [Opinio](https://opinio.media) - Allows the population to be surveyed on social issues.
44+
- [medpex: Online Apotheke](https://www.medpex.de) - Online pharmacy for medicines & cosmetics with over 5 million customers.
4245

43-
Let us know about your awesome project [here](https://github.com/proyecto26/react-native-inappbrowser/issues/164)! ❤️
46+
Share your awesome project [here](https://github.com/proyecto26/react-native-inappbrowser/issues/164)! ❤️
4447

4548
## Getting started
4649

@@ -67,7 +70,7 @@ Linking the package manually is not required anymore with [Autolinking](https://
6770
minSdkVersion = 16
6871
compileSdkVersion = 28
6972
targetSdkVersion = 28
70-
# Only using Android Support libraries
73+
// Only using Android Support libraries
7174
supportLibVersion = "28.0.0"
7275
}
7376
```
@@ -82,7 +85,7 @@ Linking the package manually is not required anymore with [Autolinking](https://
8285
minSdkVersion = 16
8386
compileSdkVersion = 28
8487
targetSdkVersion = 28
85-
# Remove 'supportLibVersion' property and put specific versions for AndroidX libraries
88+
// Remove 'supportLibVersion' property and put specific versions for AndroidX libraries
8689
androidXAnnotation = "1.1.0"
8790
androidXBrowser = "1.0.0"
8891
// Put here other AndroidX dependencies
@@ -231,17 +234,21 @@ import { InAppBrowser } from 'react-native-inappbrowser-reborn'
231234
In order to redirect back to your application from a web browser, you must specify a unique URI to your app. To do this,
232235
define your app scheme and replace `my-scheme` and `my-host` with your info.
233236

234-
- Enable deep linking (Android) - **[AndroidManifest.xml](https://github.com/proyecto26/react-native-inappbrowser/blob/master/example/android/app/src/main/AndroidManifest.xml#L23)**
237+
- Enable deep linking (Android) - **[AndroidManifest.xml](https://github.com/proyecto26/react-native-inappbrowser/blob/main/example/android/app/src/main/AndroidManifest.xml#L23)**
235238
```
236-
<intent-filter>
237-
<action android:name="android.intent.action.VIEW" />
238-
<category android:name="android.intent.category.DEFAULT" />
239-
<category android:name="android.intent.category.BROWSABLE" />
240-
<data android:scheme="my-scheme" android:host="my-host" android:pathPrefix="" />
241-
</intent-filter>
239+
<activity
240+
...
241+
android:launchMode="singleTask">
242+
<intent-filter>
243+
<action android:name="android.intent.action.VIEW" />
244+
<category android:name="android.intent.category.DEFAULT" />
245+
<category android:name="android.intent.category.BROWSABLE" />
246+
<data android:scheme="my-scheme" android:host="my-host" android:pathPrefix="" />
247+
</intent-filter>
248+
</activity>
242249
```
243250

244-
- Enable deep linking (iOS) - **[Info.plist](https://github.com/proyecto26/react-native-inappbrowser/blob/master/example/ios/example/Info.plist#L23)**
251+
- Enable deep linking (iOS) - **[Info.plist](https://github.com/proyecto26/react-native-inappbrowser/blob/main/example/ios/example/Info.plist#L23)**
245252
```
246253
<key>CFBundleURLTypes</key>
247254
<array>
@@ -270,8 +277,8 @@ export const getDeepLink = (path = "") => {
270277
- App.js ([Using react-navigation with Deep Linking](https://reactnavigation.org/docs/en/deep-linking.html))
271278
```javascript
272279
import { Root } from 'native-base'
273-
import { getDeepLink } from './utilities'
274280
import { createStackNavigator } from 'react-navigation'
281+
import { getDeepLink } from './utilities'
275282

276283
const Main = createStackNavigator(
277284
{
@@ -482,6 +489,14 @@ Support this project with your organization. Your logo will show up here with a
482489
I believe in Unicorns 🦄
483490
Support [me](http://www.paypal.me/jdnichollsc/2), if you do too.
484491

492+
Donate **Ethereum**, **ADA**, **BNB**, **SHIBA**, **USDT**, **DOGE**:
493+
494+
![Wallet address](https://user-images.githubusercontent.com/2154886/123501719-84bf1900-d60c-11eb-882c-98a499cea323.png)
495+
496+
> Wallet address: 0x3F9fA8021B43ACe578C2352861Cf335449F33427
497+
498+
Please let us know your contributions! 🙏
499+
485500
## Enterprise 💼
486501

487502
Available as part of the Tidelift Subscription.

android/src/main/java/com/proyecto26/inappbrowser/ChromeTabsDismissedEvent.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@
33
public class ChromeTabsDismissedEvent {
44
public final String message;
55
public final String resultType;
6+
public final Boolean isError;
67

7-
public ChromeTabsDismissedEvent(String message, String resultType) {
8+
public ChromeTabsDismissedEvent(String message, String resultType, Boolean isError) {
89
this.message = message;
910
this.resultType = resultType;
11+
this.isError = isError;
1012
}
1113
}

android/src/main/java/com/proyecto26/inappbrowser/ChromeTabsManagerActivity.java

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ public class ChromeTabsManagerActivity extends Activity {
2020

2121
private boolean mOpened = false;
2222
private String resultType = null;
23+
private boolean isError = false;
2324

2425
public static Intent createStartIntent(Context context, Intent authIntent) {
2526
Intent intent = createBaseIntent(context);
@@ -39,20 +40,27 @@ private static Intent createBaseIntent(Context context) {
3940

4041
@Override
4142
protected void onCreate(Bundle savedInstanceState) {
42-
super.onCreate(savedInstanceState);
43+
try {
44+
super.onCreate(savedInstanceState);
4345

44-
// This activity gets opened in 2 different ways. If the extra KEY_BROWSER_INTENT is present we
45-
// start that intent and if it is not it means this activity was started with FLAG_ACTIVITY_CLEAR_TOP
46-
// in order to close the intent that was started previously so we just close this.
47-
if (getIntent().hasExtra(KEY_BROWSER_INTENT)
48-
&& (savedInstanceState == null || savedInstanceState.getString(BROWSER_RESULT_TYPE) == null)
49-
) {
50-
Intent browserIntent = getIntent().getParcelableExtra(KEY_BROWSER_INTENT);
51-
browserIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
52-
startActivity(browserIntent);
53-
resultType = DEFAULT_RESULT_TYPE;
54-
} else {
46+
// This activity gets opened in 2 different ways. If the extra KEY_BROWSER_INTENT is present we
47+
// start that intent and if it is not it means this activity was started with FLAG_ACTIVITY_CLEAR_TOP
48+
// in order to close the intent that was started previously so we just close this.
49+
if (getIntent().hasExtra(KEY_BROWSER_INTENT)
50+
&& (savedInstanceState == null || savedInstanceState.getString(BROWSER_RESULT_TYPE) == null)
51+
) {
52+
Intent browserIntent = getIntent().getParcelableExtra(KEY_BROWSER_INTENT);
53+
browserIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
54+
startActivity(browserIntent);
55+
resultType = DEFAULT_RESULT_TYPE;
56+
} else {
57+
finish();
58+
}
59+
} catch (Exception e) {
60+
isError = true;
61+
EventBus.getDefault().post(new ChromeTabsDismissedEvent("Unable to open url.", resultType, isError));
5562
finish();
63+
e.printStackTrace();
5664
}
5765
}
5866

@@ -76,10 +84,10 @@ protected void onDestroy() {
7684
if (resultType != null) {
7785
switch (resultType) {
7886
case "cancel":
79-
EventBus.getDefault().post(new ChromeTabsDismissedEvent("chrome tabs activity closed", resultType));
87+
EventBus.getDefault().post(new ChromeTabsDismissedEvent("chrome tabs activity closed", resultType, isError));
8088
break;
8189
default:
82-
EventBus.getDefault().post(new ChromeTabsDismissedEvent("chrome tabs activity destroyed", DEFAULT_RESULT_TYPE));
90+
EventBus.getDefault().post(new ChromeTabsDismissedEvent("chrome tabs activity destroyed", DEFAULT_RESULT_TYPE, isError));
8391
break;
8492
}
8593
resultType = null;

android/src/main/java/com/proyecto26/inappbrowser/RNInAppBrowser.java

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,8 @@ public void open(Context context, final ReadableMap options, final Promise promi
187187
} catch (Exception e) {
188188
e.printStackTrace();
189189
}
190+
191+
registerEventBus();
190192

191193
intent.setData(Uri.parse(url));
192194
if (options.hasKey(KEY_SHOW_PAGE_TITLE)) {
@@ -196,8 +198,6 @@ public void open(Context context, final ReadableMap options, final Promise promi
196198
intent.putExtra(CustomTabsIntent.EXTRA_TITLE_VISIBILITY_STATE, CustomTabsIntent.NO_TITLE);
197199
}
198200

199-
registerEventBus();
200-
201201
currentActivity.startActivity(
202202
ChromeTabsManagerActivity.createStartIntent(currentActivity, intent),
203203
customTabsIntent.startAnimationBundle);
@@ -238,9 +238,14 @@ public void onEvent(ChromeTabsDismissedEvent event) {
238238
throw new AssertionError();
239239
}
240240

241-
WritableMap result = Arguments.createMap();
242-
result.putString("type", event.resultType);
243-
mOpenBrowserPromise.resolve(result);
241+
if (event.isError) {
242+
mOpenBrowserPromise.reject(ERROR_CODE, event.message);
243+
} else {
244+
WritableMap result = Arguments.createMap();
245+
result.putString("type", event.resultType);
246+
result.putString("message", event.message);
247+
mOpenBrowserPromise.resolve(result);
248+
}
244249
mOpenBrowserPromise = null;
245250
}
246251

example/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,5 @@ buck-out/
5757

5858
# CocoaPods
5959
/ios/Pods/
60+
61+
yarn.lock

example/App.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export default class App extends Component<ComponentState> {
3737
super(props);
3838

3939
this.state = {
40-
url: 'https://www.proyecto26.com',
40+
url: 'https://reactnative.dev',
4141
statusBarStyle: 'dark-content',
4242
};
4343
}
@@ -97,7 +97,7 @@ export default class App extends Component<ComponentState> {
9797
}
9898
} catch (error) {
9999
console.error(error);
100-
Alert.alert(error.message);
100+
Alert.alert(error.message || error);
101101
} finally {
102102
// Restore the previous StatusBar of the App
103103
StatusBar.setBarStyle(statusBarStyle);

ios/RNInAppBrowser.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ + (BOOL)requiresMainQueueSetup
165165
}
166166
@catch (NSException *exception) {
167167
reject(RNInAppBrowserErrorCode, @"Unable to open url.", nil);
168-
[self _close];
168+
[self flowDidFinish];
169169
NSLog(@"CRASH: %@", exception);
170170
NSLog(@"Stack Trace: %@", [exception callStackSymbols]);
171171
return;

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-native-inappbrowser-reborn",
3-
"version": "3.6.0",
3+
"version": "3.6.1",
44
"description": "InAppBrowser for React Native",
55
"main": "index.js",
66
"scripts": {

0 commit comments

Comments
 (0)