Ace = JavaScript +  Native UI  + iOS + Android

for Apache Cordova


Add native power to your shared JavaScript codebase

Works with Ionic, PhoneGap, and all Cordova-based projects

 See how Ace is used in the PhoneGap Day app

$ cordova plugin add cordova-plugin-ace

View on Github

What can you do with Project Ace?

1

Mix native UI with HTML

GET THE BEST OF BOTH WORLDS

What's the big deal about native UI?

  • Great performance
  • Looks perfect
  • Stays up-to-date with theme changes
  • Respects user accessibility settings

Yet with HTML, you can still leverage your web skills, code, and familiar frameworks like Ionic, Bootstrap, and Ember.

Docked

Overlays

Fullscreen

Widgets ()

Floating ()


2

Use a cross-platform native UI framework

...OR JUST USE RAW NATIVE CONTROLS DIRECTLY

Use simple classes like Button, Grid, or DatePicker. The UI framework provides cross-platform abstractions for native controls, layout, styling, and more. These abstractions are easy to use in JavaScript, TypeScript, or XAML markup.

Or, you can use platform-specific native controls directly. You've got many options:

Cross-Platform
(Write Once)
Platform-Specific
(Write Twice)
JavaScript
var button = new ace.Button();
var button;
if (ace.platform == "iOS")
  button = new ace.NativeObject("UIButton");
else if (ace.platform == "Android")
  button = new ace.NativeObject("android.widget.Button");
XAML
<Button />
<if:iOS>
  <ios:UIButton />
</if:iOS>
<if:Android>
  <android:Button />
</if:Android>
Android XML   only
<Button android:layout_width="wrap_content"
        android:layout_height="wrap_content" />
Interface Builder
(NIB/XIB)
  only
Cross-Platform
(Write Once)
JavaScript
var button = new ace.Button();
XAML
<Button />
Platform-Specific
(Write Twice)
JavaScript
var button;
if (ace.platform == "iOS")
  button = new ace.NativeObject(
    "UIButton");
else if (ace.platform == "Android")
  button = new ace.NativeObject(
    "android.widget.Button");
XAML
<if:iOS>
  <ios:UIButton />
</if:iOS>
<if:Android>
  <android:Button />
</if:Android>
Android XML
<Button android:layout_width=
        "wrap_content"
        android:layout_height=
        "wrap_content" />
Interface Builder
(NIB/XIB)

If you decide to use markup, you can link to it directly from your HTML, regardless of its type:

<a href="native://page.xaml">
  Go to an all-native page
</a>
<a href="android://page.xml">
  Go to an Android XML page
</a>
<a href="ios://page.xib">
  Go to an Interface Builder page
</a>

3

Call native code without additional plugins

THE ULTIMATE ESCAPE HATCH

Invoke anything from JavaScript. Your own code, third-party code, or platform APIs. No additional plugins or wrappers needed.

Directly add Java, Objective-C, and Android resources to your Cordova project so you can easily leverage them.

Android

// Vibrate using a pattern
var pattern = [500, 110, 450, 110, 200, 110];

// Get the VIBRATOR_SERVICE string constant
ace.NativeObject.getField("android.content.Context", "VIBRATOR_SERVICE", function (constant) {

  // Invoke Context.getSystemService with the constant
  ace.android.getContext().invoke("getSystemService", constant, function (vibrator) {

    // Call an instance method on the returned VibratorService
    vibrator.invoke("vibrate", pattern, -1);
  });
});

iOS

// Show the current battery level

// Invoke a static currentDevice method on UIDevice

ace.NativeObject.invoke("UIDevice", "currentDevice", function (device) {

  // On the returned instance, call an instance method with no return value
  device.invoke("setBatteryMonitoringEnabled", true);

  // Call another instance method that returns a double
  device.invoke("batteryLevel", function (level) {
    alert("capacity = " + (level * 100) + "%");
  });
});

Want to know more?

See Ace in Action Read the Docs