fix for ios and macos #1738

This commit is contained in:
Lorenzo Pichilli 2023-12-01 14:26:34 +01:00
parent d23f7fd41b
commit 290cfd6efa
6 changed files with 34 additions and 38 deletions

View File

@ -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

View File

@ -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);
}

View File

@ -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

View File

@ -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

View File

@ -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);
}

View File

@ -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