The official ToggleHQ Appcelerator Titanium Plugin
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.project
LICENSE
README.md
togglehq.js

README.md

ToggleHQ Appcelerator Titanium Plugin

Requirements

The ToggleHQ Appcelerator Titanium Plugin requires iOS 8.0+

Installation

To install it, simply add the following line to your app.js file:

require("path/to/togglehq.js");

Create your application by visiting ToggleHQ.com and either registering or logging into an existing account. Once you're in head to App Settings > API Access and grab your Mobile OAuth Credentials. You'll use those to install ToggleHQ.

// app.js

require("path/to/togglehq.js");

THQ.init({
  client_id: "your-mobile-oauth-client-id",
  secret: "your-mobile-oauth-secret"
});

Basic Usage

Using these implementation methods are the quickest and fastest way to get ToggleHQ installed and running in your app.

On Login/Signup Assign This Device to a User

THQ.assignDeviceToUser("user_identifier", successCallback, failureCallback);

On Logout Assign This Device to a User

THQ.unassignDevice(successCallback, failureCallback);

Display Preferences Popup

THQ.requestCustomPermissions({
  image: "path/to/image.png",  // Optional
  header: "Example Header",  // Optional
  subHeader: "Here's some more information.", // Optional
  color: "#00ff00" // Optional
})

Open Preferences Page

var win = THQ.createPreferencesWindow({
  title: "Preferences", // Optional
  barColor: "#00ff00", // Optional
  tintColor: "#fff" // Optional
})

self.containingTab.open(win, {animated: true});

Additional Usage

While above displays the simplest methods for using ToggleHQ, you are also able to use more advanced methods to create a more customized solution.

Enable a preference for the current user or device

THQ.enablePreference("category_key", "preference_key", successCallback, failureCallback);

Disable a preference for the current user or device

THQ.disablePreference("category_key", "preference_key", successCallback, failureCallback);

Get all preferences for the current user or device

THQ.getPreferences(successCallback, failureCallback);
Example:
THQ.getPreferences(function(response){
  // Success
  // response: An array of categories and preferences
}, function(response){
  // Failure
  // response: A JSON object with a failure message
});

License

The ToggleHQ Appcelerator Titanium plugin is available under the MIT license. See the LICENSE file for more info.