Note that there are some explanatory texts on larger screens.

plurals
  1. POCustom Cordova Plugin
    text
    copied!<p>I'm trying to write a custom plugin for Cordova 2.0.0. The custom plugin that I want to make has to get the WP accent color, so I can use it in the app Style.</p> <p>But I can't manage to make it work properly and can't figure it out what I'm doing wrong.</p> <p><strong>Index.js</strong></p> <pre><code>function onDeviceReady() { click(); } function click() { navigator.notification.alert(callback, callback, "text", "button"); window.getAccentColor(); } </code></pre> <p><strong>GetTheme.cs</strong></p> <pre><code>namespace Cordova.Extension.Commands { // Use the phonegap base class public class GetTheme : BaseCommand { public void Get() { Color currentColorHex = (Color)Application.Current.Resources["PhoneAccentColor"]; var result = new PluginResult(PluginResult.Status.OK, currentColorHex.ToString()); DispatchCommandResult(result); } } } </code></pre> <p><strong>GetTheme.js</strong></p> <pre><code>window.getAccentColor = function () { cordova.exec(win, error, "GetTheme", "Get"); } function win(result) { console.log(result); console.log("2"); }; function error() { } </code></pre> <p>There a some things a bit strange that I've noticed. With the notification pop-up on the click action "2" is written in the output. But without it doesn't output anything.</p> <p>In both cases <code>result</code> from the <code>win</code> function is still empty and doesn't output anything.</p> <p>All the *.js files are included in the <code>index.html</code> file in the head section. The callback method from the notification is defined but it does nothing.</p> <p>I've also tried with the <code>WP7CordovaClassLib.Cordova.Commands</code> namespace.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload