Skip to content

Commit

Permalink
Merge pull request #278 from proyecto26/develop
Browse files Browse the repository at this point in the history
Release 3.6.1
  • Loading branch information
jdnichollsc authored Jun 27, 2021
2 parents 623f34a + b6a193b commit 05364d3
Show file tree
Hide file tree
Showing 10 changed files with 78 additions and 40 deletions.
2 changes: 1 addition & 1 deletion .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ To help the rest of the community review your change, please follow the instruct

## PR Checklist

- [ ] The PR title follows our guidelines: https://github.com/proyecto26/react-native-inappbrowser/blob/master/CONTRIBUTING.md#pull-request-process.
- [ ] The PR title follows our guidelines: https://github.com/proyecto26/react-native-inappbrowser/blob/main/CONTRIBUTING.md#pull-request-process.
- [ ] 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.
- [ ] All existing tests are passing
- [ ] Tests for the changes are included
Expand Down
10 changes: 8 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,15 @@ in case of vulnerabilities.

## [Unreleased]

## [3.6.1] - 2021-06-27

### Added
- Add try catch block to `CustomTabs` logic to validate the url.

## [3.6.0] - 2021-06-25

### Added
- Add `navigationBarColor` and `navigationBarDividerColor` by [@jdnichollsc](https://github.com/jdnichollsc).
- Add `navigationBarColor` and `navigationBarDividerColor` options by [@jdnichollsc](https://github.com/jdnichollsc).
- 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)).

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


[Unreleased]: https://github.com/proyecto26/react-native-inappbrowser/compare/v3.6.0...HEAD
[Unreleased]: https://github.com/proyecto26/react-native-inappbrowser/compare/v3.6.1...HEAD
[3.6.1]: https://github.com/proyecto26/react-native-inappbrowser/compare/v3.6.0...v3.6.1
[3.6.0]: https://github.com/proyecto26/react-native-inappbrowser/compare/v3.5.1...v3.6.0
[3.5.1]: https://github.com/proyecto26/react-native-inappbrowser/compare/v3.5.0...v3.5.1
[3.5.0]: https://github.com/proyecto26/react-native-inappbrowser/compare/v3.4.0...v3.5.0
Expand Down
41 changes: 28 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,17 @@
<img width="400px" src="https://github.com/proyecto26/react-native-inappbrowser/blob/main/img/inappbrowser.png?raw=true">
</p>

## Demo
## Who is using InAppBrowser?

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

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

## Getting started

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

