browser
The sos.browser
API groups together methods for working with the integrated web browser.
info
This API is currently available on:
- Android devices with Android 5+ (Philips, Benq, Sharp, generic Android device)
With some limitation you can use this API also on
- Samsung Tizen (SSSP 4 and above); where the website is just in fullscreen without an address bar or theme options (headless mode)
- LG webOS (webOS 3.0 and above); where the website is just in fullscreen without an address bar or theme options (headless mode)
- Linux (Fedora, Ubuntu), Raspberry Pi, NEC Compute Module; where the website is just in fullscreen without an address bar or theme options (headless mode)
- BrightSign; where the website is just in fullscreen without an address bar or theme options (headless mode)
Methods
close()
The close()
method closes the browser window opened by the open()
method.
close(): Promise<void>;
onClose()
The onClose()
method sets up a listener, which is called whenever a browser window is closed. This can happen by an API call, by a
user request or after a timeout. This doesn't fire between open
calls or on subsequent close
calls.
onClose(listener: (event: CloseEvent) => void): () => void;
Return value
A callback which removes the listener.
open()
The open()
method opens the specified url in a browser window.
open(uri: string, options?: IOpenLinkOptions): Promise<void>;
Params
Name | Type | Description |
---|---|---|
options.aclDomains (optional) | string[] | List of domains to be interpreted according to aclMode . |
options.aclMode (optional) | "blacklist" | "whitelist" | Either "blacklist" or "whitelist". |
options.readOnlyAddressBar (optional) | boolean | Should the address bar be readonly. |
options.idleTimeout (optional) | number | Close browser after specified period if idle. |
options.coordinates (optional) | { x: number; y: number; width: number; height: number; } | Size and position of the browser window. Defaults to fullscreen. |
options.theme (optional) | ITheme | Specify custom UI theme. (Android only) |
options.headlessMode (optional) | boolean | Headless mode hides the entire address bar. (Android only) |
options.canUserClose (optional) | boolean | Whether the user can manually close the browser. (default if headless false, else true) |
options.clearData (optional) | boolean | Clear cache after the browser closes. (default if headless false, else true) |
options.method (optional) | "native" | "iframe" | Either "native" or "iframe" |
Example
sos.browser.open('https://www.signageos.io', {
aclDomains: ['google.com', 'yahoo.com'],
aclMode: 'blacklist', // or 'whitelist'
readOnlyAddressBar: true,
coordinates: { // Supported only on Linux and Android
x: 0,
y: 0,
height: 500,
width: 500,
},
// theme: { ... }
headlessMode: false,
});
openLink()
Deprecated
This method was deprecated. use sos.browser.open()
instead
openLink(uri: string, options?: IDeprecatedOpenLinkOptions): Promise<void>;
API Example
import { sos } from '@signageos/front-applet';
void sos.onReady(async () => {
await sos.browser.open('https://www.signageos.io', {
aclDomains: ['google.com', 'yahoo.com'],
aclMode: 'blacklist', // or 'whitelist'
readOnlyAddressBar: true,
coordinates: {
// Supported only on Linux and Android
x: 0,
y: 0,
height: 500,
width: 500,
},
// theme: { ... } // supported only on Android
headlessMode: false, // supported only on Android
});
await sos.browser.close(); // Close the browser
});