UNPKG

13 kBTypeScriptView Raw
1import { IonicNativePlugin } from '@ionic-native/core';
2import { Observable } from 'rxjs';
3export interface InAppBrowserOptions {
4 /**
5 * (iOS Only) Set to yes or no to allow in-line HTML5 media playback, displaying within the browser window rather than a device-specific playback interface.
6 * The HTML's video element must also include the webkit-playsinline attribute (defaults to no)
7 */
8 allowInlineMediaPlayback?: 'yes' | 'no';
9 /**
10 * set to enable the beforeload event to modify which pages are actually loaded in the browser. Accepted values are get to
11 * intercept only GET requests, post to intercept on POST requests or yes to intercept both GET & POST requests.
12 * Note that POST requests are not currently supported and will be ignored (if you set beforeload=post it will raise an error).
13 */
14 beforeload?: 'yes' | 'get' | 'post';
15 /** Set to yes to have the browser's cookie cache cleared before the new window is opened. */
16 clearcache?: 'yes' | 'no';
17 /** set to yes to have the browser's entire local storage cleared (cookies, HTML5 local storage, IndexedDB, etc.) before the new window is opened */
18 cleardata?: 'yes' | 'no';
19 /**
20 * Set to yes to have the session cookie cache cleared before the new window is opened.
21 * For WKWebView, requires iOS 11+ on target device.
22 */
23 clearsessioncache?: 'yes' | 'no';
24 /**
25 * (Android) Set to a string to use as the close button's caption instead of a X. Note that you need to localize this value yourself.
26 * (iOS) Set to a string to use as the Done button's caption. Note that you need to localize this value yourself.
27 */
28 closebuttoncaption?: string;
29 /**
30 * (Android) Set to a valid hex color string, for example: #00ff00, and it will change the close button color from default, regardless of being a text or default X. Only has effect if user has location set to yes.
31 * (iOS) Set as a valid hex color string, for example: #00ff00, to change from the default Done button's color. Only applicable if toolbar is not disabled.
32 */
33 closebuttoncolor?: string;
34 /** (iOS Only) Set to yes or no (default is no). Turns on/off the UIWebViewBounce property. */
35 disallowoverscroll?: 'yes' | 'no';
36 /** (iOS Only) Set to yes or no to prevent viewport scaling through a meta tag (defaults to no). */
37 enableViewportScale?: 'yes' | 'no';
38 /** (Android Only) Set to yes to show a close button in the footer similar to the iOS Done button. The close button will appear the same as for the header hence use closebuttoncaption and closebuttoncolor to set its properties */
39 footer?: 'yes' | 'no';
40 /** (Android Only) Set to a valid hex color string, for example #00ff00 or #CC00ff00 (#aarrggbb), and it will change the footer color from default. Only has effect if user has footer set to yes */
41 footercolor?: string;
42 /**
43 * (Windows only) Set to yes to create the browser control without a border around it.
44 * Please note that if location=no is also specified, there will be no control presented to user to close IAB window.
45 */
46 fullscreen?: 'yes' | 'no';
47 /**
48 * (Android & Windows Only) Set to yes to use the hardware back button to navigate backwards through the InAppBrowser's history.
49 * If there is no previous page, the InAppBrowser will close. The default value is yes, so you must set it to no if you want the back button to simply close the InAppBrowser.
50 */
51 hardwareback?: 'yes' | 'no';
52 /**
53 * Set to yes to create the browser and load the page, but not show it. The loadstop event fires when loading is complete.
54 * Omit or set to no (default) to have the browser open and load normally.
55 */
56 hidden?: 'yes' | 'no';
57 /**
58 * (Android) Set to yes to hide the navigation buttons on the location toolbar, only has effect if user has location set to yes. The default value is no.
59 * (iOS) Set to yes or no to turn the toolbar navigation buttons on or off (defaults to no). Only applicable if toolbar is not disabled.
60 */
61 hidenavigationbuttons?: 'yes' | 'no';
62 /**
63 * (iOS Only) Set to yes or no to change the visibility of the loading indicator (defaults to no).
64 */
65 hidespinner?: 'yes' | 'no';
66 /** (Android) Set to yes to hide the url bar on the location toolbar, only has effect if user has location set to yes. The default value is no. */
67 hideurlbar?: 'yes' | 'no';
68 /** (iOS Only) Set to yes or no to open the keyboard when form elements receive focus via JavaScript's focus() call (defaults to yes). */
69 keyboardDisplayRequiresUserAction?: 'yes' | 'no';
70 /**
71 * (Android) Set to yes to swap positions of the navigation buttons and the close button. Specifically, navigation buttons go to the left and close button to the right.
72 * (iOS) Set to yes to swap positions of the navigation buttons and the close button. Specifically, close button goes to the right and navigation buttons to the left.
73 */
74 lefttoright?: 'yes' | 'no';
75 /** Set to yes or no to turn the InAppBrowser's location bar on or off. */
76 location?: 'yes' | 'no';
77 /**
78 * Set to yes to prevent HTML5 audio or video from autoplaying (defaults to no).
79 */
80 mediaPlaybackRequiresUserAction?: 'yes' | 'no';
81 /**
82 * (Android) Set to a valid hex color string, for example: #00ff00, and it will change the color of both navigation buttons from default. Only has effect if user has location set to yes and not hidenavigationbuttons set to yes.
83 * (iOS) Set as a valid hex color string, for example: #00ff00, to change from the default color. Only applicable if navigation buttons are visible.
84 */
85 navigationbuttoncolor?: string;
86 /** (iOS Only) Set to pagesheet, formsheet or fullscreen to set the presentation style (defaults to fullscreen). */
87 presentationstyle?: 'pagesheet' | 'formsheet' | 'fullscreen';
88 /** (Android Only) Set to yes to make InAppBrowser WebView to pause/resume with the app to stop background audio (this may be required to avoid Google Play issues) */
89 shouldPauseOnSuspend?: 'yes' | 'no';
90 /** (iOS Only) Set to yes or no to wait until all new view content is received before being rendered (defaults to no). */
91 suppressesIncrementalRendering?: 'yes' | 'no';
92 /** (iOS Only) Set to yes or no to turn the toolbar on or off for the InAppBrowser (defaults to yes) */
93 toolbar?: 'yes' | 'no';
94 /**
95 * (Android) Set to a valid hex color string, for example: #00ff00, and it will change the color the toolbar from default. Only has effect if user has location set to yes.
96 * (iOS) Set as a valid hex color string, for example: #00ff00, to change from the default color of the toolbar. Only applicable if toolbar is not disabled.
97 */
98 toolbarcolor?: string;
99 /** (iOS Only) Set to top or bottom (default is bottom). Causes the toolbar to be at the top or bottom of the window. */
100 toolbarposition?: 'top' | 'bottom';
101 /** (iOS Only) Set to yes or no to make the toolbar translucent(semi-transparent) (defaults to yes). Only applicable if toolbar is not disabled. */
102 toolbartranslucent?: 'yes' | 'no';
103 /** (iOS Only) Set to fliphorizontal, crossdissolve or coververtical to set the transition style (defaults to coververtical). */
104 transitionstyle?: 'fliphorizontal' | 'crossdissolve' | 'coververtical';
105 /** (Android Only) Sets whether the WebView should enable support for the "viewport" HTML meta tag or should use a wide viewport. When the value of the setting is no, the layout width is always set to the width of the WebView control in device-independent (CSS) pixels. When the value is yes and the page contains the viewport meta tag, the value of the width specified in the tag is used. If the page does not contain the tag or does not provide a width, then a wide viewport will be used. (defaults to yes). */
106 useWideViewPort?: 'yes' | 'no';
107 /** (iOS Only) Set to yes to use WKWebView engine for the InappBrowser. Omit or set to no (default) to use UIWebView. */
108 usewkwebview?: 'yes' | 'no';
109 /** (Android Only) Set to yes to show Android browser's zoom controls, set to no to hide them. Default value is yes. */
110 zoom?: 'yes' | 'no';
111 /**
112 * @hidden
113 */
114 [key: string]: any;
115}
116export declare type InAppBrowserEventType = 'loadstart' | 'loadstop' | 'loaderror' | 'exit' | 'beforeload' | 'message' | 'customscheme';
117export interface InAppBrowserEvent extends Event {
118 /** the event name */
119 type: string;
120 /** the URL that was loaded. */
121 url: string;
122 /** the error code, only in the case of loaderror. */
123 code: number;
124 /** the error message, only in the case of loaderror. */
125 message: string;
126 /** the postMessage data, only in the case of message. */
127 data: any;
128}
129/**
130 * @hidden
131 */
132export declare class InAppBrowserObject {
133 private _objectInstance;
134 /**
135 * Opens a URL in a new InAppBrowser instance, the current browser instance, or the system browser.
136 * @param {string} url The URL to load.
137 * @param {string} [target="self"] The target in which to load the URL, an optional parameter that defaults to _self.
138 * _self: Opens in the WebView if the URL is in the white list, otherwise it opens in the InAppBrowser.
139 * _blank: Opens in the InAppBrowser.
140 * _system: Opens in the system's web browser.
141 * @param {string | InAppBrowserOptions} [options] Options for the InAppBrowser. Optional, defaulting to: location=yes.
142 * The options string must not contain any blank space, and each feature's
143 * name/value pairs must be separated by a comma. Feature names are case insensitive.
144 */
145 constructor(url: string, target?: string, options?: string | InAppBrowserOptions);
146 /**
147 * Method to be called after the "beforeload" event to continue the script
148 * @param strUrl {String} The URL the InAppBrowser should navigate to.
149 */
150 _loadAfterBeforeload(strUrl: string): void;
151 /**
152 * Displays an InAppBrowser window that was opened hidden. Calling this has no effect
153 * if the InAppBrowser was already visible.
154 */
155 show(): void;
156 /**
157 * Closes the InAppBrowser window.
158 */
159 close(): void;
160 /**
161 * Hides an InAppBrowser window that is currently shown. Calling this has no effect
162 * if the InAppBrowser was already hidden.
163 */
164 hide(): void;
165 /**
166 * Injects JavaScript code into the InAppBrowser window.
167 * @param script {Object} Details of the script to run, specifying either a file or code key.
168 * @returns {Promise<any>}
169 */
170 executeScript(script: {
171 file?: string;
172 code?: string;
173 }): Promise<any>;
174 /**
175 * Injects CSS into the InAppBrowser window.
176 * @param css {Object} Details of the script to run, specifying either a file or code key.
177 * @returns {Promise<any>}
178 */
179 insertCSS(css: {
180 file?: string;
181 code?: string;
182 }): Promise<any>;
183 /**
184 * A method that allows you to listen to events happening in the browser.
185 * @param event {InAppBrowserEventType} Name of the event
186 * @returns {Observable<InAppBrowserEvent>} Returns back an observable that will listen to the event on subscribe, and will stop listening to the event on unsubscribe.
187 */
188 on(event: InAppBrowserEventType): Observable<InAppBrowserEvent>;
189}
190/**
191 * @name In App Browser
192 * @premier inappbrowser
193 * @description Launches in app Browser
194 * @usage
195 * ```typescript
196 * import { InAppBrowser } from '@ionic-native/in-app-browser/ngx';
197 *
198 * constructor(private iab: InAppBrowser) { }
199 *
200 *
201 * ...
202 *
203 *
204 * const browser = this.iab.create('https://ionicframework.com/');
205 *
206 * browser.executeScript(...);
207 *
208 * browser.insertCSS(...);
209 * browser.on('loadstop').subscribe(event => {
210 * browser.insertCSS({ code: "body{color: red;" });
211 * });
212 *
213 * browser.close();
214 *
215 * ```
216 * @classes
217 * InAppBrowserObject
218 * @interfaces
219 * InAppBrowserEvent
220 * InAppBrowserOptions
221 */
222export declare class InAppBrowserOriginal extends IonicNativePlugin {
223 /**
224 * Opens a URL in a new InAppBrowser instance, the current browser instance, or the system browser.
225 * @param url {string} The URL to load.
226 * @param target {string} The target in which to load the URL, an optional parameter that defaults to _self.
227 * @param options {string} Options for the InAppBrowser. Optional, defaulting to: location=yes.
228 * The options string must not contain any blank space, and each feature's
229 * name/value pairs must be separated by a comma. Feature names are case insensitive.
230 * @returns {InAppBrowserObject}
231 */
232 create(url: string, target?: string, options?: string | InAppBrowserOptions): InAppBrowserObject;
233}
234
235export declare const InAppBrowser: InAppBrowserOriginal;
\No newline at end of file