Skip to content

Commit

Permalink
Merge pull request #6 from shankari/restore_hardcoded_jwt
Browse files Browse the repository at this point in the history
Minor fixes to the android and iOS remote calls
  • Loading branch information
shankari committed Feb 22, 2016
2 parents 26d74c3 + 800cd71 commit ad3ab37
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
16 changes: 12 additions & 4 deletions src/android/CommunicationHelperPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,28 @@

public class CommunicationHelperPlugin extends CordovaPlugin {
@Override
public boolean execute(String action, JSONArray data, CallbackContext callbackContext) throws JSONException {
public boolean execute(String action, JSONArray data, final CallbackContext callbackContext) throws JSONException {
if (action.equals("pushGetJSON")) {
try {
Context ctxt = cordova.getActivity();
final Context ctxt = cordova.getActivity();
String relativeURL = data.getString(0);
JSONObject filledMessage = data.getJSONObject(1);
final JSONObject filledMessage = data.getJSONObject(1);

String commuteTrackerHost = ConnectionSettings.getConnectURL(ctxt);
String fullURL = commuteTrackerHost + relativeURL;
final String fullURL = commuteTrackerHost + relativeURL;

cordova.getThreadPool().execute(new Runnable() {
public void run() {
try {
String resultString = CommunicationHelper.pushGetJSON(ctxt, fullURL, filledMessage);
callbackContext.success(new JSONObject(resultString));
} catch (Exception e) {
callbackContext.error("While pushing/getting from server "+e.getMessage());
}
}
});
} catch (Exception e) {
callbackContext.error("While pushing/getting from server "+e.getMessage());
}
return true;
} else {
Expand Down
3 changes: 2 additions & 1 deletion src/ios/BEMCommunicationHelperPlugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ - (void)pushGetJSON:(CDVInvokedUrlCommand *)command
[CommunicationHelper pushGetJSON:filledMessage toURL:relativeURL completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error != NULL) {
[self sendError:error callBackID:callbackId];
}
} else {
NSError *parseError;
NSDictionary *parsedResult = [NSJSONSerialization JSONObjectWithData:data
options:kNilOptions
Expand All @@ -26,6 +26,7 @@ - (void)pushGetJSON:(CDVInvokedUrlCommand *)command
resultWithStatus:CDVCommandStatus_OK
messageAsDictionary:parsedResult];
[self.commandDelegate sendPluginResult:result callbackId:callbackId];
}
}];
}
@catch (NSException *exception) {
Expand Down

0 comments on commit ad3ab37

Please sign in to comment.