Object “app”
Object
> NativeObject
> App
Provides information about the application.
Constructor | private |
Singleton | app |
Namespace | tabris |
Direct subclasses | None |
JSX support | No |
See also:
JSX Displaying app properties
JSX Displaying app events
JSX Launching an url
JS Register and use an external font
Methods
close()
Android
Shuts down the running application and closes the UI.
Returns void
getResourceLocation(path)
Returns the URL for a given resource that is bundled with the app. Can be used to access app resources like images, videos, etc. Note that these resources can only be accessed in read-only mode.
Parameter | Type | Optional | Description |
---|---|---|---|
path | string |
No | The path of a resource relative to the application root. |
Returns string
launch(url)
Asks the operating system to open the given URL in an external app. Operating systems usually support a variety of URL schemes including http
, https
, mailto
, tel
, and sms
. Apps can also register for custom URL schemes.
Parameter | Type | Optional | Description |
---|---|---|---|
url | string |
No | The URL to launch. |
Returns Promise<void>
See also:
registerFont(alias, file)
Allows to register a font to use throughout the app. Once a font is registered its alias can be used to apply the font where ever a font can be configured, e.g. in TextView
or GraphicalContext
. Tabris.js supports TrueType fonts (.ttf) and OpenType fonts (.otf).
Parameter | Type | Optional | Description |
---|---|---|---|
alias | string |
No | An identifier for the registered font. The alias can be used as a font family, e.g. in the font properties of TextView and Button . |
file | string |
No | The font file to register for later use. Similar to images paths, the file path can be absolute, relative or an URL. |
Returns void
reload(url?)
Closes the running application and either loads a different app at the given url
or reloads the current app when no url
is given.
Parameter | Type | Optional | Description |
---|---|---|---|
url | string |
Yes | An optional url to an app to launch |
Returns void
Properties
debugBuild
Returns false
if this app was build build in production mode, otherwise true
. In production mode no debugger can be attached to the JavaScript VM.
Type | boolean |
Settable | No |
Change events | No |
This property can only be set via constructor. Once set, it cannot change anymore.
id
Uniquely identifies the app.
Type | string |
Settable | No |
Change events | No |
This property can only be set via constructor. Once set, it cannot change anymore.
pinnedCertificates
Enables certificate pinning for HTTP requests. When pinned certificates are defined for a host, connections to this host will only be permitted if the server provides a matching certificate. Connections to hosts that are not in the list are not affected.
Certificate pinning affects the following components: XHR/fetch, WebSockets and image loading. It does not affect WebViews.
The list of pinned certificates has to be in the form of [{host: <string>, hash: <string>, algorithm: <RSA2048|RSA4096|ECDSA256>}, ..]
.
- The
host
attribute denotes the host name (including subdomain) of the host to be pinned (wildcards allowed). - The
hash
attribute is the base64 encoded sha256 fingerprint of the subjectPublicKeyInfo, prefixed withsha256/
. - The
algorithm
attribute denotes the public key algorithm of the SSL certificate and can have the valuesRSA2048
,RSA4096
orECDSA256
. This attribute is only required on iOS.
Example: [{host: 'freegeoip.net', hash: 'sha256/+SVYjThgePRQxQ0e8bWTQDRtPYR/xBRufqyMoeaWteo=', algorithm: 'ECDSA256'}]
For further details see https://www.owasp.org/index.php/Certificate_and_Public_Key_Pinning.
Type | any[] |
Settable | Yes |
Change events | Yes |
trustedCertificates
Adds a set of certificates to validated ssl connections against. The certificates are applied in addition to the system wide default certificates.
The ArrayBuffer
entries of the trustedCertificates
array consist of the bytes of the certificate files. On Android the certificate file has to be a *.pem (Privacy Enhanced Mail) file whereas on iOS it has to be *.der (Distinguished Encoding Rules) file.
Type | ArrayBuffer[] |
Settable | Yes |
Change events | Yes |
version
The user facing version number, e.g. ‘2.1-beta3’.
Type | string |
Settable | No |
Change events | No |
This property can only be set via constructor. Once set, it cannot change anymore.
versionCode
An alternative version number used in app stores to identify different versions of an app. Usually incremented with each release. This property reflects the versionCode
on Android and CFBundleVersion
on iOS.
Type | number |
Settable | No |
Change events | No |
This property can only be set via constructor. Once set, it cannot change anymore.
Events
foreground
The event is fired when the app starts or when it returns from the background.
resume
Fired when the app is visible and ready to interact with the user. The event is preceded by either foreground
(the app becomes visible again) or pause
(the app regains ability to interact with user).
pause
Fired when the app is not the interaction target of the user anymore. Usually preceded by resume
.
background
Fired when the app becomes invisible. Either because another app is in the foreground or the user has returned to the home screen.
terminate
Fired when the app is being destroyed. After this callback no more interaction with the app is possible.
backNavigation
Fired when the back button is pressed on Android.
Parameter | Type | Description |
---|---|---|
preventDefault | () => void |
Call to suppress the default back navigation behavior. |
Change Events
pinnedCertificatesChanged
Fired when the pinnedCertificates property has changed.
Parameter | Type | Description |
---|---|---|
value | any[] |
The new value of pinnedCertificates. |
trustedCertificatesChanged
Fired when the trustedCertificates property has changed.
Parameter | Type | Description |
---|---|---|
value | ArrayBuffer[] |
The new value of trustedCertificates. |