diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index ff3a543..ff6cb17 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -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 diff --git a/CHANGELOG.md b/CHANGELOG.md index 66f510e..c079255 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 @@ -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 diff --git a/README.md b/README.md index ff2734f..80ac578 100644 --- a/README.md +++ b/README.md @@ -33,14 +33,17 @@

-## 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 @@ -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" } ``` @@ -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 @@ -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)** ``` - - - - - - + + + + + + + + ``` -- 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)** ``` CFBundleURLTypes @@ -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( { @@ -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. diff --git a/android/src/main/java/com/proyecto26/inappbrowser/ChromeTabsDismissedEvent.java b/android/src/main/java/com/proyecto26/inappbrowser/ChromeTabsDismissedEvent.java index f4655f4..ed12d2d 100644 --- a/android/src/main/java/com/proyecto26/inappbrowser/ChromeTabsDismissedEvent.java +++ b/android/src/main/java/com/proyecto26/inappbrowser/ChromeTabsDismissedEvent.java @@ -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; } } \ No newline at end of file diff --git a/android/src/main/java/com/proyecto26/inappbrowser/ChromeTabsManagerActivity.java b/android/src/main/java/com/proyecto26/inappbrowser/ChromeTabsManagerActivity.java index 02636cf..78bb33a 100644 --- a/android/src/main/java/com/proyecto26/inappbrowser/ChromeTabsManagerActivity.java +++ b/android/src/main/java/com/proyecto26/inappbrowser/ChromeTabsManagerActivity.java @@ -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); @@ -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(); } } @@ -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; diff --git a/android/src/main/java/com/proyecto26/inappbrowser/RNInAppBrowser.java b/android/src/main/java/com/proyecto26/inappbrowser/RNInAppBrowser.java index 80bf255..6798ed6 100644 --- a/android/src/main/java/com/proyecto26/inappbrowser/RNInAppBrowser.java +++ b/android/src/main/java/com/proyecto26/inappbrowser/RNInAppBrowser.java @@ -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)) { @@ -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); @@ -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; } diff --git a/example/.gitignore b/example/.gitignore index ad572e6..7e134ea 100644 --- a/example/.gitignore +++ b/example/.gitignore @@ -57,3 +57,5 @@ buck-out/ # CocoaPods /ios/Pods/ + +yarn.lock \ No newline at end of file diff --git a/example/App.js b/example/App.js index 4f496be..36bdf84 100644 --- a/example/App.js +++ b/example/App.js @@ -37,7 +37,7 @@ export default class App extends Component { super(props); this.state = { - url: 'https://www.proyecto26.com', + url: 'https://reactnative.dev', statusBarStyle: 'dark-content', }; } @@ -97,7 +97,7 @@ export default class App extends Component { } } 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); diff --git a/ios/RNInAppBrowser.m b/ios/RNInAppBrowser.m index 7b73f43..7eb5157 100644 --- a/ios/RNInAppBrowser.m +++ b/ios/RNInAppBrowser.m @@ -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; diff --git a/package.json b/package.json index a8bb33b..fc6a3af 100644 --- a/package.json +++ b/package.json @@ -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": {