-
Notifications
You must be signed in to change notification settings - Fork 208
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
External keyword in JS for iOS and maccatyalist is deprecated. #2775
Comments
Hi @SoumyadipYT-OSS , it looks like the HybidWebView code was only using Are you seeing any problems or issues with this usage in HybridWebView? |
@Eilon Thank you for the previous reply, I am facing an issue to build HybridWebView handlers in .NET MAUI, I tried to configure but the index.html file is not rendering in the application. Can you help me to guide me on this topic? |
@Eilon can you guide for HybridWebView implementation for a existing normal .NET MAUI App? Because it is not working properly in my application. |
I've had a hard time creating a bidirectional communication between Android/Windows and the JavaScript of the index with window.external. When I finally got everything working, I learned that window.external is deprecated. Now I've started from scratch, and there's no way for the native app to receive messages from the JavaScript of the index. I created this class: `namespace ProjectName {
} And from JavaScript, I'm doing this: `document.addEventListener("DOMContentLoaded", function() { function SendDataToNative(command, params = null) { window.receiveMessage = function(message) {
}; // Example usage `// Somewhere in the class private void HandleMessageFromJs(string message) { |
@Bricobit Due to this deprecated issue, the log is not showing the message properly and so the output is not rendering on the UI part. But if you check in the backend, try to write Console.WriteLine(); If answer shows in the output, then your backend is working fine! |
In the end, in order to avoid using windows.external, which is deprecated, I have tried to navigate directly with window.location.href and for the moment everything seems to be working fine and I have not had to change anything I had done. It seems that it has some limitations when passing some complex json objects through the URL parameters, but for the moment it works for me.
|
@Bricobit Check my code that I have solved the code, check on top on this issue, the whole code you can use the code adjust as your project. Thank you! If you want to discuss on this topic, issue is still open. |
Hello, thanks, that was the first thing I tried. I put your window.HybridWebView = {...} object inside my index.php, but for some reason, I couldn't retrieve the messages sent from index.php to MAUI. It's possible that my limited experience in C# is causing me not to implement it correctly, or I might be missing a practical working example. In the end, I opted for a hybrid solution, because there can be character issues when sending JSON objects through URLs, and I don't want to send Base64 strings, since URLs also have character limits, and I don't want to worry about that, although it's unlikely I'll need to send that much information. The method I've decided to use is to first store the JSON object or information in localStorage and then send a message/command to MAUI via window.location.href with a URL like ?command=loadFromLocalStorage&key=keyToLoad, to indicate/notify it to load the information from localStorage for the given key when it receives that command. So far, this is working well for me. To communicate from MAUI to JS, I do it directly by evaluating a function, and for reverse communications where I need to send complex data, I use localStorage as an intermediary, as I have explained. I will keep an eye on the community in case someone shows a basic example of how to implement hybridwebview and see how something like a "Hello world" is sent and received correctly and then I may change the system, greetings. |
Type of issue
Outdated article
Description
Please update the code of HybridWebView.js part:
because external keyword is deprecated: I have updated the code block please add into it.
Page URL
https://learn.microsoft.com/en-us/dotnet/maui/user-interface/controls/hybridwebview?view=net-maui-9.0
Content source URL
https://github.com/dotnet/docs-maui/blob/main/docs/user-interface/controls/hybridwebview.md
Document Version Independent Id
2a6b2f14-d1b6-4833-6193-1d3ddb123ca0
Article author
@davidbritch
Metadata
Related Issues
The text was updated successfully, but these errors were encountered: