# Modules.WebDialog
Allows a Titanium application to use the Safari Controller (iOS) and Chrome Tabs (Android) to create an embedded browser.
# Overview
The WebDialog module provides Titanium access to the native SFSafariViewController
(iOS) and ChromeTabs
(Android).
This enables you to deliver interactive web content in your app just like the built-in browser, including the native UI elements already
familiar to your users.
# Requirements
The WebDialog module is available with the Titanium SDK starting with Release 7.1.0. This module only works with devices running iOS 9 / Android 4.1 and later. Please make sure you have at least Xcode 7 to build to the required iOS sources.
# Getting Started
Add the module as a dependency to your application by adding a <module>
item to the
<modules>
element of your tiapp.xml
file:
<ti:app>
<!-- ... -->
<modules>
<module platform="iphone">ti.webdialog</module>
</modules>
<!-- ... -->
</ti:app>
Use require()
to access the module from JavaScript:
var dialog = require('ti.webdialog');
The dialog
variable is a reference to the module. Make API calls using this reference:
if (dialog.isSupported()) {
dialog.open({
url: 'https://appcelerator.com'
});
}
# Sample Application
The module contains a sample application in the
<TITANIUM_SDK_HOME>/modules/iphone/ti.webdialog/<VERSION>/example/
folder.
# Methods
# close
Programmatically closes the web dialog.
var dialog = require('ti.webdialog');
if (dialog.isOpen()) {
dialog.close();
}
Returns
- Type
- void
# createAuthenticationSession
Creates and returns an instance of Modules.WebDialog.AuthenticationSession.
Parameters
Name | Type | Description |
---|---|---|
parameters | Dictionary<Modules.WebDialog.AuthenticationSession> | Properties to set on a new object, including any defined by Modules.WebDialog.AuthenticationSession except those marked not-creation or read-only. |
Returns
# isSupported
Indicates if the web dialog is supported.
Returns
- Type
- Boolean
# open
Opens the web dialog with the options provided.
var dialog = require('ti.webdialog');
if (dialog.isSupported()) {
dialog.open({
url: 'https://appcelerator.com',
title: 'Hello World',
tintColor: 'red'
});
}
Parameters
Name | Type | Description |
---|---|---|
params | WebDialogOpenParams | Dictionary used to configure the web dialog. |
Returns
- Type
- void
# Events
# open
The open event is fired after the web dialog has opened.
Properties
Name | Type | Description |
---|---|---|
url | String | The URL provided when opening the web dialog. |
source | Object | Source object that fired the event. |
type | String | Name of the event fired. |
bubbles | Boolean | True if the event will try to bubble up if possible. |
cancelBubble | Boolean | Set to true to stop the event from bubbling. |
# close
The close event is fired when the web dialog is closed by the user or programmatically.
Properties
Name | Type | Description |
---|---|---|
url | String | The URL provided when opening the web dialog. |
source | Object | Source object that fired the event. |
type | String | Name of the event fired. |
bubbles | Boolean | True if the event will try to bubble up if possible. |
cancelBubble | Boolean | Set to true to stop the event from bubbling. |
# load
Fired when the initial URL load is complete.
This event is invoked when the erb dialog completes the loading of the URL that you pass to it's initializer. It is not invoked for any subsequent page loads in the same web dialog instance.
Properties
Name | Type | Description |
---|---|---|
url | String | The URL provided when opening the web dialog. |
success | Boolean | Returns |
source | Object | Source object that fired the event. |
type | String | Name of the event fired. |
bubbles | Boolean | True if the event will try to bubble up if possible. |
cancelBubble | Boolean | Set to true to stop the event from bubbling. |
# redirect
Fired when the browser is redirected to another URL before the first page load finishes.
Properties
Name | Type | Description |
---|---|---|
url | String | The URL provided when opening the web dialog. |
source | Object | Source object that fired the event. |
type | String | Name of the event fired. |
bubbles | Boolean | True if the event will try to bubble up if possible. |
cancelBubble | Boolean | Set to true to stop the event from bubbling. |
# Constants
# DISMISS_BUTTON_STYLE_CANCEL
Button style used to display a localized "Cancel" button.
Use with the dismissButtonStyle
property in open.