-
1. Re: Solve referenceError on some Android Devices.
ryanskiheadMay 2, 2017 10:43 AM (in response to guilherme.ramalho)
Have you tried connecting Chrome web inspector to see if some of your files (such as config.js) are failing to load?
-
2. Re: Solve referenceError on some Android Devices.
guilherme.ramalho May 2, 2017 11:19 AM (in response to ryanskihead) -
3. Re: Solve referenceError on some Android Devices.
ryanskiheadMay 2, 2017 11:34 AM (in response to guilherme.ramalho)
No idea. But showing that none of the JS files are failing to load in Firefox doesn't say much. Connect one of the failure devices to your machine, launch Chrome, and use chrome://inspect to check for other errors in the app when it's actually running on your device.
https://gonzalo123.com/2014/08/04/debugging-android-cordovaphonegap-apps-with-chrome/
-
4. Re: Solve referenceError on some Android Devices.
guilherme.ramalho May 2, 2017 11:48 AM (in response to ryanskihead)Oh, cool! I didn't know I could do that. I'll try and post the result. Thanks!
-
5. Re: Solve referenceError on some Android Devices.
guilherme.ramalho May 2, 2017 12:48 PM (in response to ryanskihead)Looks like the problem is one of the functions I have in config.js. Do you see anything wrong with It? If I just comment this function the app works fine.
I'm getting this on the 'var maxStrWidth' line: Uncaught SyntaxError: Unexpected token >
function socialShare(message, font) {var y = 12;
var x = 18;
var canvas = document.getElementById("receipt");
var context = canvas.getContext("2d");
// calcula a largura da string mais larga
context.font = font;
var maxStrWidth = message.map(e => {
return context.measureText(e).width;
}).sort((a, b) => {
return b - a;
});
// configura a largura do canvas dinamicamente
canvas.width = maxStrWidth[0] + 9;
canvas.height = x * message.length;
// seta a cor do background do canvas
context.fillStyle = "#ffffe6";
context.fillRect(0, 0, canvas.width, canvas.height);
// escreve o texto
context.font = font;
context.fillStyle = "#000";
message.forEach(e => {
context.fillText(e, 3, y);
y += x;
});
// gera a string base64
let base64 = canvas.toDataURL("image/jpeg", 1);
// chamada do plugin social share
window.plugins.socialsharing.share(
null,
'Comprovante de Aposta',
base64,
null
);
}
-
6. Re: Solve referenceError on some Android Devices.
guilherme.ramalho May 2, 2017 1:52 PM (in response to guilherme.ramalho)I've just find out that some older WebViews don't support fat arrow function of ES6 and that's the reason for the error.