mrchandoo / cordova-plugin-decimal-keyboard

Cordova plugin to show decimal keyboard on iPhones
Apache License 2.0
37 stars 71 forks source link

Crashes with Ionic 3 and WK WebView #4

Open jans-y opened 7 years ago

jans-y commented 7 years ago

Hi,

I have experienced crashes until uninstalling this plugin.

Before on UIWebView I didn't experience the problem.

I am using ionic-team WK WebView plugin that is installed as standard when starting new project with ionic start.

ionic info global packages:

@ionic/cli-utils : 1.3.0
Cordova CLI      : 6.5.0 
Ionic CLI        : 3.3.0

local packages:

@ionic/app-scripts              : 1.3.7
@ionic/cli-plugin-cordova       : 1.3.0
@ionic/cli-plugin-ionic-angular : 1.3.0
Cordova Platforms               : android 6.2.3 ios 4.4.0
Ionic Framework                 : ionic-angular 3.3.0

Installed plugins: cordova-plugin-console 1.0.5 "Console" cordova-plugin-crosswalk-webview 2.2.0 "Crosswalk WebView Engine" cordova-plugin-device 1.1.4 "Device" cordova-plugin-facebook4 1.9.1 "Facebook Connect" cordova-plugin-inappbrowser 1.4.0 "InAppBrowser" cordova-plugin-intercom 3.2.2 "Intercom" cordova-plugin-network-information 1.3.3 "Network Information" cordova-plugin-splashscreen 4.0.3 "Splashscreen" cordova-plugin-statusbar 2.2.1 "StatusBar" cordova-plugin-whitelist 1.3.1 "Whitelist" cordova-plugin-wkwebview-engine 1.1.4-dev "Cordova WKWebView Engine" cordova-sqlite-storage 2.0.4 "Cordova sqlite storage plugin" ionic-plugin-deploy 0.6.7 "IonicDeploy" ionic-plugin-keyboard 2.2.1 "Keyboard"

CooleyGit commented 7 years ago

I had the same issue, I reported it about a month ago but it was closed bc author couldn't reproduce. This plugin doesn't seem to support Ionic 3 and WK WebView but I would love to be able to use it with Ionic.

ericdesa commented 7 years ago

The plugin is build for UIWebview, not WKWebview. The app crash on stringByEvaluatingJavaScriptFromString calls (https://github.com/mrchandoo/cordova-plugin-decimal-keyboard/blob/master/src/ios/CDVDecimalKeyboard.m#L164)

Here is the crash log :

[WKWebView stringByEvaluatingJavaScriptFromString:]: unrecognized selector sent to instance 0x7fe7cb81bc00
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[WKWebView stringByEvaluatingJavaScriptFromString:]: unrecognized selector sent to instance 0x7fe7cb81bc00'
    *** First throw call stack:
    (
        0   CoreFoundation                      0x00000001038e2b0b __exceptionPreprocess + 171
        1   libobjc.A.dylib                     0x0000000102c7b141 objc_exception_throw + 48
        2   CoreFoundation                      0x0000000103952134 -[NSObject(NSObject) doesNotRecognizeSelector:] + 132
        3   CoreFoundation                      0x0000000103869840 ___forwarding___ + 1024
        4   CoreFoundation                      0x00000001038693b8 _CF_forwarding_prep_0 + 120
        5   TransHY'tion                        0x0000000101fc65ac -[CDVDecimalKeyboard isTextAndDecimal] + 60
        6   TransHY'tion                        0x0000000101fc629b -[CDVDecimalKeyboard processKeyboardShownEvent] + 43
        7   TransHY'tion                        0x0000000101fc61f6 __41-[CDVDecimalKeyboard keyboardWillAppear:]_block_invoke + 38
        8   libdispatch.dylib                   0x0000000109b94792 _dispatch_client_callout + 8
        9   libdispatch.dylib                   0x0000000109b7867b _dispatch_continuation_pop + 498
        10  libdispatch.dylib                   0x0000000109b89128 _dispatch_source_latch_and_call + 227
        11  libdispatch.dylib                   0x0000000109b8215f _dispatch_source_invoke + 1150
        12  libdispatch.dylib                   0x0000000109b7c0a4 _dispatch_main_queue_callback_4CF + 622
        13  CoreFoundation                      0x00000001038a7909 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
        14  CoreFoundation                      0x000000010386dae4 __CFRunLoopRun + 2164
        15  CoreFoundation                      0x000000010386d016 CFRunLoopRunSpecific + 406
        16  GraphicsServices                    0x00000001061cba24 GSEventRunModal + 62
        17  UIKit                               0x00000001045e6134 UIApplicationMain + 159
        18  TransHY'tion                        0x0000000101f987f1 main + 65
        19  libdyld.dylib                       0x0000000109bdd65d start + 1
    )

I think we can make a wrapper to call the right function if the user use a WKWebview. instead of the UIWebView : https://developer.apple.com/documentation/webkit/wkwebview/1415017-evaluatejavascript

trfletch commented 7 years ago

Did anyone find a solution to this? I was planning on using it but have recently updated to use wkwebview due to layout issues on ios11 and can no longer use this plugin.

dgproductions88 commented 6 years ago
mrchandoo commented 6 years ago

Plugin currently doesnt support WK, it uses UIWebview, need some volunteers to look into it.

ericdesa commented 6 years ago

Hello, i made a PR to solve this issue : https://github.com/mrchandoo/cordova-plugin-decimal-keyboard/pull/12

john-doherty commented 6 years ago

Any change of getting this merged ^ ?

john-doherty commented 6 years ago

For those unable to wait for a merge, I forked, renamed and published to npm. You can install using:

cordova plugin add --save cordova-plugin-decimal-keyboard-wkwebview

I can confirm it's working fine with the above merged pull request. Thank you @ericdesa

ericdesa commented 6 years ago

glad it helped you @john-doherty ;-)

aiba commented 6 years ago

I had this same issue when installing from npm, e.g. cordova plugin add cordova-plugin-decimal-keyboard.

However, it works when I add it straight from the git repo:

cordova plugin add 'https://github.com/mrchandoo/cordova-plugin-decimal-keyboard'

Perhaps we need to publish a new version?