Skip to content

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

Closed

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.

Activity

  1. CarLoOSX commented on Apr 12, 2018

    @CarLoOSX
    Author

    Any ideas ??
    Thank you.

  2. dalexsoto commented on Apr 13, 2018

    @dalexsoto
    Member

    Hello I have tried to reproduce the issue running in both simulator and device (iPhone X using iOS 11.3) using current stable and I am unable to reproduce the issue you are seeing, I have attached both my information log [2] and the sample[1] I am using to try to reproduce this issue.

    Could you please give this sample a try to see if you can reproduce said issue with it? and if so could you outline the details to reproduce it? (Configuration, build logs etc.), also please attach your version information.

    The easiest way to get exact version information:

    • On Visual Studio for Mac: "Visual Studio" menu, "About Visual Studio" item, "Show Details" button.
    • On Visual Studio for Windows: "Help menu", "About Microsoft Visual Studio" item.
      Then copy/paste the version information (you can use the "Copy Information" button).

    To get full build logs just set the log verbosity to diagnostic at the following locations:

    • On Visual Studio for Mac: Preferences > Projects > Build
    • On Visual Studio for Windows: Tools > Options > Projects and Solutions > Build and Run

    On Visual Studio Windows you also want to add -v -v -v -v to the mtouch additional arguments by right-clicking the project in the solution explorer and selecting Properties.
    Note: this is done automatically on Visual Studio for Mac when the log verbosity is set to diagnostic.

    [1] GHIssue3928.zip

    [2]

    === Visual Studio Enterprise 2017 for Mac ===
    
    Version 7.4.2 (build 12)
    Installation UUID: 69ef5826-a186-4773-b4f0-bef3d15d8e39
    Runtime:
    	Mono 5.8.1.0 (2017-10/6bf3922f3fd) (64-bit)
    	GTK+ 2.24.23 (Raleigh theme)
    
    	Package version: 508010000
    
    === NuGet ===
    
    Version: 4.3.1.4445
    
    === .NET Core ===
    
    Runtime: /usr/local/share/dotnet/dotnet
    Runtime Versions:
    	2.0.5
    	2.0.3
    	2.0.0
    SDK: /usr/local/share/dotnet/sdk/2.1.4/Sdks
    SDK Versions:
    	2.1.4
    	2.0.3
    	2.0.0
    MSBuild SDKs: /Library/Frameworks/Mono.framework/Versions/5.8.1/lib/mono/msbuild/15.0/bin/Sdks
    
    === Xamarin.Profiler ===
    
    Version: 1.6.1
    Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler
    
    === Apple Developer Tools ===
    
    Xcode 9.3 (14154)
    Build 9E145
    
    === Xamarin.Mac ===
    
    Version: 4.2.1.28 (Visual Studio Enterprise)
    
    === Xamarin.iOS ===
    
    Version: 11.9.1.24 (Visual Studio Enterprise)
    Hash: f62de472
    Branch: xcode9.3
    Build date: 2018-03-29 19:30:53-0400
    
    === Xamarin.Android ===
    
    Version: 8.2.0.16 (Visual Studio Enterprise)
    Android SDK: /Users/alex/Library/Developer/Xamarin/android-sdk-macosx
    	Supported Android versions:
    		4.0.3  (API level 15)
    		4.1    (API level 16)
    		4.2    (API level 17)
    		4.3    (API level 18)
    		4.4    (API level 19)
    		4.4.87 (API level 20)
    		5.0    (API level 21)
    		5.1    (API level 22)
    		6.0    (API level 23)
    		7.0    (API level 24)
    		7.1    (API level 25)
    		8.0    (API level 26)
    
    SDK Tools Version: 26.1.1
    SDK Platform Tools Version: 27.0.1
    SDK Build Tools Version: 26.0.3
    
    Java SDK: /usr
    java version "1.8.0_131"
    Java(TM) SE Runtime Environment (build 1.8.0_131-b11)
    Java HotSpot(TM) 64-Bit Server VM (build 25.131-b11, mixed mode)
    
    Android Designer EPL code available here:
    https://github.com/xamarin/AndroidDesigner.EPL
    
    === Xamarin Inspector ===
    
    Version: 1.4.0
    Hash: b3f92f9
    Branch: master
    Build date: Fri, 19 Jan 2018 22:00:34 GMT
    Client compatibility: 1
    
    === Build Information ===
    
    Release ID: 704020012
    Git revision: 0d8e3f0a4d683771f17959739956fa09c7ba21e3
    Build date: 2018-03-30 10:45:17-04
    Xamarin addins: 958839ea56ab1e331caf7c92b6ad50fb9e6ee9d2
    Build lane: monodevelop-lion-d15-6
    
    === Operating System ===
    
    Mac OS X 10.13.4
    Darwin 17.5.0 Darwin Kernel Version 17.5.0
        Mon Mar  5 22:24:32 PST 2018
        root:xnu-4570.51.1~1/RELEASE_X86_64 x86_64
    
    === Enabled user installed addins ===
    
    Internet of Things (IoT) development (Preview) 7.1
    
  3. added
    iOS
    need-info
    on Apr 13, 2018
  4. added this to the Future milestone on Apr 13, 2018
  5. CarLoOSX commented on Apr 13, 2018

    @CarLoOSX
    Author

    Hello @dalexsoto I found the solution. Xamarin's example only was worked in simulator but I changed the method signature to :

    public override void RunJavaScriptConfirmPanel(WKWebView webView, string message, WKFrameInfo frame, Action completionHandler)
    {

    Without any Foundation Export and now is working in simulator and phisical device.

    Sorry for the late answer, I was sleeping 😴

    Thank you.

  6. added
    support
    on Sep 7, 2018
  7. ghost locked as resolved and limited conversation to collaborators on May 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    iOSneed-infosupport

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions