API Reference
Cordova Plugin Reference
This document describes all available Cordova bindings which exists in the Wikitude Cordova Plugin. To ease the use of the raw cordova bindings, we created a wrapper which is called WikitudePlugin
and can be found in WikitudePlugin.js
.
Wikitude Plugin
All code snippets in this section assumes that an object called wikitudePlugin
exist that was created using the cordova.require
function. Do not confuse this with the plugin name WikitudePlugin
which is referenced in the bindings.
var wikitudePlugin = cordova.require("com.wikitude.phonegap.WikitudePlugin.WikitudePlugin");
Managing the ARchitectView
isDeviceSupported
Use this function to check if the current device is capable of running ARchitect Worlds.
@param {function} successCallback: A callback which is called if the device is capable of running ARchitect Worlds.
@param {function} errorCallback: A callback which is called if the device is not capable of running ARchitect Worlds.
Usage:
wikitudePlugin.isDeviceSupported(onDeviceSupported, onDeviceNotSupported);
loadARchitectWorld
Use this function to load an ARchitect World.
@param {string} worldPath: The path to an ARchitect world, ether on the device or on e.g. your Dropbox.
Usage:
wikitudePlugin.loadARchitectWorld("path/to/a/bundle/resource/or/url/index.html");
Managing the Wikitude SDK Lifecycle
close
Use this function to stop the augmented reality experience and to remove it from the screen.
Usage:
wikitudePlugin.close();
hide
Use this function to hide the augmented reality experience. In contrast to the close functions all location and rendering updates are still active.
Usage:
wikitudePlugin.hide();
show
Use this function to show the augmented reality experience again if it was hidden before.
Usage:
wikitudePlugin.show();
Interacting with the Wikitude SDK
callJavaScript
Use this function to call JavaScript which will be executed in the context of the currently loaded ARchitect World.
@param {string} js: The JavaScript that should be evaluated in the ARchitect View.
Usage:
wikitudePlugin.callJavaScript('alert(\'Hello!\')');
setJSONObjectReceivedCallback
Use this function to set a callback which will be invoked when the ARchitect World calls AR.platform.sendJSONObject()
.
@param onJSONObjectReceived A function which will be called when AR.platform.sendJSONObject is called.
Usage:
wikitudePlugin.onJSONObjectReceived(onJSONObjectReceived);
ARchitect example:
AR.platform.sendJSONObject({
name: "button",
action: "captureScreen"
}
setLocation
Use this function to inject a location into the Wikitude SDK. The location is a coordinate in the three-dimensional space plus a value indicating the accuracy of this location. The coordinate system used is WGS 84.
@param {number} latitude: The latitude of the location in decimal degrees which should be simulated
@param {number} longitude: The longitude of the location in decimal degrees should be simulated
@param {number} altitude: The altitude of the location in meters which should be simulated
@param {number} accuracy: The location accuracy of the simulated location in meters
Usage:
wikitudePlugin.setLocation(latitude, longitude, altitude, accuracy);
captureScreen
Use this function to generate a screenshot from the current Wikitude SDK view.
@param {function} onCapturedScreen: A function that is called when the screen could be successfully captured. The bundle path is passed to the function when the photo was saved into the application bundle.
@param {function} onErrorCapturedScreen: A function that is called when an error occurred during screen capturing.
@param {bool} includeWebView: Indicates if the ARchitect web view should be included in the generated screenshot or not.
@param {string} imagePathInBundleorNullForPhotoLibrary: If a file path or file name is given, the generated screenshot will be saved in the application bundle. Passing null will save the photo in the device photo library.
Usage:
wikitudePlugin.captureScreen(onCapturedScreen, onErrorCaptureScreen, true, null);
showAlert
Use this function to display an alert with a specific message.
@param alertString The message to display in the alert.
Usage:
wikitudePlugin.showAlert('Message');
Cordova Bindings
This section describes all the cordova.exec
bindings that exist in the Wikitude PhoneGap Plugin. All of the bindings are somehow represented by the WikitudePlugin
.
Getting information about device compatibility
isDeviceSupported
Call isDeviceSupported
to determine if the current device is capable of launching ARchitect Worlds.
@param onSuccessCallback - A callback which is called if the current device supports launching ARchitect Worlds
@param onErrorCallback - A callback which is called if the current device does not fulfill all needs to launch ARchitect Worlds
@param pluginName - The name of the plugin: has to be "WikitudePlugin".
@param pluginFunction - The name of the function you want to call: Has to be "isDeviceSupported".
@param options - augmentedRealityMode A string which refines the capabilities, the device should support. Possible Values are: `Geo`, `IR` or `Both`.
cordova.exec(onSuccessCallback, onErrorCallback, pluginName, pluginFunction, options);
Usage:
cordova.exec(onSuccessIsDeviceSupported, onErrorIsDeviceSupported, WikitudePlugin, isDeviceSupported, ["augmentedRealityMode":"IR"]);
Managing the ARchitectView
open
Call open
to add the ARchitectView
to your applications view hierarchy and loads the specified ARchitect World.
@param onSuccessCallback - A success callback
@param onErrorCallback - An error callback
@param pluginName - The name of the plugin: has to be "WikitudePlugin".
@param pluginFunction - The name of the function you want to call: Has to be "open".
@param options - a object containing three variables:
@first `SDKKey`: The Wikitude SDK Key provided to you after you purchased the Wikitude SDK or an empty string if you're using a trial version
@second `ARchitectWorldPath`: A path to a local bundle resource or a remote URL.
@third `AugmentedRealityMode`: Refines how the SDK should be configured. Possible Values are: `Geo`, `IR` or `IrAndGeo`. Passing `IR` will not turn on location services, so Geo Worlds will not displayed correctly.
cordova.exec(onSuccessCallback, onErrorCallback, pluginName, pluginFunction, options);
Usage:
cordova.exec(onSuccessOpen, onErrorOpen, WikitudePlugin, open, [{"SDKKey": "KGKNEK39043....", "ARchitectWorldPath": "path/to/world", "AugmentedRealityMode": "IrAndGeo"}]);
close
This call will remove the ARchitectView from the view hierarchy and also stops all ongoing Wikitude updates.
@param onSuccessCallback - A success callback
@param onErrorCallback - An error callback
@param pluginName - The name of the plugin: has to be "WikitudePlugin".
@param pluginFunction - The name of the function you want to call: Has to be "close".
@param options - No options
cordova.exec(onSuccessCallback, onErrorCallback, pluginName, pluginFunction, []);
Usage:
cordova.exec(onSuccessClose, onErrorClose, WikitudePlugin, close, []);
hide
This call hides the ARchitectView, but keeps it alive in memory.
@param onSuccessCallback - A success callback
@param onErrorCallback - An error callback
@param pluginName - The name of the plugin: has to be "WikitudePlugin".
@param pluginFunction - The name of the function you want to call: Has to be "hide".
@param options - No options
cordova.exec(onSuccessCallback, onErrorCallback, pluginName, pluginFunction, []);
Usage:
cordova.exec(onSuccessHide, onErrorHide, WikitudePlugin, hide, []);
show
This call will show the ARchitectView again if it was hidden with the hide
call.
@param onSuccessCallback - A success callback
@param onErrorCallback - An error callback
@param pluginName - The name of the plugin: has to be "WikitudePlugin".
@param pluginFunction - The name of the function you want to call: Has to be "show". @param options - No options
cordova.exec(onSuccessCallback, onErrorCallback, pluginName, pluginFunction, []);
Usage:
cordova.exec(onSuccessShow, onErrorShow, WikitudePlugin, show, []);
Interacting with the ARchitectView
callJavaScript
This function will evaluate the passed JavaScript in the current ARchitect World context.
@param onSuccessCallback - A success callback
@param onErrorCallback - An error callback
@param pluginName - The name of the plugin: has to be "WikitudePlugin".
@param pluginFunction - The name of the function you want to call: Has to be "callJavascript".
@param options - An array with one object at the first position. The first object has to be a string containing the JavaScript that has to be evaluated.
cordova.exec(onSuccessCallback, onErrorCallback, pluginName, pluginFunction, []);
Usage:
cordova.exec(onSuccessCallJavaScript, onErrorCallJavaScript, WikitudePlugin, callJavaScript, ["alert(\'Hello!\');"]);
onJSONObjectReceived
This function will set a callback which gets called if you call AR.platform.sendJSONObject()
.
@param onSuccessCallback - A callback which gets called every time you call `AR.platform.sendJSONObject()`
@param onErrorCallback - An error callback
@param pluginName - The name of the plugin: has to be "WikitudePlugin".
@param pluginFunction - The name of the function you want to call: has to be "onJSONReceived".
@param options - No options
cordova.exec(onSuccessCallback, onErrorCallback, pluginName, pluginFunction, []);
Usage:
cordova.exec(onSuccessInvoke, onErrorInvoke, WikitudePlugin, onUrlInvoke, []);
setLocation
This function allows you to set a location for your current ARchitectView
@param onSuccessCallback - A success callback
@param onErrorCallback - An error callback
@param pluginName - The name of the plugin: has to be "WikitudePlugin".
@param pluginFunction - The name of the function you want to call: has to be "setLocation". @param options - A array containing the new latitude, longitude, altitude, accuracy
@first: The new latitude in decimal degrees (WGS 84)
@second: The new longitude in decimal degrees (WGS 84)
@third: The new altitude in meters
@fourth: The accuracy of the new locations in meters
cordova.exec(onSuccessCallback, onErrorCallback, pluginName, pluginFunction, []);
Usage:
cordova.exec(onSuccessSetLocation, onErrorSetLocation, "WikitudePlugin", "setLocation", [47.22234, -18.77464, 250, 10]);
captureScreen
This function allows you to capture the content of your current ARchitectView
@param onSuccessCallback - A success callback
@param onErrorCallback - An error callback
@param pluginName - The name of the plugin: Has to be "WikitudePlugin".
@param pluginFunction - The name of the function you want to call: Has to be "captureScreen".
@param options - A array containing parameters how the screen should be captured.
@first `includeWebView`: Boolean: Should the screenshot include the web view or not
@second `imagePathInBundldeOrNullForPhotoLibrary`: If a file path or file name is given, the generated screenshot will be saved in the application bundle. Passing null will save the photo in the device photo library.
cordova.exec(onSuccessCallback, onErrorCallback, pluginName, pluginFunction, options);
Usage:
cordova.exec(onUrlInvokeCallback, onWikitudeError, "WikitudePlugin", "captureScreen", [true, null]);
JavaScript API
Go to JavaScript API Reference for a complete reference of all JavaScript API objects and functions.
Studio API
Go to REST API Reference for a complete reference of all REST API calls for the Studio API.