Skip to content

Commit 6497d79

Browse files
authored
Merge pull request #17 from proyecto26/feature/android-headers
Fix issue about headers option not working from Android
2 parents 8f24f27 + d55ceb0 commit 6497d79

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ in case of vulnerabilities.
2222

2323
## [Unreleased]
2424

25+
### Fixed
26+
- Fixed issue about `headers` option not working from **Android** [#16](https://github.com/proyecto26/nativescript-inappbrowser/issues/16).
27+
2528
## [2.1.0] - 2019-11-13
2629
### Added
2730
- Added support for `automatic` modal presentation style from **iOS**.

src/InAppBrowser.android.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ class InAppBrowserModule extends java.lang.Object {
9595
return Promise.reject(new Error(InAppBrowserModule.ERROR_CODE));
9696
}
9797

98-
const options = getDefaultOptions(url, inAppBrowserOptions);
98+
const options: InAppBrowserOptions = getDefaultOptions(url, inAppBrowserOptions);
9999

100100
const builder = new CustomTabsIntent.Builder();
101101
if (options[InAppBrowserModule.KEY_TOOLBAR_COLOR]) {
@@ -131,7 +131,7 @@ class InAppBrowserModule extends java.lang.Object {
131131
const customTabsIntent = builder.build();
132132

133133
const keyHeaders = options[InAppBrowserModule.KEY_HEADERS];
134-
if (keyHeaders && keyHeaders.length) {
134+
if (keyHeaders) {
135135
const headers = new Bundle();
136136
for (const key in keyHeaders) {
137137
if (keyHeaders.hasOwnProperty(key)) {

src/InAppBrowser.common.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,15 @@ export type RedirectResult = {
2424

2525
export type AuthSessionResult = RedirectResult | BrowserResult;
2626

27-
export function getDefaultOptions(url, options) {
27+
export function getDefaultOptions(url: string, options: any) {
2828
return {
2929
...options,
3030
url,
3131
dismissButtonStyle: options.dismissButtonStyle || 'close',
32-
readerMode: options.readerMode !== undefined ? options.readerMode : false,
32+
readerMode: !!options.readerMode,
3333
animated: options.animated !== undefined ? options.animated : true,
34-
modalEnabled: options.modalEnabled !== undefined ? options.modalEnabled : true
34+
modalEnabled: options.modalEnabled !== undefined ? options.modalEnabled : true,
35+
enableBarCollapsing: !!options.enableBarCollapsing
3536
};
3637
}
3738

0 commit comments

Comments
 (0)