-
-
Notifications
You must be signed in to change notification settings - Fork 119
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
postWebMessage failed #277
Comments
same issue. |
The ... also if you want to receive messages on the JavaScript side, you need to use Try this: WebviewController _webviewController = WebviewController();
// ...
_subscriptions.add(_webviewController.loadingState.listen((state) {
debugPrint('Loading state: $state ');
if (state == LoadingState.navigationCompleted) {
_webviewController.executeScript(
"window.chrome.webview.addEventListener('message', event => { console.log('Received message:', event.data.message); });"
);
_webviewController.postWebMessage("{ \"message\": \"hello world\" }");
}
})); See:
|
Hello, I would like to send a message to JavaScript using the postWebMessage method:
WebviewController kWebController=WebviewController();
//Several initialization tasks for WebWiew
........
_ Subscriptions. add (kWebController. loadingState. listen ((state)){
DebugPrint ('Loading state: $state ');
If (state==LoadingState. navigation Completed){
KWebController.executeScript(
"Window. addEventListener ('message ', event=>{console. log ('Received message:', event. data);});";
KWebController. postWebMessage ("hello world");
}
});
After completion
KWebController. postWebMessage ("hello world");
There was an error in this call:
[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: PlatformException(not_supported, Posting the message failed., null, null)
#0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:652:7)
#1 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:310:18)
How should I solve it? Looking forward to your reply!
The text was updated successfully, but these errors were encountered: