@@ -57,38 +57,42 @@ Methods | Action
5757### Demo
5858
5959``` javascript
60- import InAppBrowser from ' react-native-inappbrowser-reborn' ;
60+ import { Linking } from ' react-native'
61+ import InAppBrowser from ' react-native-inappbrowser-reborn'
6162
6263...
6364 async openLink () {
6465 try {
65- await InAppBrowser .isAvailable ()
66- const result = await InAppBrowser .open (' https://www.google.com' , {
67- // iOS Properties
68- dismissButtonStyle: ' cancel' ,
69- preferredBarTintColor: ' gray' ,
70- preferredControlTintColor: ' white' ,
71- readerMode: false ,
72- // Android Properties
73- showTitle: true ,
74- toolbarColor: ' #6200EE' ,
75- secondaryToolbarColor: ' black' ,
76- enableUrlBarHiding: true ,
77- enableDefaultShare: true ,
78- forceCloseOnRedirection: false ,
79- // Specify full animation resource identifier(package:anim/name)
80- // or only resource name(in case of animation bundled with app).
81- animations: {
82- startEnter: ' slide_in_right' ,
83- startExit: ' slide_out_left' ,
84- endEnter: ' slide_in_right' ,
85- endExit: ' slide_out_left' ,
86- },
87- headers: {
88- ' my-custom-header' : ' my custom header value'
89- },
90- });
91- Alert .alert (JSON .stringify (result));
66+ if (await InAppBrowser .isAvailable ()) {
67+ const url = ' https://www.google.com'
68+ const result = await InAppBrowser .open (url, {
69+ // iOS Properties
70+ dismissButtonStyle: ' cancel' ,
71+ preferredBarTintColor: ' gray' ,
72+ preferredControlTintColor: ' white' ,
73+ readerMode: false ,
74+ // Android Properties
75+ showTitle: true ,
76+ toolbarColor: ' #6200EE' ,
77+ secondaryToolbarColor: ' black' ,
78+ enableUrlBarHiding: true ,
79+ enableDefaultShare: true ,
80+ forceCloseOnRedirection: false ,
81+ // Specify full animation resource identifier(package:anim/name)
82+ // or only resource name(in case of animation bundled with app).
83+ animations: {
84+ startEnter: ' slide_in_right' ,
85+ startExit: ' slide_out_left' ,
86+ endEnter: ' slide_in_right' ,
87+ endExit: ' slide_out_left' ,
88+ },
89+ headers: {
90+ ' my-custom-header' : ' my custom header value'
91+ },
92+ });
93+ Alert .alert (JSON .stringify (result));
94+ }
95+ else Linking .openURL (url)
9296 } catch (error) {
9397 Alert .alert (error .message )
9498 }
@@ -149,20 +153,21 @@ import { getDeepLink } from './utilities'
149153 const deepLink = getDeepLink (" callback" )
150154 const url = ` https://my-auth-login-page.com?redirect_uri=${ deepLink} `
151155 try {
152- await InAppBrowser .isAvailable ()
153- InAppBrowser .openAuth (url, deepLink, {
154- // iOS Properties
155- dismissButtonStyle: ' cancel' ,
156- // Android Properties
157- showTitle: false ,
158- enableUrlBarHiding: true ,
159- enableDefaultShare: true ,
160- }).then ((response ) => {
161- if (response .type === ' success' &&
162- response .url ) {
163- Linking .openURL (response .url )
164- }
165- })
156+ if (await InAppBrowser .isAvailable ()) {
157+ InAppBrowser .openAuth (url, deepLink, {
158+ // iOS Properties
159+ dismissButtonStyle: ' cancel' ,
160+ // Android Properties
161+ showTitle: false ,
162+ enableUrlBarHiding: true ,
163+ enableDefaultShare: true ,
164+ }).then ((response ) => {
165+ if (response .type === ' success' &&
166+ response .url ) {
167+ Linking .openURL (response .url )
168+ }
169+ })
170+ } else Linking .openURL (url)
166171 } catch (error) {
167172 Linking .openURL (url)
168173 }
@@ -211,8 +216,8 @@ If you need to restore the old bar style, after the browser is dismissed, you ca
211216// patch StatusBar.setBarStyle to make style accessible
212217const _setBarStyle = StatusBar .setBarStyle ;
213218StatusBar .setBarStyle = (style ) => {
214- StatusBar .currentStyle = style;
215- _setBarStyle (style);
219+ StatusBar .currentStyle = style;
220+ _setBarStyle (style);
216221};
217222```
218223
0 commit comments