diff --git a/plugin.xml b/plugin.xml index 397a347..50aabe7 100644 --- a/plugin.xml +++ b/plugin.xml @@ -15,6 +15,8 @@ + + diff --git a/src/android/com/phonegap/plugins/twilioclient/TCPlugin.java b/src/android/com/phonegap/plugins/twilioclient/TCPlugin.java index 762c973..38d84e7 100644 --- a/src/android/com/phonegap/plugins/twilioclient/TCPlugin.java +++ b/src/android/com/phonegap/plugins/twilioclient/TCPlugin.java @@ -4,10 +4,10 @@ import java.util.Iterator; import java.util.Map; -import org.apache.cordova.api.CallbackContext; -import org.apache.cordova.api.CordovaPlugin; -import org.apache.cordova.api.PluginResult; -import org.apache.cordova.api.PluginResult.Status; +import org.apache.cordova.CallbackContext; +import org.apache.cordova.CordovaPlugin; +import org.apache.cordova.PluginResult; +import org.apache.cordova.PluginResult.Status; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; @@ -67,10 +67,9 @@ public void onReceive(Context context, Intent intent) { mConnection = intent.getParcelableExtra(Device.EXTRA_CONNECTION); mConnection.setConnectionListener(plugin); Log.d(TAG, "incoming intent received with connection: "+ mConnection.getState().name()); - JSONObject connection = new JSONObject(); String constate = mConnection.getState().name(); if(constate.equals("PENDING")) { - TCPlugin.this.javascriptCallback("onincoming", connection, mInitCallbackContext); + TCPlugin.this.javascriptCallback("onincoming", mInitCallbackContext); } } }; diff --git a/src/ios/TCPlugin.h b/src/ios/TCPlugin.h index 265a7b7..2527501 100644 --- a/src/ios/TCPlugin.h +++ b/src/ios/TCPlugin.h @@ -18,23 +18,23 @@ -(void)device:(TCDevice*)device didReceiveIncomingConnection:(TCConnection*)connection; -(void)device:(TCDevice *)device didReceivePresenceUpdate:(TCPresenceEvent *)presenceEvent; -(void)deviceDidStartListeningForIncomingConnections:(TCDevice*)device; --(void)deviceStatus:(NSMutableArray *)arguments withDict:(NSMutableDictionary *)options; +-(void)deviceStatus:(CDVInvokedUrlCommand*)command; # pragma mark connection delegate methods -(void)connection:(TCConnection*)connection didFailWithError:(NSError*)error; -(void)connectionDidStartConnecting:(TCConnection*)connection; -(void)connectionDidConnect:(TCConnection*)connection; -(void)connectionDidDisconnect:(TCConnection*)connection; --(void)connectionStatus:(NSMutableArray *)arguments withDict:(NSMutableDictionary *)options; +-(void)connectionStatus:(CDVInvokedUrlCommand*)command; # pragma mark javascript mapper methods --(void)deviceSetup:(NSMutableArray *)arguments withDict:(NSMutableDictionary *)options; --(void)connect:(NSArray *)arguments withDict:(NSMutableDictionary *)options; --(void)disconnectAll:(NSArray *)arguments withDict:(NSMutableDictionary *)options; --(void)acceptConnection:(NSArray *)arguments withDict:(NSMutableDictionary *)options; --(void)disconnectConnection:(NSArray *)arguments withDict:(NSMutableDictionary *)options; --(void)rejectConnection:(NSArray *)arguments withDict:(NSMutableDictionary *)options; --(void)muteConnection:(NSArray *)arguments withDict:(NSMutableDictionary *)options; +-(void)deviceSetup:(CDVInvokedUrlCommand*)command; +-(void)connect:(CDVInvokedUrlCommand*)command; +-(void)disconnectAll:(CDVInvokedUrlCommand*)command; +-(void)acceptConnection:(CDVInvokedUrlCommand*)command; +-(void)disconnectConnection:(CDVInvokedUrlCommand*)command; +-(void)rejectConnection:(CDVInvokedUrlCommand*)command; +-(void)muteConnection:(CDVInvokedUrlCommand*)command; -(void)sendDigits:(CDVInvokedUrlCommand*)command; -(void)showNotification:(CDVInvokedUrlCommand*)command; -(void)cancelNotification:(CDVInvokedUrlCommand*)command; diff --git a/src/ios/TCPlugin.m b/src/ios/TCPlugin.m index 33e8d62..0160d35 100644 --- a/src/ios/TCPlugin.m +++ b/src/ios/TCPlugin.m @@ -80,9 +80,9 @@ -(void)connectionDidDisconnect:(TCConnection*)connection { # pragma mark javascript device mapper methods --(void)deviceSetup:(NSMutableArray *)arguments withDict:(NSMutableDictionary*)options { - self.callback = [arguments pop]; - self.device = [[TCDevice alloc] initWithCapabilityToken:[arguments pop] delegate:self]; +-(void)deviceSetup:(CDVInvokedUrlCommand*)command { + self.callback = command.callbackId; + self.device = [[TCDevice alloc] initWithCapabilityToken:[command.arguments objectAtIndex:0] delegate:self]; // Disable sounds. was getting EXC_BAD_ACCESS //self.device.incomingSoundEnabled = NO; @@ -92,15 +92,15 @@ -(void)deviceSetup:(NSMutableArray *)arguments withDict:(NSMutableDictionary*)op [self javascriptCallback:@"onready"]; } --(void)connect:(NSArray *)arguments withDict:(NSMutableDictionary *)options { - [self.device connect:options delegate:self]; +-(void)connect:(CDVInvokedUrlCommand*)command { + [self.device connect:[command.arguments objectAtIndex:0] delegate:self]; } --(void)disconnectAll:(NSArray *)arguments withDict:(NSMutableDictionary *)options { +-(void)disconnectAll:(CDVInvokedUrlCommand*)command { [self.device disconnectAll]; } --(void)deviceStatus:(NSMutableArray *)arguments withDict:(NSMutableDictionary *)options { +-(void)deviceStatus:(CDVInvokedUrlCommand*)command { NSString *state; switch ([self.device state]) { case TCDeviceStateBusy: @@ -120,25 +120,25 @@ -(void)deviceStatus:(NSMutableArray *)arguments withDict:(NSMutableDictionary *) } CDVPluginResult *result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:state]; - [self performSelectorOnMainThread:@selector(writeJavascript:) withObject:[result toSuccessCallbackString:[arguments pop]] waitUntilDone:NO]; + [self performSelectorOnMainThread:@selector(writeJavascript:) withObject:[result toSuccessCallbackString:command.callbackId] waitUntilDone:NO]; } # pragma mark javascript connection mapper methods --(void)acceptConnection:(NSArray *)arguments withDict:(NSMutableDictionary *)options { +-(void)acceptConnection:(CDVInvokedUrlCommand*)command { [self.connection accept]; } --(void)disconnectConnection:(NSArray *)arguments withDict:(NSMutableDictionary *)options { +-(void)disconnectConnection:(CDVInvokedUrlCommand*)command { [self.connection disconnect]; } --(void)rejectConnection:(NSArray *)arguments withDict:(NSMutableDictionary *)options { +-(void)rejectConnection:(CDVInvokedUrlCommand*)command { [self.connection reject]; } --(void)muteConnection:(NSArray *)arguments withDict:(NSMutableDictionary *)options { +-(void)muteConnection:(CDVInvokedUrlCommand*)command { if(self.connection.isMuted) { self.connection.muted = NO; } else { @@ -150,7 +150,7 @@ -(void)sendDigits:(CDVInvokedUrlCommand*)command { [self.connection sendDigits:[command.arguments objectAtIndex:0]]; } --(void)connectionStatus:(NSMutableArray *)arguments withDict:(NSMutableDictionary *)options { +-(void)connectionStatus:(CDVInvokedUrlCommand*)command { NSString *state; switch ([self.connection state]) { case TCConnectionStateConnected: @@ -173,7 +173,7 @@ -(void)connectionStatus:(NSMutableArray *)arguments withDict:(NSMutableDictionar } CDVPluginResult *result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:state]; - [self performSelectorOnMainThread:@selector(writeJavascript:) withObject:[result toSuccessCallbackString:[arguments pop]] waitUntilDone:NO]; + [self performSelectorOnMainThread:@selector(writeJavascript:) withObject:[result toSuccessCallbackString:command.callbackId] waitUntilDone:NO]; }