PhoneGap Layar Plugin
The Layar plugin for Apache Cordova allows you to use the JavaScript code in your Cordova application as you use in your web application to build an augmented reality app.
- Supported on PhoneGap (Cordova) v3.3.0 and above.
- This plugin is built with
- iOS Layar SDK 8.4
- Android Layar SDK 8.4
Plugin requirements
The Layar plugin requires:
- iphone 3GS or higher (a minimum installed iOS version of 6.0 )
- iPad 2 or higher (a minimum installed iOS version of 6.0 )
- Android device that has a back-facing camera (android version 2.3 and above)
Limitations
Layer SDK callbacks are not supported in the plugin. Using the PhoneGap plugin you can launch a scan view or open a layar but cannot get javascript callbacks about what is going on. To implement callbacks please use the iOS and Android SDK natively.
Instalation guide
The Layar PhoneGap plugin requires Cordova CLI. To install the plugin in your app, execute the following code:
# Create initial Cordova app $ cordova create myApp $ cd myApp/ $ cordova platform add ios (For iOS) $ cordova platform add android (For Android) # Add the path you cloned the plugin to earlier $ cordova -d plugin add /path/to/cloned/phonegap-layar-plugin
API Methods
Initialize
LayarPlugin.initialize(Layar Key, Layar Secret)
Initializes the Layar plugin with a consumer key and secret.
Parameter (key) : The oauth consumer key
Parameter (secret) :The consumer secret.
Please contact layer support to obtain a key and secret if you don not have one.
Premature return {Q.Promise} : you can use to implement success and failure callbacks
Open Scan View
LayarPlugin.openScanView()
Opens the AR camera view for scanning
Open URL
LayarPlugin.openURL(Layar URL)
Opens a layar view with a layar URL. This is mostly useful for opening geo layers with parameter Parameter url: The URL to open
Example-> layar://yourlayarname?param=value
Open Layar
LayarPlugin.openLayar(Layername)
Opens a layar view with a layar name. Especially useful for opening geo layersparameter Parameter layername:The name of the layer to open.
Example Application
Common Issues
working with the SDK you might come across this common errors messages:
Nothing found (when scanning a Page)
Make sure that your Page is published as a Pro Campaign and not as a free one. Also make sure that the campaign belongs to the user you registered to receive the Key and secret.
An error occurred (we did not receive suitable response..)
Make sure that:
- You do have internet connection.
- The bundle id you registered with us before receiving the Key and secret remains the same.
- Key and secret are correct and have not expired yet.