Commit 26ef8e36 by Oscar Fuentes

Fix plugin response

parent 4b693015
......@@ -13,6 +13,8 @@ import org.apache.cordova.PluginResult;
import org.apache.cordova.PluginResult.Status;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import com.phonegap.plugins.barcodescanner.BarcodeScanner;
import android.content.Context;
......@@ -61,7 +63,13 @@ public class PluginHelper {
barCode = barCode.replaceAll("\u0000", "");
Log.i(TAG, barCode);
callbackContext.sendPluginResult(new PluginResult(Status.OK, barCode));
try {
JSONObject result = new JSONObject().put("text", barCode);
callbackContext.sendPluginResult(new PluginResult(Status.OK, result));
} catch (JSONException e) {
e.printStackTrace();
callbackContext.sendPluginResult(new PluginResult(Status.ERROR, ""));
}
}
});
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment