首页 文章

iOS中的Ionic,phonegap nfc异常

提问于
浏览
0

我正在开发一个读取nfc标签的Ionic应用程序 . 但是当我在iOS中运行它时,我从nfc标签获得结果,但之后我得到了NSExcetion .

以下是我试图阅读NFC标签的代码部分:

if(this.platform.is("ios")) {
      this.nfc.beginSession().subscribe(() => {
        this.nfc.addNdefListener((data) => {
          console.log("IOS: ",data) // You will not see this, at this point the app will crash
        })
      });  
  }

我从来没有得到console.log !!!!!

这些是我在Xcode(版本9.2)中遇到的错误:

2018-02-01 09:06:57.987510-0500 androidSDK[1819:852595]   readerSessionDidBecomeActive
2018-02-01 09:07:03.035369-0500 androidSDK[1819:852705] NFCNDEFReaderSession didDetectNDEFs
2018-02-01 09:07:03.035641-0500 androidSDK[1819:852705] {"ndefMessage":[{"tnf":1,"id":[],"payload":[2,101,110,72,101,108,108,111,46,33],"type":[84]},{"tnf":1,"id":[],"payload":[2,101,110,72,101,108,108,111,32,119,111,114,108,100,33,32],"type":[84]}]}
2018-02-01 09:07:03.035975-0500 androidSDK[1819:852430] -[WKWebView stringByEvaluatingJavaScriptFromString:]: unrecognized selector sent to instance 0x15e046200
2018-02-01 09:07:03.036619-0500 androidSDK[1819:852430] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[WKWebView stringByEvaluatingJavaScriptFromString:]: unrecognized selector sent to instance 0x15e046200'
*** First throw call stack:
(0x18121b164 0x180464528 0x181228628 0x18ab933c8 0x181220b10 0x181105ccc 0x104b74880 0x105cfd2cc 0x105cfd28c 0x105d01ea0 0x1811c3344 0x1811c0f20 0x1810e0c58 0x182f8af84 0x18a836804 0x104b2b1cc 0x180c0056c)
libc++abi.dylib: terminating with uncaught exception of type NSException
2018-02-01 09:07:03.036798-0500 androidSDK[1819:852705] didInvalidateWithError Single tag read (null)
  • 离子版:3.19.1

  • iOS平台版本:4.5.4

  • Cordova版本:8.0.0

  • Phonegap-nfc插件:phonegap-nfc 0.7.1 "NFC"

1 回答

  • 1

    问题是插件,它只适用于UIWebView,但你使用的是WKWebView,所以this line失败了

    [(UIWebView*)[self webView] stringByEvaluatingJavaScriptFromString: function];
    

    有一个pull request可用于修复此问题,因此请单击竖起大拇指按钮,这样可能会将其考虑并合并,或者使用fork代替 .

相关问题