tools: Miscellaneous tools

API

forge.tools.UUID()

iOS, Android, Web

This method returns a new UUID for you to use as a unique token.

Note: This function is synchronous and returns a value rather than taking a callback.

A UUID is a globally unique token; when represented as a string, they look something like 18ADF182-7B12-4FA1-AF0B-6032108C0AE8.


forge.tools.getURL(name, success, error)

iOS, Android, Web

Resolve this name to a fully-qualified local resource.

Parameters:
name
string unqualified resource name in your src directory, e.g. my/resource.html
success
function(url) will be invoked with the URL as its only parameter
error
function(content) called with details of any error which may occur

forge.tools.getCookies(success, error)

iOS

Returns an array of all cookies in the cookie store.

Parameters:
success
function(cookies)
error
function(content) called with details of any error which may occur

forge.tools.setCookie(domain, path, name, value, success, error)

iOS

Sets a cookie in the cookie store

Parameters:
name
domain The domain for the cookie
name
path The path for the cookie
name
name The name for the cookie
name
value The value for the cookie
success
function() called when the cookie has been set successfully
error
function(content) called with details of any error which may occur

forge.tools.openInWebView(url, success, error)

iOS, Android

Opens an url in the app's webview

Parameters:
name
url The url to open
success
function() called upon successful completion
error
function(content) called with details of any error which may occur

forge.tools.openWithDevice(url, success, error)

iOS, Android

Opens an url with the device's default handler for the given content type

Parameters:
name
url The url to open
success
function() called upon successful completion
error
function(content) called with details of any error which may occur

Note: Limitations: You cannot use this method to provide device access to arbitrary content within your app as this would violate sandbox security. The url must point to an external resource.