Skip to content

WKWebView RunJavaScriptConfirmPanel Unable to locate the block to delegate conversion method ... #3928

Description

@CarLoOSX

Steps to Reproduce

https://developer.xamarin.com/recipes/ios/content_controls/web_view/handle_javascript_alerts/
Method :
RunJavaScriptConfirmPanel

Expected Behavior

It should show an Action sheet like iOS Simulator

Actual Behavior

App crashes

Environment

ios 11.3
Xcode 9.3
Xamarin.iOS : Version: 11.9.1.24 (Visual Studio Community)
Hash: f62de47
Branch: xcode9.3
Build date: 2018-03-29 19:30:53-0400
Visual Studio Mac 7.4.2 (build 12)

Hello, Im trying to capture confirm panels in Xamarin.iOS App but it only works in simulator.

[Foundation.Export("webView:runJavaScriptConfirmPanelWithMessage:initiatedByFrame:completionHandler:")]
    public void RunJavaScriptConfirmPanel(WKWebView webView, string message, WKFrameInfo frame, Action<bool> completionHandler)
    {

        var alertController = UIAlertController.Create(null, message, UIAlertControllerStyle.ActionSheet);

        alertController.AddAction(UIAlertAction.Create("Sí", UIAlertActionStyle.Destructive, okAction =>
        {
            completionHandler(true);
        }));
        alertController.AddAction(UIAlertAction.Create("No", UIAlertActionStyle.Default, cancelAction =>
        {
            completionHandler(false);
        }));

        _controller.PresentViewController(alertController, true, null);

    }

I'm following the next example from xamarin official page ( https://developer.xamarin.com/recipes/ios/content_controls/web_view/handle_javascript_alerts/ ) but when I run the app on my iPhone 8 plus I'm getting this error:

ObjCRuntime.RuntimeException:
Unable to locate the block to delegate conversion method for the method XXXX.iOS.Infrastructure.JSDelegate.RunJavaScriptConfirmPanel's parameter #4. Please file a bug at http://bugzilla.xamarin.com.

Metadata

Metadata

Assignees

No one assigned

    Labels

    iOSIssues affecting iOSneed-infoWaiting for more information before the bug can be investigatedsupportThe issue is related to support

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions