Skip to content
Titanium SDK

ti.webdialog

Use the SFSafariViewController (iOS) and Chrome Pages (Android) in Titanium.

4.0.0iOSNov 6, 2025v4.0.0-ios

Install

A module is a zip you unpack in your project. There is no installer command yet - a ti module install is planned but does not exist today, so the steps below are the ones that work.

  1. 1. Download the release archive

  2. 2. Unpack it at your project root

    cd /path/to/your-project
    unzip ~/Downloads/ti.webdialog-iphone-4.0.0.zip

    The archive already contains the full path, so it lands in place:

    • modules/iphone/ti.webdialog/4.0.0/
  3. 3. Add it to tiapp.xml

    <modules>
      <module platform="iphone" version="4.0.0">ti.webdialog</module>
    </modules>

    The platform attribute is the packager’s name for the platform, which is iphone for iOS - the same word the archive uses in its own path.

  4. 4. Require it from your app

    const mod = require('ti.webdialog');

Manifest

iOS 4.0.0

Minimum SDK
12.0.0
Module API version
2
Architectures
arm64, x86_64
GUID
1f19cce1-0ad7-4e25-ab3b-0666f54a0a49
Author
Hans Knoechel
License
Apache 2.0
Copyright
Copyright (c) 2017-present by TiDev
Mac Catalyst
not supported

API reference

Compiled from tidev/titanium-web-dialog@4.0.0 (96ff666).

Modules.WebDialog

moduleAndroidiPhoneiPadsince 7.1.0

Extends Titanium.Module

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](api:Modules) element of your tiapp.xml file:

<ti:app>
  <!-- ... -->
  [modules](api: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.

Properties 3

Methods 5

Programmatically closes the web dialog.

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

isOpen

iPhoneiPad

Indicates if the web dialog is open.

Returns Boolean

Indicates if the web dialog is supported.

Returns Boolean

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
ParametersTypeDescription
paramsWebDialogOpenParams

Dictionary used to configure the web dialog.

7 fields
barCollapsingEnabled? Boolean

Indicates if the web dialog should enable collapsing of the navigation bar and hiding of the bottom toolbar when the user scrolls web content. For iOS, this API is available on iOS 11 and later.

barColor? String

The bar-color of the web dialog. For iOS, available on iOS 10 and later.

dismissButtonStyle? Number

The dismiss-button-style of the web dialog close button. For iOS, this API is available on iOS 11 and later.

entersReaderIfAvailable? Boolean

Indicates if the reader version of content should be shown automatically.

intentFlags? Number

Intent flags to be used for the Chrome Custom Tab, specified as a Bitwise-OR

tintColor? String

The tint-color of the web dialog.

url String

The URL to be opened.

Events 4

close

iPhoneiPad

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

Event properties
Event propertiesTypeDescription
urlString

The URL provided when opening the web dialog.

load

iPhoneiPad

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
Event propertiesTypeDescription
urlString

The URL provided when opening the web dialog.

successBoolean

Returns true if loading completed successfully, false otherwise.

open

iPhoneiPad

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

Event properties
Event propertiesTypeDescription
urlString

The URL provided when opening the web dialog.

redirect

iPhoneiPad

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

Event properties
Event propertiesTypeDescription
urlString

The URL provided when opening the web dialog.

Modules.WebDialog.AuthenticationSession

proxyiPhoneiPadsince 7.1.0

Extends Titanium.Proxy

Authenticate a user with a web service, even if the web service is run by a third party.

The AuthenticationSession puts the user in control of whether they want to use their existing logged-in session from Safari. The app provides a URL that points to the authentication webpage. The page will be loaded in a secure view controller. From the webpage, the user can authenticate herself and grant access to the app. On completion, the service will send a callback URL with an authentication token, and this URL will be passed to the app by the callback.

The callback URL usually has a custom URL scheme. For the app to receive the callback URL, it needs to either register the custom URL scheme in its Info.plist, or set the scheme to scheme argument in the initializer.

If the user has already logged into the web service in Safari or other apps via the AuthenticationSession, it is possible to share the existing login information. An alert will be presented to get the user's consent for sharing their existing login information. If the user cancels the alert, the session will be canceled, and the callback will be called.

If the user taps Cancel when showing the login webpage for the web service, the session will be canceled, and the callback will be called as well.

The app can cancel the session by calling cancel(). This will also dismiss the window that is showing the web service's login page.

Requirements

The AuthenticationSession API is available with the Titanium SDK starting with Release 7.1.0. This module only works with devices running iOS 11.0 and later. Please make sure you have at least Xcode 9 to build to the required sources.

Getting Started

Create a new authentication session by providing a url and scheme, create an event-listener and start:

var WebDialog = require('ti.webdialog');

var authSession = WebDialog.createAuthenticationSession({
  url: 'https://example.com/oauth?callbackURL=myapp://',
  scheme: 'myapp://'
});

authSession.addEventListener('callback', function(e) {
  if (!e.success) {
      Ti.API.error('Error authenticating: ' + e.error);
      return;
  }
  
  Ti.API.info('Callback URL: ' + e.callbackURL);
});

authSession.start(); // Or cancel() to cancel it manually.

Properties 2

scheme

String

The custom URL scheme that the app expects in the callback URL.

url

String

The initial URL pointing to the authentication webpage. Only supports URLs with http:// or https:// schemes.

Methods 2

Cancel an authentication-session.

If the view controller is already presented to load the webpage for authentication, it will be dismissed. Calling cancel on an already canceled session will have no effect.

Starts the AuthenticationSession instance after it is instantiated.

The start method can only be called once for an AuthenticationSession instance. This also means calling start on a canceled session will fail.

Returns Boolean

Returns true if the session starts successfully.

Events 1

The callback which is called when the session is completed successfully or canceled by user.

Event properties
Event propertiesTypeDescription
errorString

The error-message returned in case something went wrong.

callbackURLString

The callback-URL returned in case the OAuth-flow succeeded.

AuthenticationSessionCallback

pseudoAndroidiPhoneiPadmacOS

The callback which is called when the session is completed successfully or canceled by user.

Properties 3

The callback-url passed if no error occured, undefined otherwise.

error

String

The error returned if the authentication-session failed, undefined otherwise.

success

Boolean

Returns true if the authentication-session completed successfully, false otherwise.