The LED API is a child of the Notification API and allows access to the LEDs on your device ## Enabling the API This API is part of the `coreapi` extension that is included automatically. :::ruby extensions: ["coreapi"] ### JavaScript Usage Be sure to review the [JavaScript API Usage](/guide/api_js) guide for important information about using this API in JavaScript ### Ruby Usage Be sure to review the [Ruby API Usage](/guide/api_ruby) guide for important information about using this API in Ruby ## Enabling the API There are two methods of enabling the Notification.Led API: * Include all ebapi modules or * Include only the API modules you need For either of these methods, you'll need to include files from the `/Enterprise Browser/JavaScript Files/Enterprise Browser` directory on the computer that you installed the Enterprise Browser. ### Include all JS API modules To include all JS APIs, you must copy the ebapi-modules.js file to a location accessible by your app's files and include the JavaScript file in your app. For instance, to include the modules file in your index.html, with the file in the same directory as your index.html, you would add the following line to the <head> section of your index.html: :::html <script type="text/javascript" charset="utf-8" src="ebapi-modules.js"></script> > Note: that the pathing for this file is relative to the current page. This will define the EB class within the page. Any page you need to use the modules will need to have the .js file included in this fashion. ### Include only the modules you need To include single APIs, you must first include the `ebapi.js` in your HTML as well as the API file you want to use. For instance, to use the Notification.Led API, I would add the following code to my HTML file(s), assuming the API files have been copied to the same directory as the HTML. :::html <script type="text/javascript" charset="utf-8" src="ebapi.js"></script> <script type="text/javascript" charset="utf-8" src="eb.notification.led.js"></script> The ebapi.js file is necessary for all single API inclusions. iOS, Android, WM 1.0.0 Human readable name for the notification object, e.g. 'Green LED'. WM, CE, Android, iOS Used to return the LEDs present on the device, you can then subsequently illuminate or extinguish them. iOS, Android, WM Array of LED objects, one for each hardware LED on the device. Called on an LED object returned from the enumerate method, the specified LED will be illuminated. iOS, Android, WM Called on an LED object returned from the enumerate method, the specified LED will be extinguished. iOS, Android, WM Called on an LED object returned from the enumerate method, the specified LED will be flashed. iOS, Android, WM The properties associated with the LED flash. When flashing, the LED will remain on for this number of milliseconds When flashing, the LED will remain off for this number of milliseconds The LED will flash this number of times.
Enumerating the LEDs will return an array objects which will map to the real LEDs on the device, using these returned objects you can control the device LEDs <% $leds.each_with_index do |led, index| %>
  • <%= led.name %>
  • <% end %> ]]>