Skip to content
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

Exception:Value cannot be null. (Parameter 'json') #27

Closed
beethmon opened this issue Sep 26, 2023 · 3 comments · Fixed by #44
Closed

Exception:Value cannot be null. (Parameter 'json') #27

beethmon opened this issue Sep 26, 2023 · 3 comments · Fixed by #44
Labels
bug Something isn't working

Comments

@beethmon
Copy link

beethmon commented Sep 26, 2023

It works but throw this Exception: Value cannot be null. (Parameter 'json')
my cs code:

try
{
				await hybridWebView.InvokeJsMethodAsync<int>("TestFun", 123, 456);
}
catch (Exception ex)
{
				Debug.WriteLine(ex.Message);
}

my xaml code:

<ContentPage
    x:Class="ActionTracer.MainPage"
    xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
    xmlns:ejl="clr-namespace:HybridWebView;assembly=HybridWebView">
    <ejl:HybridWebView
        x:Name="hybridWebView"
        HybridAssetRoot="hybrid"
        MainFile="index.html"
        MaximumWidthRequest="600"
        MinimumHeightRequest="350"
        RawMessageReceived="hybridWebView_RawMessageReceived" />
</ContentPage>

my html code:

<!DOCTYPE html>
<html lang="">

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">

    <meta name="viewport" content="width=device-width, initial-scale=1.0, 
minimum-scale=1.0, maximum-scale=1.0, viewport-fit=cover, user-scalable=no">
    <link rel="icon" href="<%= BASE_URL %>favicon.ico">
    <title>
        <%= htmlWebpackPlugin.options.title %>
    </title>
    <script src="_hwv/HybridWebView.js"></script>
</head>
<script>
    function TestFun(value1, value2) {
        alert(value1 + " " + value2);
    }
</script>
@Eilon
Copy link
Owner

Eilon commented Sep 26, 2023

I'll take a look!

@beethmon
Copy link
Author

I'll take a look!

Thanks,I fix this problem,cause I forgot return
but I had another question
Can I disable Android WebView TextZoom on this?
I can set it by use blazorWebView in the Init event:

                private void blazorWebView_BlazorWebViewInitialized(object sender, Microsoft.AspNetCore.Components.WebView.BlazorWebViewInitializedEventArgs e)
                {
        #if ANDROID
                    e.WebView.Settings.TextZoom = 100;
                   e.WebView.Settings.SetSupportZoom(false);
        #endif
                }

but It seems private in your library
=>private Android.Webkit.WebView PlatformWebView

Eilon added a commit that referenced this issue Feb 10, 2024
The InvokeJsMethodAsync() method now returns null if there was no return value.

Fixes #27
@Eilon Eilon added this to the 1.0.0-preview5 milestone Feb 10, 2024
@Eilon Eilon added the bug Something isn't working label Feb 10, 2024
@Eilon
Copy link
Owner

Eilon commented Feb 10, 2024

For the NullRef I have a fix here: #44

And for the initialization/zoom issue I logged #45 to track supporting that.

@Eilon Eilon closed this as completed in #44 Feb 11, 2024
Eilon added a commit that referenced this issue Feb 11, 2024
The InvokeJsMethodAsync() method now returns null if there was no return value.

Fixes #27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants