Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to add/call plugin method from javascript

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 223
    Comment on it

    Use the following code to make plugin javascript

    Here connectwebsocketserver is the function which called by javascript (index.js). If your plugin javascript file name is test then by following lin you can call this function

     test.connectwebsocketserver("192.168.3.82",connectionsucess,conectionfail);
    

    .. WebSocketServer is the name of objective C file plugin and startWebSocketServer is name of function in that file which will called from javascript. serverip is the parameter passing to the plugin function.

    module.exports = {
       connectwebsocketserver: function (serverip, successCallback, errorCallback) {
           cordova.exec(function(){return successCallback},errorCallback,
                     // Define what class to route messages to
                     'WebSocketServer',
                     // Execute this method on the above class
                     'startWebSocketServer',
                     // An array containing one String (our newly created Date String).
                     [serverip]);
        },
    sendmessage: function(message, successCallback, errorCallback)
        {
            cordova.exec(successCallback,errorCallback,
                         // Define what class to route messages to
                         'WebSocketServer',
                         // Execute this method on the above class
                         'sendMessagetoAllConnectedWebSockets',
                         // An array containing one String (our newly created Date String).
                         [message]);
        }
    };
    

    In the same way , you can call another plugin method sendMessagetoAllConnectedWebSockets

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: