# Modules.WebDialog

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

Availability
7.1.0
7.1.0

# 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

Availability
7.1.0
7.1.0
close() void

Programmatically closes the web dialog.

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

Returns

Type
void

# createAuthenticationSession

Availability
7.1.0
createAuthenticationSession([parameters]) Modules.WebDialog.AuthenticationSession

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


# isOpen

Availability
7.1.0
isOpen() Boolean

Indicates if the web dialog is open.

Returns

Type
Boolean

# isSupported

Availability
7.1.0
7.1.0
isSupported() Boolean

Indicates if the web dialog is supported.

Returns

Type
Boolean

# open

Availability
7.1.0
7.1.0
open(params) void

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

Availability
7.1.0

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

Availability
7.1.0

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

Availability
7.1.0

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 true if loading completed successfully, false otherwise.

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

Availability
7.1.0

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

Availability
7.1.0
DISMISS_BUTTON_STYLE_CANCEL :Number

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

Use with the dismissButtonStyle property in open.


# DISMISS_BUTTON_STYLE_CLOSE

Availability
7.1.0
DISMISS_BUTTON_STYLE_CLOSE :Number

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

Use with the dismissButtonStyle property in open.


# DISMISS_BUTTON_STYLE_DONE

Availability
7.1.0
DISMISS_BUTTON_STYLE_DONE :Number

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

Use with the dismissButtonStyle property in open.