silkimen / cordova-plugin-advanced-http

Cordova / Phonegap plugin for communicating with HTTP servers. Allows for SSL pinning!
MIT License
391 stars 313 forks source link

[Bug] [Android] Uncaught SyntaxError: Use of const in strict mode. #479

Open iPMisterX opened 1 year ago

iPMisterX commented 1 year ago

Describe the bug This plugin work perfectly on 3.3.0 version. But in 3.3.1 version app stuck on the splashscreen

I test in Android 5.1, Android 5.1.1, Android 6.0 version but it’s all failed Android 7.0 and above work perfect

Android 5.1, Android 5.1.1

I/chromium: [INFO:CONSOLE(3854)] "Uncaught SyntaxError: Use of const in strict mode.", source: http://localhost:8080/plugins/cordova-plugin-advanced-http/www/umd-tough-cookie.js (3854)
I/chromium: [INFO:CONSOLE(53)] "Uncaught Error: module cordova-plugin-advanced-http.tough-cookie not found", source: http://localhost:8080/cordova.js (53)

Android 6.0

I/chromium: [INFO:CONSOLE(3873)] "Uncaught SyntaxError: Unexpected token =>", source: http://localhost:8080/plugins/cordova-plugin-advanced-http/www/umd-tough-cookie.js (3873)
I/chromium: [INFO:CONSOLE(53)] "Uncaught Error: module cordova-plugin-advanced-http.tough-cookie not found", source: http://localhost:8080/cordova.js (53)

System info

Are you using ionic-native-wrapper?

Minimum viable code to reproduce If applicable, add formatted sample coding to help explain your problem.

silkimen commented 11 months ago

Thanks for the feedback! This problem seems to be caused by the fact that Android < 7.0 was shipped with an old web view version which does not support some ES6 features which are used in though-cookie >= 3.0.0.

Now there are multiple options to solve this problem:

  1. use an old version of this plugin (easiest solution)
  2. tell your users to update their web view version on their devices, because that's actually supported for Android > 5.1 (but not easy as you probably have no control over customer devices)
  3. transpile though-cookie with e.g. babel or similar to support outdated ES5 engine (best solution, but quite some effort)

Would you (or anyone else here) please provide a PR for option 3? I guess it makes sense to implement this in the https://github.com/silkimen/umd-tough-cookie repository.