Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

minor changes to JS to suit my app development platform #6

Open
mm108 opened this issue Aug 4, 2015 · 0 comments
Open

minor changes to JS to suit my app development platform #6

mm108 opened this issue Aug 4, 2015 · 0 comments

Comments

@mm108
Copy link

mm108 commented Aug 4, 2015

hi,

Thanks a lot for the plugin. I am a NOOB to java / cordova and I have some difficulty in getting this plugin to work. I use a mobile app development platform. I have other plugins working and here is the sample of a JS file / plugin that works

cordova.define("com.badrit.MacAddress", function(require, exports, module) {

    /*
 * MacAddress
 * Implements the javascript access to the cordova plugin for retrieving the device mac address. Returns 0 if not running on Android
 * @author Olivier Brand
 */

    /**
 * @return the mac address class instance
 */
    var MacAddress = {

        getMacAddress: function(successCallback, failureCallback){
            cordova.exec(successCallback, failureCallback, 'MacAddressPlugin',
                         'getMacAddress', []);
        }
    };

    cordova.addConstructor(function () {
        if (!window.plugins) {
            window.plugins = {};
        }

        window.plugins.MacAddress = MacAddress;
        return window.plugins.MacAddress;
    });    
});

And here is the code in your plugin / JS file

var exec = require('cordova/exec');

exports.SPEAKER = 'speaker';
exports.EARPIECE = 'earpiece';
exports.NORMAL = 'normal';
exports.RINGTONE = 'ringtone';

exports.setAudioMode = function (mode) {
    cordova.exec(null, null, 'AudioTogglePlugin', 'setAudioMode', [mode]);
};

Is it possible to change the JS in your plugin to suit my platform? If you could help in any way that'll be great. Mainly the part I couldn't understand was the exports / parameters below

exports.SPEAKER = 'speaker';
exports.EARPIECE = 'earpiece';
exports.NORMAL = 'normal';
exports.RINGTONE = 'ringtone';

Thanks once again,
M&M

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant