├── .editorconfig
├── .eslintignore
├── .eslintrc.json
├── .gitignore
├── .husky
├── .gitignore
└── pre-commit
├── .npsrc
├── .nxignore
├── .prettierignore
├── .prettierrc
├── .travis.yml
├── LICENSE
├── README.md
├── apps
├── demo-angular
│ ├── .eslintrc.json
│ ├── .gitignore
│ ├── nativescript.config.ts
│ ├── package.json
│ ├── project.json
│ ├── references.d.ts
│ ├── src
│ │ ├── app-routing.module.ts
│ │ ├── app.component.ts
│ │ ├── app.module.ts
│ │ ├── app.scss
│ │ ├── assets
│ │ │ └── test.html
│ │ ├── home.component.html
│ │ ├── home.component.ts
│ │ ├── main.ts
│ │ ├── plugin-demos
│ │ │ ├── .gitkeep
│ │ │ ├── nativescript-webview.component.html
│ │ │ ├── nativescript-webview.component.ts
│ │ │ └── nativescript-webview.module.ts
│ │ └── polyfills.ts
│ ├── tsconfig.json
│ └── webpack.config.js
└── demo
│ ├── .eslintrc.json
│ ├── .gitignore
│ ├── nativescript.config.ts
│ ├── package.json
│ ├── project.json
│ ├── references.d.ts
│ ├── src
│ ├── app-root.xml
│ ├── app.scss
│ ├── app.ts
│ ├── assets
│ │ └── test.html
│ ├── main-page.ts
│ ├── main-page.xml
│ ├── main-view-model.ts
│ └── plugin-demos
│ │ ├── .gitkeep
│ │ ├── nativescript-webview.ts
│ │ └── nativescript-webview.xml
│ ├── tsconfig.json
│ └── webpack.config.js
├── jest.config.ts
├── nx.json
├── package.json
├── packages
├── .gitkeep
└── nativescript-webview
│ ├── .eslintrc.json
│ ├── README.md
│ ├── angular
│ ├── index.ts
│ ├── ng-package.json
│ ├── package.json
│ ├── tsconfig.angular.json
│ └── tsconfig.json
│ ├── common.ts
│ ├── index.ts
│ ├── package.json
│ ├── project.json
│ ├── references.d.ts
│ ├── screenshot.png
│ ├── tsconfig.json
│ └── utils.ts
├── references.d.ts
├── tools
├── assets
│ ├── App_Resources
│ │ ├── Android
│ │ │ ├── app.gradle
│ │ │ ├── before-plugins.gradle
│ │ │ ├── settings.gradle
│ │ │ └── src
│ │ │ │ └── main
│ │ │ │ ├── AndroidManifest.xml
│ │ │ │ └── res
│ │ │ │ ├── drawable-hdpi
│ │ │ │ ├── background.png
│ │ │ │ ├── icon.png
│ │ │ │ └── logo.png
│ │ │ │ ├── drawable-ldpi
│ │ │ │ ├── background.png
│ │ │ │ ├── icon.png
│ │ │ │ └── logo.png
│ │ │ │ ├── drawable-mdpi
│ │ │ │ ├── background.png
│ │ │ │ ├── icon.png
│ │ │ │ └── logo.png
│ │ │ │ ├── drawable-nodpi
│ │ │ │ └── splash_screen.xml
│ │ │ │ ├── drawable-xhdpi
│ │ │ │ ├── background.png
│ │ │ │ ├── icon.png
│ │ │ │ └── logo.png
│ │ │ │ ├── drawable-xxhdpi
│ │ │ │ ├── background.png
│ │ │ │ ├── icon.png
│ │ │ │ └── logo.png
│ │ │ │ ├── drawable-xxxhdpi
│ │ │ │ ├── background.png
│ │ │ │ ├── icon.png
│ │ │ │ └── logo.png
│ │ │ │ ├── values-v21
│ │ │ │ ├── colors.xml
│ │ │ │ └── styles.xml
│ │ │ │ └── values
│ │ │ │ ├── colors.xml
│ │ │ │ └── styles.xml
│ │ └── iOS
│ │ │ ├── Assets.xcassets
│ │ │ ├── AppIcon.appiconset
│ │ │ │ ├── Contents.json
│ │ │ │ ├── icon-1024.png
│ │ │ │ ├── icon-20.png
│ │ │ │ ├── icon-20@2x.png
│ │ │ │ ├── icon-20@3x.png
│ │ │ │ ├── icon-29.png
│ │ │ │ ├── icon-29@2x.png
│ │ │ │ ├── icon-29@3x.png
│ │ │ │ ├── icon-40.png
│ │ │ │ ├── icon-40@2x.png
│ │ │ │ ├── icon-40@3x.png
│ │ │ │ ├── icon-60@2x.png
│ │ │ │ ├── icon-60@3x.png
│ │ │ │ ├── icon-76.png
│ │ │ │ ├── icon-76@2x.png
│ │ │ │ └── icon-83.5@2x.png
│ │ │ ├── Contents.json
│ │ │ ├── LaunchScreen.AspectFill.imageset
│ │ │ │ ├── Contents.json
│ │ │ │ ├── LaunchScreen-AspectFill.png
│ │ │ │ ├── LaunchScreen-AspectFill@2x.png
│ │ │ │ └── LaunchScreen-AspectFill@3x.png
│ │ │ └── LaunchScreen.Center.imageset
│ │ │ │ ├── Contents.json
│ │ │ │ ├── LaunchScreen-Center.png
│ │ │ │ ├── LaunchScreen-Center@2x.png
│ │ │ │ └── LaunchScreen-Center@3x.png
│ │ │ ├── Info.plist
│ │ │ ├── LaunchScreen.storyboard
│ │ │ ├── Podfile
│ │ │ ├── build.xcconfig
│ │ │ ├── icon.png
│ │ │ └── icon@2x.png
│ ├── README.md
│ └── publishing
│ │ └── .npmignore
├── demo
│ ├── index.ts
│ ├── nativescript-webview
│ │ └── index.ts
│ ├── references.d.ts
│ ├── tsconfig.json
│ └── utils
│ │ ├── demo-base.ts
│ │ └── index.ts
├── package-settings.json
├── schematics
│ └── .gitkeep
├── scripts
│ └── build-finish.ts
├── tsconfig.tools.json
└── workspace-scripts.js
└── tsconfig.base.json
/.editorconfig:
--------------------------------------------------------------------------------
1 | # Editor configuration, see http://editorconfig.org
2 | root = true
3 |
4 | [*]
5 | charset = utf-8
6 | indent_style = space
7 | indent_size = 2
8 | insert_final_newline = true
9 | trim_trailing_whitespace = true
10 |
11 | [*.md]
12 | max_line_length = off
13 | trim_trailing_whitespace = false
14 |
--------------------------------------------------------------------------------
/.eslintignore:
--------------------------------------------------------------------------------
1 | node_modules
2 |
--------------------------------------------------------------------------------
/.eslintrc.json:
--------------------------------------------------------------------------------
1 | {
2 | "root": true,
3 | "ignorePatterns": ["**/*"],
4 | "plugins": ["@nrwl/nx"],
5 | "overrides": [
6 | {
7 | "files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
8 | "rules": {
9 | "@nrwl/nx/enforce-module-boundaries": [
10 | "error",
11 | {
12 | "enforceBuildableLibDependency": true,
13 | "allow": [],
14 | "depConstraints": [
15 | {
16 | "sourceTag": "*",
17 | "onlyDependOnLibsWithTags": ["*"]
18 | }
19 | ]
20 | }
21 | ]
22 | }
23 | },
24 | {
25 | "files": ["*.ts", "*.tsx"],
26 | "extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended", "prettier", "plugin:@nrwl/nx/typescript"],
27 | "rules": {}
28 | },
29 | {
30 | "files": ["*.js", "*.jsx"],
31 | "extends": ["plugin:@nrwl/nx/javascript"],
32 | "rules": {}
33 | },
34 | {
35 | "files": ["references.d.ts"],
36 | "rules": {
37 | "@typescript-eslint/triple-slash-reference": "off"
38 | }
39 | }
40 | ]
41 | }
42 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # See http://help.github.com/ignore-files/ for more about ignoring files.
2 |
3 | # compiled output
4 | /dist
5 | /tmp
6 | /out-tsc
7 |
8 | # dependencies
9 | node_modules
10 | package-lock.json
11 | yarn.lock
12 |
13 | # IDEs and editors
14 | /.idea
15 | .project
16 | .classpath
17 | .c9/
18 | *.launch
19 | .settings/
20 | *.sublime-workspace
21 |
22 | # IDE - VSCode
23 | .vscode/*
24 | !.vscode/settings.json
25 | !.vscode/tasks.json
26 | !.vscode/launch.json
27 | !.vscode/extensions.json
28 |
29 | # misc
30 | /.sass-cache
31 | /connect.lock
32 | /coverage
33 | /libpeerconnection.log
34 | npm-debug.log
35 | yarn-error.log
36 | testem.log
37 | /typings
38 |
39 | # System Files
40 | .DS_Store
41 | Thumbs.db
42 |
43 | *.tgz
44 | packages/**/angular/dist
45 |
--------------------------------------------------------------------------------
/.husky/.gitignore:
--------------------------------------------------------------------------------
1 | _
2 |
--------------------------------------------------------------------------------
/.husky/pre-commit:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | . "$(dirname "$0")/_/husky.sh"
3 |
4 | npx lint-staged --allow-empty
5 |
--------------------------------------------------------------------------------
/.npsrc:
--------------------------------------------------------------------------------
1 | {
2 | "config": "./tools/workspace-scripts.js"
3 | }
--------------------------------------------------------------------------------
/.nxignore:
--------------------------------------------------------------------------------
1 | apps/**/*_off
--------------------------------------------------------------------------------
/.prettierignore:
--------------------------------------------------------------------------------
1 | # Add files here to ignore them from prettier formatting
2 |
3 | /dist
4 | /coverage
5 | native-src
6 |
--------------------------------------------------------------------------------
/.prettierrc:
--------------------------------------------------------------------------------
1 | {
2 | "useTabs": false,
3 | "printWidth": 800,
4 | "tabWidth": 2,
5 | "singleQuote": true
6 | }
7 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: node_js
2 | node_js:
3 | - "node"
4 | script:
5 | - npm run setup
6 | - npm start @ammarahmed.build-all
7 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "{}"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright (c) 2015-2019 Progress Software Corporation
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # NativeScript WebView
2 |
3 | A NativeScript webview plugin that wraps the popular [react-native-webview](https://github.com/react-native-webview/react-native-webview) library using [Open Native](https://github.com/OpenNative). Seemlessly integrate web content into your NativeScript applications using the robust and feature rich WebView library.
4 |
5 |
6 |
7 | ## Installation
8 |
9 | ```bash
10 | npm install @open-native/core @ammarahmed/nativescript-webview react-native-webview
11 | ```
12 | Make sure to set up `@open-native/core` in your project following the [Open Native Getting Started](https://open-native.org) guide.
13 |
14 | ## Usage
15 |
16 | ### Core
17 |
18 | 1. Register the plugin namespace with Page's `xmlns` attribute providing your prefix( `ui`, for example).
19 |
20 | ```xml
21 |
22 | ```
23 |
24 | 2. Access the `WebView` view through the prefix.
25 |
26 | ```xml
27 |
28 |
29 |
30 | ```
31 | ---
32 |
33 | ### Angular
34 |
35 | 1. Add `NativeScriptWebViewModule` to the module imports where you want to use the view.
36 |
37 | ```typescript
38 | import { NativeScriptWebViewModule } from '@ammarahmed/nativescript-webview/angular';
39 | imports: [NativeScriptWebViewModule];
40 | ```
41 |
42 | 2. Use the view in HTML.
43 |
44 | ```xml
45 |
46 | ```
47 | ---
48 |
49 | ### Vue
50 |
51 | 1. Register the view in the `app.ts` file.
52 | ```ts
53 | import { registerElement } from 'nativescript-vue';
54 |
55 | registerElement("NSWebView", ()=> require("@ammarahmed/nativescript-webview").NSWebView)
56 | ```
57 | 2. Use the view in a `.vue` file.
58 |
59 | ```xml
60 |
61 | ```
62 | ---
63 |
64 | # Reference
65 |
66 | This document lays out the current public properties and methods for the NativeScript WebView. This is mostly based on the original [react-native-webview API reference](https://github.com/react-native-webview/react-native-webview/blob/master/docs/Reference.md) with some small differences.
67 |
68 | ### `source`
69 |
70 | Loads static HTML or a URI (with optional headers) in the WebView. Note that static HTML will require setting [`originWhitelist`](README.md#originwhitelist) to `["*"]`.
71 |
72 | The object passed to `source` can have either of the following shapes:
73 |
74 | **Load uri**
75 |
76 | - `uri` (string) - The URI to load in the `WebView`. Can be a local or remote file, and can be changed with React state or props to navigate to a new page.
77 | - `method` (string) - The HTTP Method to use. Defaults to GET if not specified. On Android and Windows, the only supported methods are GET and POST.
78 | - `headers` (object) - Additional HTTP headers to send with the request. On Android, this can only be used with GET requests. See the [Guide](Guide.md#setting-custom-headers) for more information on setting custom headers.
79 | - `body` (string) - The HTTP body to send with the request. This must be a valid UTF-8 string, and will be sent exactly as specified, with no additional encoding (e.g. URL-escaping or base64) applied. On Android and Windows, this can only be used with POST requests.
80 |
81 | **Local files**
82 |
83 | Place the files you want to load in app's `assets` folder. Then pass in the path to your file as URI:
84 |
85 | ```js
86 | // Android
87 | `file:///android_asset/app/assets/path/to/your/html/file.html` // iOS
88 | ` app/assets/path/to/your/file.html`;
89 | ```
90 |
91 | **Static HTML**
92 |
93 | _Note that using static HTML requires the WebView property [originWhiteList](README.md#originWhiteList) to `['*']`. For some content, such as video embeds (e.g. Twitter or Facebook posts with video), the baseUrl needs to be set for the video playback to work_
94 |
95 | - `html` (string) - A static HTML page to display in the WebView.
96 | - `baseUrl` (string) - The base URL to be used for any relative links in the HTML. This is also used for the origin header with CORS requests made from the WebView. See [Android WebView Docs](https://developer.android.com/reference/android/webkit/WebView#loadDataWithBaseURL)
97 |
98 | | Type | Required |
99 | | ------ | -------- |
100 | | object | No |
101 |
102 | ---
103 |
104 | ### `automaticallyAdjustContentInsets`
105 |
106 | Controls whether to adjust the content inset for web views that are placed behind a navigation bar, tab bar, or toolbar. The default value is `true`.
107 |
108 | | Type | Required | Platform |
109 | | ---- | -------- | -------- |
110 | | bool | No | iOS |
111 |
112 | ---
113 |
114 | ### `automaticallyAdjustsScrollIndicatorInsets`
115 |
116 | Controls whether to adjust the scroll indicator inset for web views that are placed behind a navigation bar, tab bar, or toolbar. The default value `false`. (iOS 13+)
117 |
118 | | Type | Required | Platform |
119 | | ---- | -------- | -------- |
120 | | bool | No | iOS(13+) |
121 |
122 | ---
123 |
124 | ### `injectedJavaScript`
125 |
126 | Set this to provide JavaScript that will be injected into the web page after the document finishes loading, but before other subresources finish loading.
127 |
128 | Make sure the string evaluates to a valid type (`true` works) and doesn't otherwise throw an exception.
129 |
130 | On iOS, see [`WKUserScriptInjectionTimeAtDocumentEnd`](https://developer.apple.com/documentation/webkit/wkuserscriptinjectiontime/wkuserscriptinjectiontimeatdocumentend?language=objc). Be sure
131 | to set an [`onMessage`](README.md#onmessage) handler, even if it's a no-op, or the code will not be run.
132 |
133 | | Type | Required | Platform |
134 | | ------ | -------- | ------------ |
135 | | string | No | iOS, Android |
136 |
137 | ---
138 |
139 | ### `injectedJavaScriptBeforeContentLoaded`
140 |
141 | Set this to provide JavaScript that will be injected into the web page after the document element is created, but before other subresources finish loading.
142 |
143 | Make sure the string evaluates to a valid type (`true` works) and doesn't otherwise throw an exception.
144 |
145 | On iOS, see [`WKUserScriptInjectionTimeAtDocumentStart`](https://developer.apple.com/documentation/webkit/wkuserscriptinjectiontime/wkuserscriptinjectiontimeatdocumentstart?language=objc)
146 |
147 | > **Warning**
148 | > On Android, this may work, but it is not 100% reliable (see [#1609](https://github.com/react-native-webview/react-native-webview/issues/1609) and [#1099](https://github.com/react-native-webview/react-native-webview/pull/1099)). Consider `injectedJavaScriptObject` instead.
149 |
150 | | Type | Required | Platform |
151 | | ------ | -------- | ---------------------------------- |
152 | | string | No | iOS, Android (experimental) |
153 |
154 | To learn more, read the [Communicating between JS and Native](Guide.md#communicating-between-js-and-native) guide.
155 |
156 | ---
157 |
158 | ### `injectedJavaScriptForMainFrameOnly`
159 |
160 | If `true` (default; mandatory for Android), loads the `injectedJavaScript` only into the main frame.
161 |
162 | If `false`, (only supported on iOS), loads it into all frames (e.g. iframes).
163 |
164 | | Type | Required | Platform |
165 | | ---- | -------- | ------------------------------------------------- |
166 | | bool | No | iOS (only `true` supported for Android) |
167 |
168 | ---
169 |
170 | ### `injectedJavaScriptBeforeContentLoadedForMainFrameOnly`
171 |
172 | If `true` (default; mandatory for Android), loads the `injectedJavaScriptBeforeContentLoaded` only into the main frame.
173 |
174 | If `false`, (only supported on iOS), loads it into all frames (e.g. iframes).
175 |
176 | | Type | Required | Platform |
177 | | ---- | -------- | ------------------------------------------------- |
178 | | bool | No | iOS (only `true` supported for Android) |
179 |
180 | ---
181 |
182 | ### `injectedJavaScriptObject`
183 |
184 | Inject any JavaScript object into the webview so it is available to the JS running on the page.
185 |
186 | | Type | Required | Platform |
187 | | ---- | -------- | ------------ |
188 | | obj | No | Android only |
189 |
190 | Example:
191 |
192 | Set a value to be used in JavaScript.
193 |
194 | Note: Any value in the object will be accessible to _all_ frames of the webpage. If sensitive values are present please ensure that you have a strict Content Security Policy set up to avoid data leaking.
195 |
196 | You can access the object in the webview using `window.ReactNativeWebView.injectedObject`.
197 |
198 | ```js
199 | window.ReactNativeWebView.injectedObjectJson();
200 | ```
201 |
202 | ---
203 |
204 | ### `mediaPlaybackRequiresUserAction`
205 |
206 | Boolean that determines whether HTML5 audio and video requires the user to tap them before they start playing. The default value is `true`. (Android API minimum version 17).
207 |
208 | NOTE: the default `true` value might cause some videos to hang loading on iOS. Setting it to `false` could fix this issue.
209 |
210 | | Type | Required | Platform |
211 | | ---- | -------- | ------------------- |
212 | | bool | No | iOS, Android |
213 |
214 | ---
215 |
216 | ### `originWhitelist`
217 |
218 | List of origin strings to allow being navigated to. The strings allow wildcards and get matched against _just_ the origin (not the full URL). If the user taps to navigate to a new page but the new page is not in this whitelist, the URL will be handled by the OS. The default whitelisted origins are "http://_" and "https://_".
219 |
220 | | Type | Required | Platform |
221 | | ---------------- | -------- | ------------ |
222 | | array of strings | No | iOS, Android |
223 |
224 | ---
225 |
226 | ### `scalesPageToFit`
227 |
228 | Boolean that controls whether the web content is scaled to fit the view and enables the user to change the scale. The default value is `true`.
229 |
230 | | Type | Required | Platform |
231 | | ---- | -------- | -------- |
232 | | bool | No | Android |
233 |
234 | ---
235 |
236 | ### `decelerationRate`
237 |
238 | A floating-point number that determines how quickly the scroll view decelerates after the user lifts their finger. You may also use the string shortcuts `"normal"` and `"fast"` which match the underlying iOS settings for `UIScrollViewDecelerationRateNormal` and `UIScrollViewDecelerationRateFast` respectively:
239 |
240 | - normal: 0.998
241 | - fast: 0.99 (the default for iOS web view)
242 |
243 | | Type | Required | Platform |
244 | | ------ | -------- | -------- |
245 | | number | No | iOS |
246 |
247 | ---
248 |
249 | ### `domStorageEnabled`
250 |
251 | Boolean value to control whether DOM Storage is enabled. Used only in Android.
252 |
253 | | Type | Required | Platform |
254 | | ---- | -------- | -------- |
255 | | bool | No | Android |
256 |
257 | ---
258 |
259 | ### `javaScriptEnabled`
260 |
261 | Boolean value to enable JavaScript in the `WebView`. The default value is `true`.
262 |
263 | | Type | Required |
264 | | ---- | -------- |
265 | | bool | No |
266 |
267 | ---
268 |
269 | ### `javaScriptCanOpenWindowsAutomatically`
270 |
271 | A Boolean value indicating whether JavaScript can open windows without user interaction. The default value is `false`.
272 |
273 | | Type | Required |
274 | | ---- | -------- |
275 | | bool | No |
276 |
277 | ---
278 |
279 | ### `androidLayerType`
280 |
281 | Specifies the layer type.
282 |
283 | Possible values for `androidLayerType` are:
284 |
285 | - `none` (default) - The view does not have a layer.
286 | - `software` - The view has a software layer. A software layer is backed by a bitmap and causes the view to be rendered using Android's software rendering pipeline, even if hardware acceleration is enabled.
287 | - `hardware` - The view has a hardware layer. A hardware layer is backed by a hardware specific texture and causes the view to be rendered using Android's hardware rendering pipeline, but only if hardware acceleration is turned on for the view hierarchy.
288 |
289 | | Type | Required | Platform |
290 | | ------ | -------- | -------- |
291 | | string | No | Android |
292 |
293 | ---
294 |
295 | ### `mixedContentMode`
296 |
297 | Specifies the mixed content mode. i.e WebView will allow a secure origin to load content from any other origin.
298 |
299 | Possible values for `mixedContentMode` are:
300 |
301 | - `never` (default) - WebView will not allow a secure origin to load content from an insecure origin.
302 | - `always` - WebView will allow a secure origin to load content from any other origin, even if that origin is insecure.
303 | - `compatibility` - WebView will attempt to be compatible with the approach of a modern web browser with regard to mixed content.
304 |
305 | | Type | Required | Platform |
306 | | ------ | -------- | -------- |
307 | | string | No | Android |
308 |
309 | ---
310 |
311 | ### `thirdPartyCookiesEnabled`
312 |
313 | Boolean value to enable third party cookies in the `WebView`. Used on Android Lollipop and above only as third party cookies are enabled by default on Android Kitkat and below and on iOS. The default value is `true`. For more on cookies, read the [Guide](Guide.md#Managing-Cookies)
314 |
315 | | Type | Required | Platform |
316 | | ---- | -------- | -------- |
317 | | bool | No | Android |
318 |
319 | ---
320 |
321 | ### `userAgent`
322 |
323 | Sets the user-agent for the `WebView`.
324 |
325 | | Type | Required | Platform |
326 | | ------ | -------- | ------------ |
327 | | string | No | iOS, Android |
328 |
329 | ---
330 |
331 | ### `applicationNameForUserAgent`
332 |
333 | Append to the existing user-agent. Setting `userAgent` will override this.
334 |
335 | | Type | Required | Platform |
336 | | ------ | -------- | ------------ |
337 | | string | No | iOS, Android |
338 |
339 | ### `allowsFullscreenVideo`
340 |
341 | Boolean that determines whether videos are allowed to be played in fullscreen. The default value is `false`.
342 |
343 | | Type | Required | Platform |
344 | | ---- | -------- | -------- |
345 | | bool | No | Android |
346 |
347 | ---
348 |
349 | ### `allowsInlineMediaPlayback`
350 |
351 | Boolean that determines whether HTML5 videos play inline or use the native full-screen controller. The default value is `false`.
352 |
353 | > **NOTE**
354 | >
355 | > In order for video to play inline, not only does this property need to be set to `true`, but the video element in the HTML document must also include the `webkit-playsinline` attribute.
356 |
357 | | Type | Required | Platform |
358 | | ---- | -------- | -------- |
359 | | bool | No | iOS |
360 |
361 | ---
362 |
363 | ### `allowsAirPlayForMediaPlayback`
364 |
365 | A Boolean value indicating whether AirPlay is allowed. The default value is `false`.
366 |
367 | | Type | Required | Platform |
368 | | ------- | -------- | ------------- |
369 | | boolean | No | iOS |
370 |
371 | ---
372 |
373 | ### `bounces`
374 |
375 | Boolean value that determines whether the web view bounces when it reaches the edge of the content. The default value is `true`.
376 |
377 | | Type | Required | Platform |
378 | | ---- | -------- | -------- |
379 | | bool | No | iOS |
380 |
381 | ---
382 |
383 | ### `overScrollMode`
384 |
385 | Specifies the over scroll mode.
386 |
387 | Possible values for `overScrollMode` are:
388 |
389 | - `always` (default) - Always allow a user to over-scroll this view, provided it is a view that can scroll.
390 | - `content` - Allow a user to over-scroll this view only if the content is large enough to meaningfully scroll, provided it is a view that can scroll.
391 | - `never` - Never allow a user to over-scroll this view.
392 |
393 | | Type | Required | Platform |
394 | | ------ | -------- | -------- |
395 | | string | No | Android |
396 |
397 | ---
398 |
399 | ### `contentInset`
400 |
401 | The amount by which the web view content is inset from the edges of the scroll view. Defaults to {top: 0, left: 0, bottom: 0, right: 0}.
402 |
403 | | Type | Required | Platform |
404 | | ------------------------------------------------------------------ | -------- | -------- |
405 | | object: {top: number, left: number, bottom: number, right: number} | No | iOS |
406 |
407 | ---
408 |
409 | ### `contentInsetAdjustmentBehavior`
410 |
411 | This property specifies how the safe area insets are used to modify the content area of the scroll view. The default value of this property is "never". Available on iOS 11 and later. Defaults to `never`.
412 |
413 | Possible values:
414 |
415 | - `automatic`
416 | - `scrollableAxes`
417 | - `never`
418 | - `always`
419 |
420 | | Type | Required | Platform |
421 | | ------ | -------- | -------- |
422 | | string | No | iOS |
423 |
424 | ---
425 |
426 | ### `contentMode`
427 |
428 | Controls the type of content to load. Available on iOS 13 and later. Defaults to `recommended`, which loads mobile content on iPhone & iPad Mini but desktop content on larger iPads.
429 |
430 | See [Introducing Desktop-class Browsing on iPad](https://developer.apple.com/videos/play/wwdc2019/203/) for more.
431 |
432 | Possible values:
433 |
434 | - `recommended`
435 | - `mobile`
436 | - `desktop`
437 |
438 | | Type | Required | Platform |
439 | | ------ | -------- | -------- |
440 | | string | No | iOS |
441 |
442 | ---
443 |
444 | ### `dataDetectorTypes`
445 |
446 | Determines the types of data converted to clickable URLs in the web view's content. By default only phone numbers are detected.
447 |
448 | You can provide one type or an array of many types.
449 |
450 | Possible values for `dataDetectorTypes` are:
451 |
452 | - `phoneNumber`
453 | - `link`
454 | - `address`
455 | - `calendarEvent`
456 | - `none`
457 | - `all`
458 | - `trackingNumber`
459 | - `flightNumber`
460 | - `lookupSuggestion`
461 |
462 | | Type | Required | Platform |
463 | | ---------------- | -------- | -------- |
464 | | string, or array | No | iOS |
465 |
466 | ---
467 |
468 | ### `scrollEnabled`
469 |
470 | Boolean value that determines whether scrolling is enabled in the `WebView`. The default value is `true`. Setting this to `false` will prevent the webview from moving the document body when the keyboard appears over an input.
471 |
472 | | Type | Required | Platform |
473 | | ---- | -------- | -------- |
474 | | bool | No | iOS |
475 |
476 | ---
477 |
478 | ### `nestedScrollEnabled`
479 |
480 | Boolean value that determines whether scrolling is possible in the `WebView` when used inside a `ScrollView` on Android. The default value is `false`.
481 |
482 | Setting this to `true` will prevent the `ScrollView` to scroll when scrolling from inside the `WebView`.
483 |
484 | | Type | Required | Platform |
485 | | ---- | -------- | -------- |
486 | | bool | No | Android |
487 |
488 | ---
489 |
490 | ### `setBuiltInZoomControls`
491 |
492 | Sets whether the WebView should use its built-in zoom mechanisms. The default value is `true`. Setting this to `false` will prevent the use of a pinch gesture to control zooming.
493 |
494 | | Type | Required | Platform |
495 | | ---- | -------- | -------- |
496 | | bool | No | Android |
497 |
498 | ---
499 |
500 | ### `setDisplayZoomControls`
501 |
502 | Sets whether the WebView should display on-screen zoom controls when using the built-in zoom mechanisms (see `setBuiltInZoomControls`). The default value is `false`.
503 |
504 | | Type | Required | Platform |
505 | | ---- | -------- | -------- |
506 | | bool | No | Android |
507 |
508 | ---
509 |
510 | ### `directionalLockEnabled`
511 |
512 | A Boolean value that determines whether scrolling is disabled in a particular direction.
513 | The default value is `true`.
514 |
515 | | Type | Required | Platform |
516 | | ---- | -------- | -------- |
517 | | bool | No | iOS |
518 |
519 | ---
520 |
521 | ### `showsHorizontalScrollIndicator`
522 |
523 | Boolean value that determines whether a horizontal scroll indicator is shown in the `WebView`. The default value is `true`.
524 |
525 | | Type | Required | Platform |
526 | | ---- | -------- | ------------ |
527 | | bool | No | iOS, Android |
528 |
529 | ---
530 |
531 | ### `showsVerticalScrollIndicator`
532 |
533 | Boolean value that determines whether a vertical scroll indicator is shown in the `WebView`. The default value is `true`.
534 |
535 | | Type | Required | Platform |
536 | | ---- | -------- | ------------ |
537 | | bool | No | iOS, Android |
538 |
539 | ---
540 |
541 | ### `geolocationEnabled`
542 |
543 | Set whether Geolocation is enabled in the `WebView`. The default value is `false`. Used only in Android.
544 |
545 | | Type | Required | Platform |
546 | | ---- | -------- | -------- |
547 | | bool | No | Android |
548 |
549 | ---
550 |
551 | ### `allowFileAccessFromFileURLs`
552 |
553 | Boolean that sets whether JavaScript running in the context of a file scheme URL should be allowed to access content from other file scheme URLs. The default value is `false`.
554 |
555 | | Type | Required | Platform |
556 | | ---- | -------- | ------------ |
557 | | bool | No | iOS, Android |
558 |
559 | ---
560 |
561 | ### `allowUniversalAccessFromFileURLs`
562 |
563 | Boolean that sets whether JavaScript running in the context of a file scheme URL should be allowed to access content from any origin. Including accessing content from other file scheme URLs. The default value is `false`.
564 |
565 | | Type | Required | Platform |
566 | | ---- | -------- | ------------ |
567 | | bool | No | iOS, Android |
568 |
569 | ---
570 |
571 | ### `allowingReadAccessToURL`
572 |
573 | A String value that indicates which URLs the WebView's file can then reference in scripts, AJAX requests, and CSS imports. This is only used in for WebViews that are loaded with a `source.uri` set to a `'file://'` URL. If not provided, the default is to only allow read access to the URL provided in `source.uri` itself.
574 |
575 | | Type | Required | Platform |
576 | | ------ | -------- | -------- |
577 | | string | No | iOS |
578 |
579 | ---
580 |
581 | ### `keyboardDisplayRequiresUserAction`
582 |
583 | If `false`, web content can programmatically display the keyboard. The default value is `true`.
584 |
585 | | Type | Required | Platform |
586 | | ------- | -------- | -------- |
587 | | boolean | No | iOS |
588 |
589 | ---
590 |
591 | ### `hideKeyboardAccessoryView`
592 |
593 | If `true`, this will hide the keyboard accessory view (< > and Done).
594 |
595 | | Type | Required | Platform |
596 | | ------- | -------- | -------- |
597 | | boolean | No | iOS |
598 |
599 | ---
600 |
601 | ### `allowsBackForwardNavigationGestures`
602 |
603 | If `true`, this will be able horizontal swipe gestures. The default value is `false`.
604 |
605 | | Type | Required | Platform |
606 | | ------- | -------- | -------- |
607 | | boolean | No | iOS |
608 |
609 | ---
610 |
611 | ### `incognito`
612 |
613 | Does not store any data within the lifetime of the WebView.
614 |
615 | | Type | Required | Platform |
616 | | ------- | -------- | ------------------- |
617 | | boolean | No | iOS, Android |
618 |
619 | ---
620 |
621 | ### `allowFileAccess`
622 |
623 | If `true`, this will allow access to the file system via `file://` URI's. The default value is `false`.
624 |
625 | | Type | Required | Platform |
626 | | ------- | -------- | -------- |
627 | | boolean | No | Android |
628 |
629 | ---
630 |
631 | ### `saveFormDataDisabled`
632 |
633 | Sets whether the WebView should disable saving form data. The default value is `false`. This function does not have any effect from Android API level 26 onwards as there is an Autofill feature which stores form data.
634 |
635 | | Type | Required | Platform |
636 | | ------- | -------- | -------- |
637 | | boolean | No | Android |
638 |
639 | ---
640 |
641 | ### `cacheEnabled`
642 |
643 | Sets whether WebView should use browser caching.
644 |
645 | | Type | Required | Default | Platform |
646 | | ------- | -------- | ------- | ------------ |
647 | | boolean | No | true | iOS, Android |
648 |
649 | ---
650 |
651 | ### `cacheMode`
652 |
653 | Overrides the way the cache is used. The way the cache is used is based on the navigation type. For a normal page load, the cache is checked and content is re-validated as needed. When navigating back, content is not revalidated, instead the content is just retrieved from the cache. This property allows the client to override this behavior.
654 |
655 | Possible values are:
656 |
657 | - `LOAD_DEFAULT` - Default cache usage mode. If the navigation type doesn't impose any specific behavior, use cached resources when they are available and not expired, otherwise load resources from the network.
658 | - `LOAD_CACHE_ELSE_NETWORK` - Use cached resources when they are available, even if they have expired. Otherwise load resources from the network.
659 | - `LOAD_NO_CACHE` - Don't use the cache, load from the network.
660 | - `LOAD_CACHE_ONLY` - Don't use the network, load from the cache.
661 |
662 | | Type | Required | Default | Platform |
663 | | ------ | -------- | ------------ | -------- |
664 | | string | No | LOAD_DEFAULT | Android |
665 |
666 | ---
667 |
668 | ### `pagingEnabled`
669 |
670 | If the value of this property is `true`, the scroll view stops on multiples of the scroll view’s bounds when the user scrolls. The default value is `false`.
671 |
672 | | Type | Required | Platform |
673 | | ------- | -------- | -------- |
674 | | boolean | No | iOS |
675 |
676 | ---
677 |
678 | ### `allowsLinkPreview`
679 |
680 | A Boolean value that determines whether pressing on a link displays a preview of the destination for the link. In iOS this property is available on devices that support 3D Touch. In iOS 10 and later, the default value is `true`; before that, the default value is `false`.
681 |
682 | | Type | Required | Platform |
683 | | ------- | -------- | ------------- |
684 | | boolean | No | iOS |
685 |
686 | ---
687 |
688 | ### `sharedCookiesEnabled`
689 |
690 | Set `true` if shared cookies from `[NSHTTPCookieStorage sharedHTTPCookieStorage]` should be used for every load request in the WebView. The default value is `false`. For more on cookies, read the [Guide](Guide.md#Managing-Cookies)
691 |
692 | | Type | Required | Platform |
693 | | ------- | -------- | ------------- |
694 | | boolean | No | iOS |
695 |
696 | ---
697 |
698 | ### `textZoom`
699 |
700 | If the user has set a custom font size in the Android system, an undesirable scale of the site interface in WebView occurs.
701 |
702 | When setting the standard textZoom (100) parameter size, this undesirable effect disappears.
703 |
704 | | Type | Required | Platform |
705 | | ------ | -------- | -------- |
706 | | number | No | Android |
707 |
708 | ---
709 |
710 | ### `pullToRefreshEnabled`
711 |
712 | Boolean value that determines whether a pull to refresh gesture is available in the `WebView`. The default value is `false`. If `true`, sets `bounces` automatically to `true`.
713 |
714 | | Type | Required | Platform |
715 | | ------- | -------- | -------- |
716 | | boolean | No | iOS |
717 |
718 | ### `ignoreSilentHardwareSwitch`
719 |
720 | (ios only)
721 |
722 | When set to `true` the hardware silent switch is ignored. Default: `false`
723 |
724 | | Type | Required | Platform |
725 | | ------- | -------- | -------- |
726 | | boolean | No | iOS |
727 |
728 | ### `limitsNavigationsToAppBoundDomains`
729 |
730 | If `true` indicates to WebKit that a WKWebView will only navigate to app-bound domains. Only applicable for iOS 14 or greater.
731 |
732 | Once set, any attempt to navigate away from an app-bound domain will fail with the error “App-bound domain failure.”
733 | Applications can specify up to 10 “app-bound” domains using a new Info.plist key `WKAppBoundDomains`. For more information see [App-Bound Domains](https://webkit.org/blog/10882/app-bound-domains/).
734 |
735 | | Type | Required | Platform |
736 | | ------- | -------- | -------- |
737 | | boolean | No | iOS |
738 |
739 | ---
740 |
741 | ### `textInteractionEnabled`
742 |
743 | If false indicates to WebKit that a WKWebView will not interact with text, thus not showing a text selection loop. Only applicable for iOS 14.5 or greater.
744 |
745 | Defaults to `true`.
746 |
747 | | Type | Required | Platform |
748 | | ------- | -------- | -------- |
749 | | boolean | No | iOS |
750 |
751 | ---
752 |
753 | ### `suppressMenuItems`
754 |
755 | Allows to suppress menu item from the default context menu.
756 |
757 | Possible values are:
758 |
759 | - `cut`
760 | - `copy`
761 | - `paste`
762 | - `delete`
763 | - `select`
764 | - `selectAll`
765 | - `replace`
766 | - `lookup`
767 | - `translate`
768 | - `bold`
769 | - `italic`
770 | - `underline`
771 | - `share`
772 |
773 | | Type | Required | Default | Platform |
774 | | ---------------- | -------- | ------- | -------- |
775 | | array of strings | No | [] | iOS |
776 |
777 | ### `mediaCapturePermissionGrantType`
778 |
779 | This property specifies how to handle media capture permission requests. Defaults to `prompt`, resulting in the user being prompted repeatedly. Available on iOS 15 and later.
780 |
781 | Possible values:
782 |
783 | - `grantIfSameHostElsePrompt`: If the security origin's host of the permission request equals the host of the WebView's current URL, the permission is granted if it has been granted before. Otherwise, the user gets prompted.
784 | - `grantIfSameHostElseDeny`: If the security origin's host of the permission request equals the host of the WebView's current URL, the permission is granted if it has been granted before. Otherwise, it gets denied.
785 | - `deny`
786 | - `grant`: The permission is granted if it has been granted before.
787 | - `prompt`
788 |
789 | Note that a grant may still result in a prompt, for example if the user has never been prompted for the permission before.
790 |
791 | | Type | Required | Platform |
792 | | ------ | -------- | -------- |
793 | | string | No | iOS |
794 |
795 | ---
796 |
797 | ### `autoManageStatusBarEnabled`
798 |
799 | If set to `true`, the status bar will be automatically hidden/shown by WebView, specifically when full screen video is being watched. If `false`, WebView will not manage the status bar at all. The default value is `true`.
800 |
801 | | Type | Required | Platform |
802 | | ------- | -------- | -------- |
803 | | boolean | No | iOS |
804 |
805 | ### `setSupportMultipleWindows`
806 |
807 | Sets whether the WebView supports multiple windows. See [Android documentation](<'https://developer.android.com/reference/android/webkit/WebSettings#setSupportMultipleWindows(boolean)'>) for more information.
808 | Setting this to `false` can expose the application to this [vulnerability](https://alesandroortiz.com/articles/uxss-android-webview-cve-2020-6506/) allowing a malicious iframe to escape into the top layer DOM.
809 |
810 | | Type | Required | Default | Platform |
811 | | ------- | -------- | ------- | -------- |
812 | | boolean | No | true | Android |
813 |
814 | ### `enableApplePay`
815 |
816 | A Boolean value which, when set to `true`, WebView will be rendered with Apple Pay support. Once set, websites will be able to invoke Apple Pay from React Native Webview.
817 | This comes with a cost features like [`injectJavaScript`](README.md#injectjavascriptstr), html5 History, [`sharedCookiesEnabled`](README.md#sharedCookiesEnabled), [`injectedJavaScript`](README.md#injectedjavascript), [`injectedJavaScriptBeforeContentLoaded`](README.md#injectedjavascriptbeforecontentloaded) will not work See [Apple Pay Release Note](https://developer.apple.com/documentation/safari-release-notes/safari-13-release-notes#Payment-Request-API).
818 |
819 | If you are required to send message to App , webpage has to explicitly call webkit message handler and receive it on `onMessage` handler on react native side
820 |
821 | ```javascript
822 | window.webkit.messageHandlers.ReactNativeWebView.postMessage('hello apple pay');
823 | ```
824 |
825 | | Type | Required | Default | Platform |
826 | | ------- | -------- | ------- | -------- |
827 | | boolean | No | false | iOS |
828 |
829 | ### `forceDarkOn`
830 |
831 | Configuring Dark Theme
832 |
833 | _NOTE_ : The force dark setting is not persistent. You must call the static method every time your app process is started.
834 |
835 | _NOTE_ : The change from day<->night mode is a configuration change so by default the activity will be restarted and pickup the new values to apply the theme. Take care when overriding this default behavior to ensure this method is still called when changes are made.
836 |
837 | | Type | Required | Platform |
838 | | ------- | -------- | -------- |
839 | | boolean | No | Android |
840 |
841 | ### `menuItems`
842 |
843 | An array of custom menu item objects that will be shown when selecting text. An empty array will suppress the menu. Used in tandem with `onCustomMenuSelection`
844 |
845 | | Type | Required | Platform |
846 | | ---------------------------------------------- | -------- | ------------ |
847 | | array of objects: {label: string, key: string} | No | iOS, Android |
848 |
849 | ### `customMenuSelection`
850 |
851 | Function called when a custom menu item is selected. It receives a Native event, which includes three custom keys: `label`, `key` and `selectedText`.
852 |
853 | | Type | Required | Platform |
854 | | -------- | -------- | ------------ |
855 | | function | No | iOS, Android |
856 |
857 | ### `basicAuthCredential`
858 |
859 | An object that specifies the credentials of a user to be used for basic authentication.
860 |
861 | - `username` (string) - A username used for basic authentication.
862 | - `password` (string) - A password used for basic authentication.
863 |
864 | | Type | Required |
865 | | ------ | -------- |
866 | | object | No |
867 |
868 | ### `minimumFontSize`
869 |
870 | Android enforces a minimum font size based on this value. A non-negative integer between 1 and 72. Any number outside the specified range will be pinned. Default value is 8. If you are using smaller font sizes and are having trouble fitting the whole window onto one screen, try setting this to a smaller value.
871 |
872 | | Type | Required | Platform |
873 | | ------ | -------- | -------- |
874 | | number | No | Android |
875 |
876 | Example:
877 |
878 | ```jsx
879 |
880 | ```
881 |
882 | ### `downloadingMessage`
883 |
884 | This is the message that is shown in the Toast when downloading a file via WebView. Default message is "Downloading".
885 |
886 | | Type | Required | Platform |
887 | | ------ | -------- | -------- |
888 | | string | No | Android |
889 |
890 | ### `lackPermissionToDownloadMessage`
891 |
892 | This is the message that is shown in the Toast when the webview is unable to download a file. Default message is "Cannot download files as permission was denied. Please provide permission to write to storage, in order to download files.".
893 |
894 | | Type | Required | Platform |
895 | | ------ | -------- | -------- |
896 | | string | No | Android |
897 |
898 | ### `allowsProtectedMedia`
899 |
900 | Whether or not the Webview can play media protected by DRM. Default is `false`.
901 | ⚠️ Setting this to `false` won't revoke the permission already granted to the current webpage. In order to do so, you'd have to reload the page as well. ⚠️
902 |
903 | | Type | Required | Platform |
904 | | ------- | -------- | -------- |
905 | | boolean | No | Android |
906 |
907 | ### `fraudulentWebsiteWarningEnabled`
908 |
909 | A Boolean value that indicates whether the web view shows warnings for suspected fraudulent content, such as malware or phishing attempts. The default value is `true`. (iOS 13+)
910 |
911 | | Type | Required | Default | Platform |
912 | | ------- | -------- | ------- | -------- |
913 | | boolean | No | true | iOS |
914 |
915 | ### `webviewDebuggingEnabled`
916 |
917 | Whether or not the webview can be debugged remotely using Safari / Chrome.
918 | Default is `false`. Supported on iOS as of 16.4, previous versions always allow debugging by default.
919 |
920 | | Type | Required | Platform |
921 | | ------- | -------- | ------------- |
922 | | boolean | No | iOS & Android |
923 |
924 | ## Events
925 |
926 | ### `error`
927 |
928 | Event that is invoked when the `WebView` load fails.
929 |
930 | | Type | Required |
931 | | ----- | -------- |
932 | | Event | No |
933 |
934 | The `error` event is called with a `event.nativeEvent` with these properties:
935 |
936 | ```
937 | canGoBack
938 | canGoForward
939 | code
940 | description
941 | didFailProvisionalNavigation
942 | domain
943 | loading
944 | target
945 | title
946 | url
947 | ```
948 |
949 | ---
950 |
951 | ### `load`
952 |
953 | Event that is invoked when the `WebView` has finished loading.
954 |
955 | | Type | Required |
956 | | ----- | -------- |
957 | | Event | No |
958 |
959 | The `load` event is called with a `event.nativeEvent` with these properties:
960 |
961 | ```
962 | canGoBack
963 | canGoForward
964 | loading
965 | target
966 | title
967 | url
968 | ```
969 |
970 | ---
971 |
972 | ### `loadEnd`
973 |
974 | Event that is invoked when the `WebView` load succeeds or fails.
975 |
976 | | Type | Required |
977 | | ----- | -------- |
978 | | Event | No |
979 |
980 | The `loadEnd` event is called with a `event.nativeEvent` with these properties:
981 |
982 | ```
983 | canGoBack
984 | canGoForward
985 | loading
986 | target
987 | title
988 | url
989 | ```
990 |
991 | ---
992 |
993 | ### `loadingStart`
994 |
995 | Event that is invoked when the `WebView` starts loading.
996 |
997 | | Type | Required |
998 | | ----- | -------- |
999 | | Event | No |
1000 |
1001 | The `loadingStart` event is called with a `event.nativeEvent` with these properties:
1002 |
1003 | ```
1004 | canGoBack
1005 | canGoForward
1006 | loading
1007 | target
1008 | title
1009 | url
1010 | ```
1011 |
1012 | ---
1013 |
1014 | ### `loadingProgress`
1015 |
1016 | Event that is invoked when the `WebView` is loading.
1017 |
1018 | | Type | Required | Platform |
1019 | | ----- | -------- | ------------------- |
1020 | | Event | No | iOS, Android |
1021 |
1022 | The `loadingProgress` event is called with a `event.nativeEvent` with these properties:
1023 |
1024 | ```
1025 | canGoBack
1026 | canGoForward
1027 | loading
1028 | progress
1029 | target
1030 | title
1031 | url
1032 | ```
1033 |
1034 | ---
1035 |
1036 | ### `httpError`
1037 |
1038 | Event that is invoked when the `WebView` receives an http error.
1039 |
1040 | > **_Note_**
1041 | > Android API minimum level 23.
1042 |
1043 | | Type | Required |
1044 | | ----- | -------- |
1045 | | Event | No |
1046 |
1047 | The `httpError` event is called with a `event.nativeEvent` with these properties:
1048 |
1049 | ```
1050 | canGoBack
1051 | canGoForward
1052 | description
1053 | loading
1054 | statusCode
1055 | target
1056 | title
1057 | url
1058 | ```
1059 |
1060 | > **_Note_**
1061 | > Description is only used on Android
1062 |
1063 | ---
1064 |
1065 | ### `renderProcessGone`
1066 |
1067 | Event that is invoked when the `WebView` process crashes or is killed by the OS on Android.
1068 |
1069 | > **_Note_**
1070 | > Android API minimum level 26. Android Only
1071 |
1072 | | Type | Required |
1073 | | ----- | -------- |
1074 | | Event | No |
1075 |
1076 | The `renderProcressGone` event is called with a `event.nativeEvent` with these properties:
1077 |
1078 | ```
1079 | didCrash
1080 | ```
1081 |
1082 | ---
1083 |
1084 | ### `message`
1085 |
1086 | Function that is invoked when the webview calls `window.ReactNativeWebView.postMessage`. Setting this property will inject this global into your webview.
1087 |
1088 | `window.ReactNativeWebView.postMessage` accepts one argument, `data`, which will be available on the event object, `event.nativeEvent.data`. `data` must be a string.
1089 |
1090 | | Type | Required |
1091 | | ----- | -------- |
1092 | | Event | No |
1093 |
1094 | ---
1095 |
1096 | ### `navigationStateChange`
1097 |
1098 | Event that is invoked when the `WebView` loading starts or ends.
1099 |
1100 | | Type | Required |
1101 | | ----- | -------- |
1102 | | Event | No |
1103 |
1104 | The `navigationStateChange` event is called with the following properties:
1105 |
1106 | ```
1107 | canGoBack
1108 | canGoForward
1109 | loading
1110 | navigationType (iOS only)
1111 | target
1112 | title
1113 | url
1114 | ```
1115 |
1116 | ---
1117 |
1118 | ### `openWindow`
1119 |
1120 | Event that is invoked when the `WebView` should open a new window.
1121 |
1122 | This happens when the JS calls `window.open('http://someurl', '_blank')` or when the user clicks on a `` link.
1123 |
1124 | | Type | Required |
1125 | | ----- | -------- |
1126 | | Event | No |
1127 |
1128 | The `openWindow` event is called with a `event.nativeEvent` with these properties:
1129 |
1130 | ```
1131 | targetUrl
1132 | ```
1133 |
1134 | ---
1135 |
1136 | ### `contentProcessDidTerminate`
1137 |
1138 | Event that is invoked when the `WebView` content process is terminated.
1139 |
1140 | | Type | Required | Platform |
1141 | | ----- | -------- | ----------------------- |
1142 | | Event | No | iOS |
1143 |
1144 | iOS Web views use a separate process to render and manage web content. WebKit calls this method when the process for the specified web view terminates for any reason.
1145 | The reason is not necessarily a crash. For instance, since iOS WebViews are not included in the total RAM of the app, they can be terminated independently of the app to liberate memory for new apps the user is opening. It's not unexpected to have WebViews get terminated after a while in the background.
1146 |
1147 | The `contentProcessDidTerminate` event is called with a `event.nativeEvent` with these properties:
1148 |
1149 | ```
1150 | canGoBack
1151 | canGoForward
1152 | loading
1153 | target
1154 | title
1155 | url
1156 | ```
1157 |
1158 | ---
1159 |
1160 | ### `scroll`
1161 |
1162 | Event that is invoked when the scroll event is fired in the `WebView`.
1163 |
1164 | | Type | Required | Platform |
1165 | | ----- | -------- | ------------ |
1166 | | Event | No | iOS, Android |
1167 |
1168 | The `scroll` event is called with a `event.nativeEvent` with these properties:
1169 |
1170 | ```
1171 | contentInset
1172 | contentOffset
1173 | contentSize
1174 | layoutMeasurement
1175 | velocity
1176 | zoomScale
1177 | ```
1178 |
1179 | ---
1180 |
1181 | ### `shouldStartLoad`
1182 |
1183 | Event that allows custom handling of any web view requests. Set `event.nativeEvent.shouldStart = true` from the function to continue loading the request and `false` to stop loading.
1184 |
1185 | On Android, is not called on the first load.
1186 |
1187 | | Type | Required | Platform |
1188 | | -------- | -------- | ------------------- |
1189 | | Event | No | iOS, Android |
1190 |
1191 | The `event.nativeEvent` object includes these properties:
1192 |
1193 | ```
1194 | title
1195 | url
1196 | loading
1197 | target
1198 | canGoBack
1199 | canGoForward
1200 | lockIdentifier
1201 | mainDocumentURL (iOS only)
1202 | navigationType (iOS only)
1203 | isTopFrame (iOS only)
1204 | hasTargetFrame (iOS only)
1205 | shouldStart
1206 | ```
1207 |
1208 | The `hasTargetFrame` prop is a boolean that is `false` when the navigation targets a new window or tab, otherwise it should be `true` ([more info](https://developer.apple.com/documentation/webkit/wknavigationaction/1401918-targetframe)). Note that this prop should always be `true` when `onOpenWindow` event is registered on the WebView because the `false` case is intercepted by this event.
1209 |
1210 | ---
1211 |
1212 | ### `fileDownload`
1213 |
1214 | This property is iOS-only.
1215 |
1216 | Function that is invoked when the client needs to download a file.
1217 |
1218 | iOS 13+ only: If the webview navigates to a URL that results in an HTTP
1219 | response with a Content-Disposition header 'attachment...', then
1220 | this will be called.
1221 |
1222 | iOS 8+: If the MIME type indicates that the content is not renderable by the
1223 | webview, that will also cause this to be called. On iOS versions before 13,
1224 | this is the only condition that will cause this function to be called.
1225 |
1226 | The application will need to provide its own code to actually download
1227 | the file.
1228 |
1229 | If not provided, the default is to let the webview try to render the file.
1230 |
1231 | | Type | Required | Platform |
1232 | | ----- | -------- | -------- |
1233 | | Event | No | iOS |
1234 |
1235 | ---
1236 |
1237 | ## Methods
1238 |
1239 | ### `goForward()`
1240 |
1241 | ```javascript
1242 | goForward();
1243 | ```
1244 |
1245 | Go forward one page in the web view's history.
1246 |
1247 | ### `goBack()`
1248 |
1249 | ```javascript
1250 | goBack();
1251 | ```
1252 |
1253 | Go back one page in the web view's history.
1254 |
1255 | ### `reload()`
1256 |
1257 | ```javascript
1258 | reload();
1259 | ```
1260 |
1261 | Reloads the current page.
1262 |
1263 | ### `stopLoading()`
1264 |
1265 | ```javascript
1266 | stopLoading();
1267 | ```
1268 |
1269 | Stop loading the current page.
1270 |
1271 | ### `injectJavaScript(str)`
1272 |
1273 | ```javascript
1274 | injectJavaScript('... javascript string ...');
1275 | ```
1276 |
1277 | Executes the JavaScript string.
1278 |
1279 | To learn more, read the [Communicating between JS and Native](Guide.md#communicating-between-js-and-native) guide.
1280 |
1281 | ### `requestFocus()`
1282 |
1283 | ```javascript
1284 | requestFocus();
1285 | ```
1286 |
1287 | Request the webView to ask for focus. (People working on TV apps might want having a look at this!)
1288 |
1289 | ### `postMessage(str)`
1290 |
1291 | ```javascript
1292 | postMessage('message');
1293 | ```
1294 |
1295 | Post a message to WebView, handled by [`onMessage`](README.md#onmessage).
1296 |
1297 | ### `clearFormData()`
1298 |
1299 | (android only)
1300 |
1301 | ```javascript
1302 | clearFormData();
1303 | ```
1304 |
1305 | Removes the autocomplete popup from the currently focused form field, if present. [developer.android.com reference]()
1306 |
1307 | ### `clearCache(bool)`
1308 |
1309 | ```javascript
1310 | clearCache(true);
1311 | ```
1312 |
1313 | Clears the resource cache. Note that the cache is per-application, so this will clear the cache for all WebViews used. [developer.android.com reference]()
1314 |
1315 | In iOS, includeDiskFiles will also remove data from the web storages and databases.[developer.apple.com reference](https://developer.apple.com/documentation/webkit/wkwebsitedatastore/1532936-removedata)
1316 |
1317 | ### `clearHistory()`
1318 |
1319 | (android only)
1320 |
1321 | ```javascript
1322 | clearHistory();
1323 | ```
1324 |
1325 | ## License
1326 |
1327 | Apache License Version 2.0
1328 |
--------------------------------------------------------------------------------
/apps/demo-angular/.eslintrc.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": ["../../.eslintrc.json"],
3 | "ignorePatterns": ["!**/*", "node_modules/**/*"],
4 | "overrides": [
5 | {
6 | "files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
7 | "rules": {}
8 | },
9 | {
10 | "files": ["*.ts", "*.tsx"],
11 | "rules": {}
12 | },
13 | {
14 | "files": ["*.js", "*.jsx"],
15 | "rules": {}
16 | }
17 | ]
18 | }
19 |
--------------------------------------------------------------------------------
/apps/demo-angular/.gitignore:
--------------------------------------------------------------------------------
1 | hooks
2 | platforms
3 | !webpack.config.js
--------------------------------------------------------------------------------
/apps/demo-angular/nativescript.config.ts:
--------------------------------------------------------------------------------
1 | import { NativeScriptConfig } from '@nativescript/core';
2 |
3 | export default {
4 | id: 'org.nativescript.plugindemoangular',
5 | appResourcesPath: '../../tools/assets/App_Resources',
6 | android: {
7 | v8Flags: '--expose_gc',
8 | markingMode: 'none',
9 | },
10 | appPath: 'src',
11 | cli: {
12 | packageManager: 'npm'
13 | }
14 | } as NativeScriptConfig;
15 |
--------------------------------------------------------------------------------
/apps/demo-angular/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "main": "./src/main.ts",
3 | "dependencies": {
4 | "@nativescript/core": "file:../../node_modules/@nativescript/core",
5 | "@ammarahmed/nativescript-webview": "file:../../dist/packages/nativescript-webview",
6 | "@open-native/core": "2.0.0-alpha.22",
7 | "react-native-webview": "13.6.3"
8 | },
9 | "devDependencies": {
10 | "@nativescript/android": "~8.6.0",
11 | "@nativescript/ios": "~8.6.0"
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/apps/demo-angular/project.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "demo-angular",
3 | "$schema": "../../node_modules/nx/schemas/project-schema.json",
4 | "sourceRoot": "apps/demo-angular/src",
5 | "projectType": "application",
6 | "prefix": "demo",
7 | "targets": {
8 | "build": {
9 | "executor": "@nativescript/nx:build",
10 | "options": {
11 | "noHmr": true,
12 | "production": true,
13 | "uglify": true,
14 | "release": true,
15 | "forDevice": true
16 | },
17 | "dependsOn": [
18 | {
19 | "target": "build.all",
20 | "projects": "dependencies"
21 | }
22 | ]
23 | },
24 | "ios": {
25 | "executor": "@nativescript/nx:build",
26 | "options": {
27 | "platform": "ios"
28 | },
29 | "dependsOn": [
30 | {
31 | "target": "build.all",
32 | "projects": "dependencies"
33 | }
34 | ]
35 | },
36 | "android": {
37 | "executor": "@nativescript/nx:build",
38 | "options": {
39 | "platform": "android"
40 | },
41 | "dependsOn": [
42 | {
43 | "target": "build.all",
44 | "projects": "dependencies"
45 | }
46 | ]
47 | },
48 | "clean": {
49 | "executor": "@nativescript/nx:build",
50 | "options": {
51 | "clean": true
52 | }
53 | },
54 | "lint": {
55 | "executor": "@nrwl/linter:eslint",
56 | "options": {
57 | "lintFilePatterns": ["apps/demo-angular/**/*.ts"]
58 | }
59 | }
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/apps/demo-angular/references.d.ts:
--------------------------------------------------------------------------------
1 | ///
2 |
--------------------------------------------------------------------------------
/apps/demo-angular/src/app-routing.module.ts:
--------------------------------------------------------------------------------
1 | import { NgModule } from '@angular/core';
2 | import { Routes } from '@angular/router';
3 | import { NativeScriptRouterModule } from '@nativescript/angular';
4 |
5 | import { HomeComponent } from './home.component';
6 |
7 | const routes: Routes = [
8 | { path: '', redirectTo: '/home', pathMatch: 'full' },
9 | { path: 'home', component: HomeComponent },
10 | { path: 'nativescript-webview', loadChildren: () => import('./plugin-demos/nativescript-webview.module').then((m) => m.NativescriptWebviewModule) },
11 | ];
12 |
13 | @NgModule({
14 | imports: [NativeScriptRouterModule.forRoot(routes)],
15 | exports: [NativeScriptRouterModule],
16 | })
17 | export class AppRoutingModule {}
18 |
--------------------------------------------------------------------------------
/apps/demo-angular/src/app.component.ts:
--------------------------------------------------------------------------------
1 | import { Component } from '@angular/core';
2 |
3 | @Component({
4 | selector: 'demo-app',
5 | template: `
6 |
7 | `,
8 | })
9 | export class AppComponent {}
10 |
--------------------------------------------------------------------------------
/apps/demo-angular/src/app.module.ts:
--------------------------------------------------------------------------------
1 | import { NgModule, NO_ERRORS_SCHEMA } from '@angular/core';
2 | import { NativeScriptModule } from '@nativescript/angular';
3 |
4 | import { AppComponent } from './app.component';
5 | import { AppRoutingModule } from './app-routing.module';
6 | import { HomeComponent } from './home.component';
7 | import { NativeScriptWebViewModule } from '@ammarahmed/nativescript-webview/angular';
8 |
9 | @NgModule({
10 | schemas: [NO_ERRORS_SCHEMA],
11 | declarations: [AppComponent, HomeComponent],
12 | bootstrap: [AppComponent],
13 | imports: [NativeScriptModule, NativeScriptWebViewModule, AppRoutingModule],
14 | })
15 | export class AppModule {}
16 |
--------------------------------------------------------------------------------
/apps/demo-angular/src/app.scss:
--------------------------------------------------------------------------------
1 | @import 'nativescript-theme-core/scss/light';
2 | @import 'nativescript-theme-core/scss/index';
3 |
4 | button, label, stack-layout {
5 | horizontal-align: center;
6 | }
7 |
8 | button {
9 | font-size: 36;
10 | }
11 |
12 | .title {
13 | font-size: 30;
14 | margin: 20;
15 | }
16 |
17 | .message {
18 | font-size: 20;
19 | color: #284848;
20 | text-align: center;
21 | margin: 0 20;
22 | }
23 |
--------------------------------------------------------------------------------
/apps/demo-angular/src/assets/test.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Hello, World!
5 |
6 |
7 |