Skip to content

Modules.WebDialog

Allows a Titanium application to use the Safari Controller (iOS) and Chrome Tabs (Android) to create an embedded browser.

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://titaniumsdk.com'
    });
}

Sample Application

The module contains a sample application in the <TITANIUM_SDK_HOME>/modules/iphone/ti.webdialog/<VERSION>/example/ folder.

Extends: Titanium.Module · Since: 7.1.0 · Platforms: iphone, ipad, android

Properties #

DISMISS_BUTTON_STYLE_CANCEL#

Type: Number

Button style used to display a localized "Cancel" button.

Use with the dismissButtonStyle property in Modules.WebDialog.open.

DISMISS_BUTTON_STYLE_CLOSE#

Type: Number

Button style used to display a localized "Close" button.

Use with the dismissButtonStyle property in Modules.WebDialog.open.

DISMISS_BUTTON_STYLE_DONE#

Type: Number

Button style used to display a localized "Done" button.

Use with the dismissButtonStyle property in Modules.WebDialog.open.

Methods #

close #

Programmatically closes the web dialog.

var dialog = require('ti.webdialog');
if (dialog.isOpen()) {
    dialog.close();
}

isOpen #

Indicates if the web dialog is open.

Returns: Boolean

isSupported #

Indicates if the web dialog is supported.

Returns: Boolean

open #

Opens the web dialog with the options provided.

var dialog = require('ti.webdialog');
if (dialog.isSupported()) {
    dialog.open({
        url: 'https://titaniumsdk.com',
        tintColor: 'red'
    });
}
Parameters:
NameTypeSummaryOptional
paramsWebDialogOpenParamsDictionary used to configure the web dialog.No

Events #

close #

The close event is fired when the web dialog is closed by the user
or programmatically.

Event Properties:
NameTypeSummary
urlStringThe URL provided when opening the web dialog.

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.

Event Properties:
NameTypeSummary
urlStringThe URL provided when opening the web dialog.
successBooleanReturns true if loading completed successfully, false otherwise.

open #

The open event is fired after the web dialog has opened.

Event Properties:
NameTypeSummary
urlStringThe URL provided when opening the web dialog.

redirect #

Fired when the browser is redirected to another URL before the first page load finishes.

Event Properties:
NameTypeSummary
urlStringThe URL provided when opening the web dialog.

Titanium SDK Documentation