Skip to content

Commit

Permalink
fix for ios and macos pichillilorenzo#1738
Browse files Browse the repository at this point in the history
  • Loading branch information
pichillilorenzo authored and ps9310 committed Feb 24, 2024
1 parent 3929006 commit e8935a2
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 38 deletions.
4 changes: 4 additions & 0 deletions flutter_inappwebview_ios/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion flutter_inappwebview_ios/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 4 additions & 0 deletions flutter_inappwebview_macos/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion flutter_inappwebview_macos/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit e8935a2

Please sign in to comment.