Skip to content

Commit 1d547b5

Browse files
committed
Fixing issue with changes to ASWebAuthenticationSession, add support for automatic modal presentation style and add option to enable bar collapsing
1 parent e5d2892 commit 1d547b5

File tree

9 files changed

+218
-109
lines changed

9 files changed

+218
-109
lines changed

CHANGELOG.md

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

2323
## [Unreleased]
2424

25+
## [3.2.0] - 2019-11-10
26+
27+
### Added
28+
- Added support for `automatic` modal presentation style from **iOS**.
29+
- Added `enableBarCollapsing` option to determines whether the browser's tool bars will collapse or not from **iOS**.
30+
31+
### Fixed
32+
- Fixed Browser crashes on iOS 13 when openAuth is used.
33+
2534
## [3.1.0] - 2019-09-03
2635

2736
### Added
28-
- Add `waitForRedirectDelay` option for **Android** to fix issues dismissing the browser before detecting the redirection with `Linking` ([817f6ec](https://github.com/proyecto26/react-native-inappbrowser/commit/817f6ece140c0f2f84e21a537d5030403e652bc1)).
37+
- Added `waitForRedirectDelay` option for **Android** to fix issues dismissing the browser before detecting the redirection with `Linking` ([817f6ec](https://github.com/proyecto26/react-native-inappbrowser/commit/817f6ece140c0f2f84e21a537d5030403e652bc1)).
2938

3039
## [3.0.1] - 2019-08-16
3140

3241
### Added
33-
- Add gradle backward-compatibility for Android Support with Jetifier ([#96](https://github.com/proyecto26/react-native-inappbrowser/pull/97)).
42+
- Added gradle backward-compatibility for Android Support with Jetifier ([#96](https://github.com/proyecto26/react-native-inappbrowser/pull/97)).
3443
- Added **androidXAnnotation** and **androidXBrowser** properties from **rootProject.ext** for **AndroidX** with backward compatibility using **supportLibVersion** property instead.
3544

3645
## [3.0.0] - 2019-07-27

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,9 +140,10 @@ Property | Description
140140
`preferredControlTintColor` (String) | The color to tint the control buttons on the navigation bar and the toolbar. [`gray`/`#808080`]
141141
`readerMode` (Boolean) | A value that specifies whether Safari should enter Reader mode, if it is available. [`true`/`false`]
142142
`animated` (Boolean) | Animate the presentation. [`true`/`false`]
143-
`modalPresentationStyle` (String) | The presentation style for modally presented view controllers. [`none`/`fullScreen`/`pageSheet`/`formSheet`/`currentContext`/`custom`/`overFullScreen`/`overCurrentContext`/`popover`]
143+
`modalPresentationStyle` (String) | The presentation style for modally presented view controllers. [`automatic`/`none`/`fullScreen`/`pageSheet`/`formSheet`/`currentContext`/`custom`/`overFullScreen`/`overCurrentContext`/`popover`]
144144
`modalTransitionStyle` (String) | The transition style to use when presenting the view controller. [`coverVertical`/`flipHorizontal`/`crossDissolve`/`partialCurl`]
145145
`modalEnabled` (Boolean) | Present the **SafariViewController** modally or as push instead. [`true`/`false`]
146+
`enableBarCollapsing` (Boolean) | Determines whether the browser's tool bars will collapse or not. [`true`/`false`]
146147
147148
### Android Options
148149
Property | Description
@@ -178,6 +179,7 @@ import InAppBrowser from 'react-native-inappbrowser-reborn'
178179
modalPresentationStyle: 'overFullScreen',
179180
modalTransitionStyle: 'partialCurl',
180181
modalEnabled: true,
182+
enableBarCollapsing: false,
181183
// Android Properties
182184
showTitle: true,
183185
toolbarColor: '#6200EE',

example/App.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,20 +47,19 @@ export default class App extends Component {
4747
if (await InAppBrowser.isAvailable()) {
4848
// A delay to change the StatusBar when the browser is opened
4949
const animated = true;
50-
setTimeout(
51-
() => StatusBar.setBarStyle('light-content'),
52-
animated && Platform.OS === 'ios' ? 500 : 0
53-
);
50+
const delay = animated && Platform.OS === 'ios' ? 400 : 0;
51+
setTimeout(() => StatusBar.setBarStyle('light-content'), delay);
5452
const result = await InAppBrowser.open(url, {
5553
// iOS Properties
5654
dismissButtonStyle: 'cancel',
5755
preferredBarTintColor: '#453AA4',
5856
preferredControlTintColor: 'white',
5957
readerMode: false,
6058
animated,
61-
modalPresentationStyle: 'overFullScreen',
59+
modalPresentationStyle: 'fullScreen',
6260
modalTransitionStyle: 'partialCurl',
6361
modalEnabled: true,
62+
enableBarCollapsing: false,
6463
// Android Properties
6564
showTitle: true,
6665
toolbarColor: '#6200EE',
@@ -103,8 +102,8 @@ export default class App extends Component {
103102

104103
async tryDeepLinking() {
105104
const loginUrl = 'https://proyecto26.github.io/react-native-inappbrowser/';
106-
const redirectUrl = encodeURIComponent(this.getDeepLink('home'));
107-
const url = `${loginUrl}?redirect_url=${redirectUrl}`;
105+
const redirectUrl = this.getDeepLink();
106+
const url = `${loginUrl}?redirect_url=${encodeURIComponent(redirectUrl)}`;
108107
try {
109108
if (await InAppBrowser.isAvailable()) {
110109
const result = await InAppBrowser.openAuth(url, redirectUrl, {
@@ -113,7 +112,7 @@ export default class App extends Component {
113112
secondaryToolbarColor: 'black',
114113
enableUrlBarHiding: true,
115114
enableDefaultShare: true,
116-
waitForRedirectDelay: 1000
115+
waitForRedirectDelay: 2000
117116
});
118117
await this.sleep(800);
119118
Alert.alert('Response', JSON.stringify(result));

index.d.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ declare module 'react-native-inappbrowser-reborn' {
1919
readerMode?: boolean,
2020
animated?: boolean,
2121
modalPresentationStyle?:
22+
| 'automatic'
2223
| 'fullScreen'
2324
| 'pageSheet'
2425
| 'formSheet'
@@ -33,7 +34,8 @@ declare module 'react-native-inappbrowser-reborn' {
3334
| 'flipHorizontal'
3435
| 'crossDissolve'
3536
| 'partialCurl',
36-
modalEnabled?: boolean
37+
modalEnabled?: boolean,
38+
enableBarCollapsing?: boolean
3739
}
3840

3941
type InAppBrowserAndroidOptions = {

index.js

Lines changed: 27 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ type InAppBrowseriOSOptions = {
2525
readerMode?: boolean,
2626
animated?: boolean,
2727
modalPresentationStyle?:
28+
| 'automatic'
2829
| 'fullScreen'
2930
| 'pageSheet'
3031
| 'formSheet'
@@ -39,7 +40,8 @@ type InAppBrowseriOSOptions = {
3940
| 'flipHorizontal'
4041
| 'crossDissolve'
4142
| 'partialCurl',
42-
modalEnabled?: boolean
43+
modalEnabled?: boolean,
44+
enableBarCollapsing?: boolean
4345
};
4446

4547
type InAppBrowserAndroidOptions = {
@@ -65,27 +67,31 @@ async function open(
6567
url: string,
6668
options: InAppBrowserOptions = {}
6769
): Promise<BrowserResult> {
68-
const modalEnabled =
69-
options.modalEnabled !== undefined ? options.modalEnabled : true;
70+
const {
71+
animated,
72+
readerMode,
73+
modalEnabled,
74+
dismissButtonStyle,
75+
waitForRedirectDelay,
76+
enableBarCollapsing,
77+
preferredBarTintColor,
78+
preferredControlTintColor,
79+
...optionalOptions
80+
} = options;
7081
const inAppBrowserOptions = {
71-
...options,
82+
...optionalOptions,
7283
url,
73-
dismissButtonStyle: options.dismissButtonStyle || 'close',
74-
readerMode: options.readerMode !== undefined ? options.readerMode : false,
75-
animated: options.animated !== undefined ? options.animated : true,
76-
modalEnabled,
77-
waitForRedirectDelay: options.waitForRedirectDelay || 0
84+
dismissButtonStyle: dismissButtonStyle || 'close',
85+
readerMode: !!readerMode,
86+
animated: animated !== undefined ? animated : true,
87+
modalEnabled: modalEnabled !== undefined ? modalEnabled : true,
88+
waitForRedirectDelay: waitForRedirectDelay || 0,
89+
enableBarCollapsing: !!enableBarCollapsing,
90+
preferredBarTintColor:
91+
preferredBarTintColor && processColor(preferredBarTintColor),
92+
preferredControlTintColor:
93+
preferredControlTintColor && processColor(preferredControlTintColor)
7894
};
79-
if (inAppBrowserOptions.preferredBarTintColor) {
80-
inAppBrowserOptions.preferredBarTintColor = processColor(
81-
inAppBrowserOptions.preferredBarTintColor
82-
);
83-
}
84-
if (inAppBrowserOptions.preferredControlTintColor) {
85-
inAppBrowserOptions.preferredControlTintColor = processColor(
86-
inAppBrowserOptions.preferredControlTintColor
87-
);
88-
}
8995
return RNInAppBrowser.open(inAppBrowserOptions);
9096
}
9197

@@ -139,13 +145,13 @@ async function _openAuthSessionPolyfillAsync(
139145
let response = null;
140146
try {
141147
response = await Promise.race([
148+
_waitForRedirectAsync(returnUrl),
142149
open(startUrl, options).then(result => {
143150
return new Promise(resolve => {
144151
// A delay to wait for the redirection or dismiss the browser instead
145152
setTimeout(() => resolve(result), options.waitForRedirectDelay);
146153
});
147-
}),
148-
_waitForRedirectAsync(returnUrl)
154+
})
149155
]);
150156
} finally {
151157
close();

ios/RNInAppBrowser.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#endif
66

77
@interface RNInAppBrowser : NSObject <RCTBridgeModule>
8-
98
@end
109

10+
@interface ModalSafariViewController : UINavigationController <UINavigationControllerDelegate>
11+
@end

0 commit comments

Comments
 (0)