diff --git a/flutter_inappwebview_ios/CHANGELOG.md b/flutter_inappwebview_ios/CHANGELOG.md index b61a86e8..18749fbb 100644 --- a/flutter_inappwebview_ios/CHANGELOG.md +++ b/flutter_inappwebview_ios/CHANGELOG.md @@ -1,3 +1,7 @@ +## 1.0.4 + +- Fixed "Cloudflare Turnstile failure" [#1738](https://github.com/pichillilorenzo/flutter_inappwebview/issues/1738) + ## 1.0.3 - Fixed `InAppBrowserMenuItem.iconColor` not working diff --git a/flutter_inappwebview_ios/ios/Classes/PluginScriptsJS/ConsoleLogJS.swift b/flutter_inappwebview_ios/ios/Classes/PluginScriptsJS/ConsoleLogJS.swift index 69a92953..d244d899 100644 --- a/flutter_inappwebview_ios/ios/Classes/PluginScriptsJS/ConsoleLogJS.swift +++ b/flutter_inappwebview_ios/ios/Classes/PluginScriptsJS/ConsoleLogJS.swift @@ -21,6 +21,17 @@ let CONSOLE_LOG_JS_PLUGIN_SCRIPT = PluginScript( let CONSOLE_LOG_JS_SOURCE = """ (function(console) { + function _callHandler(oldLog, args) { + var message = ''; + for (var i in args) { + try { + message += message === '' ? args[i] : ' ' + args[i]; + } catch(ignored) {} + } + var _windowId = \(WINDOW_ID_VARIABLE_JS_SOURCE); + window.webkit.messageHandlers[oldLog].postMessage({'message': message, '_windowId': _windowId}); + } + var oldLogs = { 'consoleLog': console.log, 'consoleDebug': console.debug, @@ -33,24 +44,7 @@ let CONSOLE_LOG_JS_SOURCE = """ (function(oldLog) { console[oldLog.replace('console', '').toLowerCase()] = function() { oldLogs[oldLog].apply(null, arguments); - var args = arguments; - - // on iOS, for some reason, accessing the arguments object synchronously can throw some errors, such as "TypeError" - // see https://github.com/pichillilorenzo/flutter_inappwebview/issues/776 - setTimeout(function() { - var message = ''; - for (var i in args) { - if (message == '') { - message += args[i]; - } - else { - message += ' ' + args[i]; - } - } - - var _windowId = \(WINDOW_ID_VARIABLE_JS_SOURCE); - window.webkit.messageHandlers[oldLog].postMessage({'message': message, '_windowId': _windowId}); - }); + _callHandler(oldLog, arguments); } })(k); } diff --git a/flutter_inappwebview_ios/pubspec.yaml b/flutter_inappwebview_ios/pubspec.yaml index 80dc4519..c090632e 100644 --- a/flutter_inappwebview_ios/pubspec.yaml +++ b/flutter_inappwebview_ios/pubspec.yaml @@ -1,6 +1,6 @@ name: flutter_inappwebview_ios description: iOS implementation of the flutter_inappwebview plugin. -version: 1.0.3 +version: 1.0.4 homepage: https://inappwebview.dev/ repository: https://github.com/pichillilorenzo/flutter_inappwebview/tree/master/flutter_inappwebview_ios issue_tracker: https://github.com/pichillilorenzo/flutter_inappwebview/issues diff --git a/flutter_inappwebview_macos/CHANGELOG.md b/flutter_inappwebview_macos/CHANGELOG.md index cbe42f3e..e7ecf7a2 100644 --- a/flutter_inappwebview_macos/CHANGELOG.md +++ b/flutter_inappwebview_macos/CHANGELOG.md @@ -1,3 +1,7 @@ +## 1.0.2 + +- Fixed "Cloudflare Turnstile failure" [#1738](https://github.com/pichillilorenzo/flutter_inappwebview/issues/1738) + ## 1.0.1 - Added `PlatformPrintJobController.onComplete` setter diff --git a/flutter_inappwebview_macos/macos/Classes/PluginScriptsJS/ConsoleLogJS.swift b/flutter_inappwebview_macos/macos/Classes/PluginScriptsJS/ConsoleLogJS.swift index 69a92953..d244d899 100644 --- a/flutter_inappwebview_macos/macos/Classes/PluginScriptsJS/ConsoleLogJS.swift +++ b/flutter_inappwebview_macos/macos/Classes/PluginScriptsJS/ConsoleLogJS.swift @@ -21,6 +21,17 @@ let CONSOLE_LOG_JS_PLUGIN_SCRIPT = PluginScript( let CONSOLE_LOG_JS_SOURCE = """ (function(console) { + function _callHandler(oldLog, args) { + var message = ''; + for (var i in args) { + try { + message += message === '' ? args[i] : ' ' + args[i]; + } catch(ignored) {} + } + var _windowId = \(WINDOW_ID_VARIABLE_JS_SOURCE); + window.webkit.messageHandlers[oldLog].postMessage({'message': message, '_windowId': _windowId}); + } + var oldLogs = { 'consoleLog': console.log, 'consoleDebug': console.debug, @@ -33,24 +44,7 @@ let CONSOLE_LOG_JS_SOURCE = """ (function(oldLog) { console[oldLog.replace('console', '').toLowerCase()] = function() { oldLogs[oldLog].apply(null, arguments); - var args = arguments; - - // on iOS, for some reason, accessing the arguments object synchronously can throw some errors, such as "TypeError" - // see https://github.com/pichillilorenzo/flutter_inappwebview/issues/776 - setTimeout(function() { - var message = ''; - for (var i in args) { - if (message == '') { - message += args[i]; - } - else { - message += ' ' + args[i]; - } - } - - var _windowId = \(WINDOW_ID_VARIABLE_JS_SOURCE); - window.webkit.messageHandlers[oldLog].postMessage({'message': message, '_windowId': _windowId}); - }); + _callHandler(oldLog, arguments); } })(k); } diff --git a/flutter_inappwebview_macos/pubspec.yaml b/flutter_inappwebview_macos/pubspec.yaml index d994d941..5a6b62af 100644 --- a/flutter_inappwebview_macos/pubspec.yaml +++ b/flutter_inappwebview_macos/pubspec.yaml @@ -1,6 +1,6 @@ name: flutter_inappwebview_macos description: macOS implementation of the flutter_inappwebview plugin. -version: 1.0.1 +version: 1.0.2 homepage: https://inappwebview.dev/ repository: https://github.com/pichillilorenzo/flutter_inappwebview/tree/master/flutter_inappwebview_macos issue_tracker: https://github.com/pichillilorenzo/flutter_inappwebview/issues