platforms: ios
$ cordova plugin add com.shazron.cordova.torch

Torch Plugin for Apache Cordova

created by Shazron Abdullah

Apache 2.0 License

Follows the Cordova Plugin spec, so that it works with Plugman, or you can install it manually below.

  1. Add the plugin files (CDVTorch.h, CDVTorch.m) in Xcode (add as a group)
  2. Add torch.js to your www folder, and reference it in a script tag, after your cordova.js
  3. a. For Cordova.plist, under the 'Plugins' key, add a new row: key is "Torch" and the value is "CDVTorch"

    b. For config.xml, under the <plugins> tag, add this (deprecated, 2.7.0 and below):

     <plugin name="Torch" value="CDVTorch" />

    c. For config.xml, add a new <feature> tag (2.8.0 and up):

     <feature name="Torch">
        <param name="ios-package" value="CDVTorch" />
  4. Add the Framework "AVFoundation.framework" in your Build Phases tab of your Project, and set it to be weak linked

The plugin's JavaScript functions are called after getting the plugin object thus:

    var torch = cordova.require("cordova/plugin/torch");
    if (torch.isOn) {
        // do something