- Enable deep linking (Android) - **[AndroidManifest.xml](https://github.com/proyecto26/react-native-inappbrowser/blob/master/example/android/app/src/main/AndroidManifest.xml#L23)**
- Enable deep linking (Android) - **[AndroidManifest.xml](https://github.com/proyecto26/react-native-inappbrowser/blob/main/example/android/app/src/main/AndroidManifest.xml#L23)**
```
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="my-scheme" android:host="my-host" android:pathPrefix="" />
</intent-filter>
<activity
...
android:launchMode="singleTask">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="my-scheme" android:host="my-host" android:pathPrefix="" />
</intent-filter>
</activity>
```

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

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

Donate **Ethereum**, **ADA**, **BNB**, **SHIBA**, **USDT**, **DOGE**:

![Wallet address](https://user-images.githubusercontent.com/2154886/123501719-84bf1900-d60c-11eb-882c-98a499cea323.png)

> Wallet address: 0x3F9fA8021B43ACe578C2352861Cf335449F33427
Please let us know your contributions! 🙏

## Enterprise 💼

Available as part of the Tidelift Subscription.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
public class ChromeTabsDismissedEvent {
public final String message;
public final String resultType;
public final Boolean isError;

public ChromeTabsDismissedEvent(String message, String resultType) {
public ChromeTabsDismissedEvent(String message, String resultType, Boolean isError) {
this.message = message;
this.resultType = resultType;
this.isError = isError;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public class ChromeTabsManagerActivity extends Activity {

private boolean mOpened = false;
private String resultType = null;
private boolean isError = false;

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

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
try {
super.onCreate(savedInstanceState);

// This activity gets opened in 2 different ways. If the extra KEY_BROWSER_INTENT is present we
// start that intent and if it is not it means this activity was started with FLAG_ACTIVITY_CLEAR_TOP
// in order to close the intent that was started previously so we just close this.
if (getIntent().hasExtra(KEY_BROWSER_INTENT)
&& (savedInstanceState == null || savedInstanceState.getString(BROWSER_RESULT_TYPE) == null)
) {
Intent browserIntent = getIntent().getParcelableExtra(KEY_BROWSER_INTENT);
browserIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(browserIntent);
resultType = DEFAULT_RESULT_TYPE;
} else {
// This activity gets opened in 2 different ways. If the extra KEY_BROWSER_INTENT is present we
// start that intent and if it is not it means this activity was started with FLAG_ACTIVITY_CLEAR_TOP
// in order to close the intent that was started previously so we just close this.
if (getIntent().hasExtra(KEY_BROWSER_INTENT)
&& (savedInstanceState == null || savedInstanceState.getString(BROWSER_RESULT_TYPE) == null)
) {
Intent browserIntent = getIntent().getParcelableExtra(KEY_BROWSER_INTENT);
browserIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(browserIntent);
resultType = DEFAULT_RESULT_TYPE;
} else {
finish();
}
} catch (Exception e) {
isError = true;
EventBus.getDefault().post(new ChromeTabsDismissedEvent("Unable to open url.", resultType, isError));
finish();
e.printStackTrace();
}
}

Expand All @@ -76,10 +84,10 @@ protected void onDestroy() {
if (resultType != null) {
switch (resultType) {
case "cancel":
EventBus.getDefault().post(new ChromeTabsDismissedEvent("chrome tabs activity closed", resultType));
EventBus.getDefault().post(new ChromeTabsDismissedEvent("chrome tabs activity closed", resultType, isError));
break;
default:
EventBus.getDefault().post(new ChromeTabsDismissedEvent("chrome tabs activity destroyed", DEFAULT_RESULT_TYPE));
EventBus.getDefault().post(new ChromeTabsDismissedEvent("chrome tabs activity destroyed", DEFAULT_RESULT_TYPE, isError));
break;
}
resultType = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,8 @@ public void open(Context context, final ReadableMap options, final Promise promi
} catch (Exception e) {
e.printStackTrace();
}

registerEventBus();

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

registerEventBus();

currentActivity.startActivity(
ChromeTabsManagerActivity.createStartIntent(currentActivity, intent),
customTabsIntent.startAnimationBundle);
Expand Down Expand Up @@ -238,9 +238,14 @@ public void onEvent(ChromeTabsDismissedEvent event) {
throw new AssertionError();
}

WritableMap result = Arguments.createMap();
result.putString("type", event.resultType);
mOpenBrowserPromise.resolve(result);
if (event.isError) {
mOpenBrowserPromise.reject(ERROR_CODE, event.message);
} else {
WritableMap result = Arguments.createMap();
result.putString("type", event.resultType);
result.putString("message", event.message);
mOpenBrowserPromise.resolve(result);
}
mOpenBrowserPromise = null;
}

Expand Down
2 changes: 2 additions & 0 deletions example/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,5 @@ buck-out/

# CocoaPods
/ios/Pods/

yarn.lock
4 changes: 2 additions & 2 deletions example/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export default class App extends Component<ComponentState> {
super(props);

this.state = {
url: 'https://www.proyecto26.com',
url: 'https://reactnative.dev',
statusBarStyle: 'dark-content',
};
}
Expand Down Expand Up @@ -97,7 +97,7 @@ export default class App extends Component<ComponentState> {
}
} catch (error) {
console.error(error);
Alert.alert(error.message);
Alert.alert(error.message || error);
} finally {
// Restore the previous StatusBar of the App
StatusBar.setBarStyle(statusBarStyle);
Expand Down
2 changes: 1 addition & 1 deletion ios/RNInAppBrowser.m
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ + (BOOL)requiresMainQueueSetup
}
@catch (NSException *exception) {
reject(RNInAppBrowserErrorCode, @"Unable to open url.", nil);
[self _close];
[self flowDidFinish];
NSLog(@"CRASH: %@", exception);
NSLog(@"Stack Trace: %@", [exception callStackSymbols]);
return;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-native-inappbrowser-reborn",
"version": "3.6.0",
"version": "3.6.1",
"description": "InAppBrowser for React Native",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit 05364d3

Please sign in to comment.