WO2022213496A1 - 一种web应用程序访问nfc智能卡的方法及中间件 - Google Patents

一种web应用程序访问nfc智能卡的方法及中间件 Download PDF

Info

Publication number
WO2022213496A1
WO2022213496A1 PCT/CN2021/104179 CN2021104179W WO2022213496A1 WO 2022213496 A1 WO2022213496 A1 WO 2022213496A1 CN 2021104179 W CN2021104179 W CN 2021104179W WO 2022213496 A1 WO2022213496 A1 WO 2022213496A1
Authority
WO
WIPO (PCT)
Prior art keywords
nfc
interface
native
nfc interface
accessing
Prior art date
Application number
PCT/CN2021/104179
Other languages
English (en)
French (fr)
Inventor
桂靖
张新访
董逢华
Original Assignee
武汉天喻信息产业股份有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 武汉天喻信息产业股份有限公司 filed Critical 武汉天喻信息产业股份有限公司
Publication of WO2022213496A1 publication Critical patent/WO2022213496A1/zh

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45504Abstract machines for programme code execution, e.g. Java virtual machine [JVM], interpreters, emulators
    • G06F9/45529Embedded in an application, e.g. JavaScript in a Web browser
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/90Details of database functions independent of the retrieved data types
    • G06F16/95Retrieval from the web
    • G06F16/955Retrieval from the web using information identifiers, e.g. uniform resource locators [URL]
    • G06F16/9566URL specific, e.g. using aliases, detecting broken or misspelled links
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code
    • G06F8/31Programming languages or programming paradigms
    • G06F8/315Object-oriented languages
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/70Software maintenance or management
    • G06F8/76Adapting program code to run in a different environment; Porting
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/54Interprogram communication
    • G06F9/541Interprogram communication via adapters, e.g. between incompatible applications
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/54Interprogram communication
    • G06F9/547Remote procedure calls [RPC]; Web services
    • G06F9/548Object oriented; Remote method invocation [RMI]
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/02Protocols based on web technology, e.g. hypertext transfer protocol [HTTP]
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/34Network arrangements or protocols for supporting network services or applications involving the movement of software or configuration parameters 

Definitions

  • the invention relates to the technical field of communication, in particular to a method and middleware for accessing an NFC smart card by a WEB application.
  • WEB applications with cross-platform advantages are widely used, and users only need a browser to access WEB applications.
  • the existing standard JavaScript interfaces on the WEB side cannot access the native interfaces of many mobile phone systems.
  • WEB developers cannot directly call the native interfaces of Android and iOS, resulting in limitations when using WEB development applications to access different mobile phones.
  • the present invention aims to solve the above-mentioned technical problems, so that a set of standard JavaScript interfaces on the WEB end can access native NFC interfaces of different mobile phone systems.
  • the embodiments of the present invention provide a method and middleware for a WEB application to access an NFC smart card, so as to realize that the native NFC interface of different mobile phone systems can be accessed through a set of WEB-side standard interfaces.
  • a method for accessing an NFC smart card by a WEB application includes: injecting a native method of an NFC interface into a browser control; when the browser control receives an instruction to access the NFC interface, calling the corresponding NFC interface Native method; the NFC interface native method includes NFC interface native methods suitable for different mobile phone systems.
  • the NFC interface native method includes the interface native methods of whether to support NFC, NFC switch state, NFC sticker state callback, NFC open channel, NFC communication, and NFC close channel.
  • injecting the native method of the NFC interface into the browser control includes the steps of: encapsulating the native method of the NFC interface to form encapsulated code; injecting the encapsulated code into the browser control; and the encapsulated code is used to call the corresponding NFC interface native method.
  • the encapsulation of the NFC interface native method to form the encapsulation code includes the steps of: converting the data type of the NFC interface native method into the JavaScript data type and forming the encapsulation code accordingly.
  • the injection of the encapsulation code into a browser control includes the steps of:
  • calling the corresponding NFC interface native method when receiving the access NFC interface instruction includes the steps of: finding out the corresponding package code according to the access NFC interface instruction; calling the corresponding NFC interface by calling the package code native method.
  • the method includes the steps of: calling the native system interface of the mobile phone with the NFC interface native method; obtaining the return result of the native system interface; The result is fed back to the browser control.
  • the feedback of the returned result to the browser control includes the steps of:
  • a middleware for accessing an NFC smart card by a WEB application is provided, characterized in that it is used to: inject the native method of the NFC interface into a browser control;
  • the NFC interface native method includes the NFC interface native method suitable for different mobile phone systems.
  • the encapsulation module is used to: encapsulate the native method of the NFC interface to form encapsulated code; and inject the encapsulated code into a browser control.
  • WEB developers do not need to consider differences in mobile phone systems (whether it is Android, IOS or other mobile phone systems), and only need a set of JavaScript code (interface docking program) to access
  • the NFC interface in different mobile phone systems realizes the reading of NFC smart cards under different mobile phone systems, and broadens the access function of WEB development applications.
  • FIG. 1 is a schematic flowchart of a WEB application accessing an NFC card according to an embodiment of the present invention
  • FIG. 2 is a schematic diagram of a communication process of a middleware for accessing an NFC smart card by a WEB application according to an embodiment of the present invention.
  • An embodiment of the present invention provides a method for a WEB application to access an NFC smart card, so as to realize that the NFC interfaces of different mobile phone systems can be accessed through a set of WEB-side standard interfaces, and the method includes the steps:
  • the NFC interface native methods include NFC interface native methods suitable for different mobile phone systems.
  • NFC is a short-range high-frequency wireless communication technology (Near Field Communication, NFC for short); an interface is a form of constraint, or a connection path, which provides general processing services for unrelated classes.
  • the NFC interface refers to the native NFC interface built into the mobile phone.
  • the NFC interface native method refers to a protocol for invoking the NFC native interface, and the NFC native interface can be invoked only by following the protocol.
  • Different mobile phone systems include Android mobile phone system and Apple's IOS system. IOS13 system has opened the NFC interface. iPhone7 and above models can read and write smart cards through the NFC interface.
  • the instruction for accessing the NFC interface is an instruction for accessing the NFC interface issued by the user through the WEB application, such as reading the balance of the bus card. The user can input the URL address of the WEB application to issue the instruction for accessing the NFC interface.
  • WEB developers do not need to consider differences in mobile phone systems (whether it is Android, IOS or other mobile phone systems), and only need a set of codes (interface docking program) to access
  • the NFC interface in different mobile phone systems realizes the reading of NFC smart cards under different mobile phone systems, and broadens the access function of WEB development applications.
  • the NFC interface native method includes whether to support NFC, NFC switch state, NFC card state callback, NFC open channel, NFC communication and NFC close channel interface native methods, and may also be NFC card type callback or startup. Other NFC interface native methods such as NFC scanning.
  • step S010 further includes the steps of:
  • S011 encapsulate the native method of the NFC interface to form an encapsulation code
  • the encapsulation code is used to call the corresponding native method of the NFC interface.
  • the step S011 further includes the step of: converting the data type of the native method of the NFC interface into the JavaScript data type, and thereby forming the encapsulation code.
  • step S012 further includes the steps of: in the Android system, calling the addJavascriptInterface interface; in the IOS system, calling the addUserScript interface.
  • step S020 includes the steps of:
  • S022 Invoke the corresponding native method of the NFC interface by invoking the encapsulation code.
  • step S022 under the Android system, you can refer to:
  • calling refers to: when a class or program calls the method, property, indexer or event (ie, interface member) described by the interface, the compiler will find the corresponding one through the interface. "Interface function class or structure”, and then execute the function code inside.
  • the method further includes the steps of: calling the native system interface of the mobile phone with the native method of the NFC interface; obtaining the return result of the native system interface; and feeding the return result to the browser control.
  • feeding back the returned result to the browser control further includes the steps of: converting the data type of the returned result to a JavaScript data type; and sending the returned result after the data type conversion to the browser control.
  • the process of WEB application accessing the NFC card is as follows:
  • Step a Inject the native method of the NFC interface into the browser control
  • Step b the browser control receives the NFC interface access instruction issued by the user
  • Step c The browser control finds the native method corresponding to the access instruction in the injected native methods of the NFC interface according to the NFC interface access instruction issued by the user;
  • Step d call the mobile phone system interface to execute the access command according to the native method corresponding to the access command;
  • Step e The mobile phone system interface feeds back the returned result after executing the access command to the browser control;
  • Step f The user obtains the returned result through the browser.
  • the native method of the NFC interface described in step a includes an NFC interface suitable for the Android system, the IOS system and other mobile phone systems, and the specific content of the above-mentioned NFC interface also includes: whether the mobile phone supports NFC, the NFC switch status, NFC sticker status callback, NFC open channel, NFC communication and NFC close channel, etc.
  • the injection method please refer to: Under Android system:
  • step b the user inputs the URL address of the WEB application to issue an NFC interface access instruction, and the access instruction may be to read the balance of the bus card.
  • the browser control performs the corresponding WEB page parsing and rendering.
  • step c after the user issues the NFC interface access command, the browser control can identify the native method corresponding to the access command in the injected native methods of the NFC interface through the encapsulation code after receiving the access modification command.
  • step d when calling different mobile phone system interfaces according to the native method:
  • step e before the returned result after executing the access instruction is fed back to the browser control, the data type of the returned result is also converted to conform to the JavaScript data type.
  • step a according to different NFC access instructions issued by the user, the above steps b to f may be repeated to meet different requirements of the WEB application for accessing the NFC smart card.
  • the embodiment of the present invention also provides a middleware for a WEB application to access an NFC smart card, which is used for: injecting a native method of an NFC interface into a browser control; calling a corresponding native method of the NFC interface when receiving an instruction to access the NFC interface; the NFC interface
  • the interface native methods include NFC interface native methods suitable for different mobile phone systems.
  • the middleware includes: an encapsulation module, which is used to encapsulate the native method of the NFC interface to form encapsulated code and inject the encapsulated code into the browser control.
  • the middleware for accessing the NFC smart card by the WEB application has been injected with native methods for the NFC interface of different mobile phone systems.
  • the middleware finds the native method corresponding to the access instruction, and then invokes the system interface of the corresponding mobile phone system according to the native method to implement the system execution, and feeds back the returned result after the system execution to the WEB terminal.
  • a unified virtual interface can be provided to WEB application developers, and WEB application developers do not need to consider differences in mobile phone systems (whether it is Android, IOS or other mobile phone systems), and only need a set of JavaScript code (Interface docking program) can access NFC interfaces in different mobile phone systems, realize NFC smart card reading under different mobile phone systems, and broaden the access function of WEB development applications.
  • WEB application developers do not need to consider differences in mobile phone systems (whether it is Android, IOS or other mobile phone systems), and only need a set of JavaScript code (Interface docking program) can access NFC interfaces in different mobile phone systems, realize NFC smart card reading under different mobile phone systems, and broaden the access function of WEB development applications.
  • the terms “installed”, “connected” and “connected” should be understood in a broad sense, for example, it may be a fixed connection, a detachable connection, or an integral connection; it may be a mechanical connection, It can also be an electrical connection; it can be a direct connection, an indirect connection through an intermediate medium, or an internal connection between two components.
  • installed should be understood in a broad sense, for example, it may be a fixed connection, a detachable connection, or an integral connection; it may be a mechanical connection, It can also be an electrical connection; it can be a direct connection, an indirect connection through an intermediate medium, or an internal connection between two components.

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Databases & Information Systems (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Computing Systems (AREA)
  • Data Mining & Analysis (AREA)
  • Telephone Function (AREA)
  • Stored Programmes (AREA)

Abstract

一种WEB应用程序访问NFC智能卡的方法及中间件,其特征在于,其包括:将NFC接口原生方法注入浏览器控件;所述浏览器控件收到访问NFC接口指令时调用对应的NFC接口原生方法;所述NFC接口原生方法包括适用于不同手机系统的NFC接口原生方法。该方法实现通过一套WEB端标准接口可以访问不同手机系统的NFC接口。

Description

一种WEB应用程序访问NFC智能卡的方法及中间件 技术领域
本发明涉及通信技术领域,特别涉及一种WEB应用程序访问NFC智能卡的方法及中间件。
背景技术
随着NFC手机的普及,大部分安卓手机都可以通过NFC访问智能卡。苹果公司也在iOS13系统中开放了NFC接口,iPhone7以及iPhone7以上的机型都可以通过NFC读写智能卡。
目前,由于具有跨平台优点WEB应用程序的得到了广泛的应用,用户只需要有浏览器即可访问WEB应用程序。但现有的WEB端的标准JavaScript接口无法访问很多手机系统的原生接口,比如WEB开发者无法直接调用安卓和iOS原生接口,从而造成用WEB开发应用程序访问不同手机时具有局限性。
本发明旨在为解决上述技术问题,使一套WEB端的标准JavaScript接口能够访问不同手机系统的原生NFC接口。
发明内容
本发明实施例提供一种WEB应用程序访问NFC智能卡的方法及中间件,以实现通过一套WEB端标准接口可以访问不同手机系统的原生NFC接口。
一方面,提出了一种WEB应用程序访问NFC智能卡的方法,其特征在于,其包括:将NFC接口原生方法注入浏览器控件;所述浏览器控件收到访问NFC接口指令时调用对应的NFC接口原生方法;所述NFC接口原生方法包括适用于不同手机系统的NFC接口原生方法。
一些实施例中,所述NFC接口原生方法包括是否支持NFC、NFC开关状态、NFC贴卡状态回调、NFC打开通道、NFC通信以及NFC关闭通道的接口原生方法。
一些实施例中,所述将NFC接口原生方法注入浏览器控件,包括步骤:将NFC接口原生方法进行封装形成封装代码;将所述封装代码注入浏览器控件;所述封装代码用于调用对应的NFC接口原生方法。
一些实施例中,所述将NFC接口原生方法进行封装形成封装代码,包括步骤:将NFC接口原生方法的数据类型转换成JavaScript数据类型并以此形成封装代码。
一些实施例中,所述将所述封装代码注入浏览器控件,包括步骤:
在安卓系统下,调用addJavascriptInterface接口;在IOS系统下,调用addUserScript接口。
一些实施例中,所述收到访问NFC接口指令时调用对应的NFC接口原生方法,包括步骤:根据所述访问NFC接口指令找出对应的封装代码;通过调用所述封装代码调用对应的NFC接口原生方法。
一些实施例中,所述收到访问NFC接口指令时调用对应的NFC接口原生方法之后,包括步骤:以NFC接口原生方法调用手机的原生系统接口;获取原生系统接口的返回结果;将所述返回结果反馈给浏览器控件。
一些实施例中,所述将所述返回结果反馈给浏览器控件,包括步骤:
将所述返回结果的数据类型转换为JavaScript数据类型;将数据类型转换后的返回结果发送至浏览器控件。
另一方面,提供了一种WEB应用程序访问NFC智能卡的中间件,其特征在于,其用于:将NFC接口原生方法注入浏览器控件;所述浏览器控件收到访问NFC接口指令时调用对应的NFC接口原生方法;所述NFC接口原生方法包括适用于不同手机系统的NFC接口原生方法。
一些实施例中,所述封装模块用于:将NFC接口原生方法进行封装形成封装代码;将所述封装代码注入浏览器控件。
通过本实施例的方法,在不同的手机系统环境下,WEB开发者不用考虑手机系统的差异(不论是安卓、IOS还是其他手机系统),只需要一 套JavaScript代码(接口对接程序)即可访问不同手机系统中的NFC接口,实现不同手机系统下的NFC智能卡读取,拓宽了WEB开发应用程序的访问功能。
附图说明
为了更清楚地说明本发明实施例中的技术方案,下面将对实施例描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本发明的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。
图1为本发明实施例提供的WEB应用程序访问NFC卡的流程示意图;
图2为本发明实施例提供的一种WEB应用程序访问NFC智能卡的中间件的通信过程示意图。
具体实施方式
为使本发明实施例的目的、技术方案和优点更加清楚,下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例是本发明的一部分实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有做出创造性劳动的前提下所获得的所有其他实施例,都属于本发明保护的范围。
本发明实施例提供了一种WEB应用程序访问NFC智能卡的方法,以实现通过一套WEB端标准接口可以访问不同手机系统的NFC接口,该方法包括步骤:
S010:将NFC接口原生方法注入浏览器控件;
S020:收到访问NFC接口指令时调用对应的NFC接口原生方法。
其中,NFC接口原生方法包括适用于不同手机系统的NFC接口原生方法。
需要说明的是,NFC为一种短距离的高频无线通信技术(Near Field Communication,简称NFC);接口是一种约束形式,或者叫连接通路,它为不相关的类提供通用的处理服务。所述的NFC接口是指内置于手机端的NFC原生接口。所述的NFC接口原生方法是指用于调用NFC原生接口的协议,只需要遵循该协议即可调用NFC原生接口。不同手机系统包括安卓手机系统和苹果公司的IOS系统,IOS13系统开放了NFC接口,iPhone7以及iPhone7以上的机型都可以通过NFC接口读写智能卡。所述的访问NFC接口指令是用户通过WEB应用下达的访问NFC接口的指令,比如读取公交卡余额。用户可输入WEB应用的URL地址下达所述的访问NFC接口指令。
通过本实施例的方法,可在不同的手机系统环境下,WEB开发者不用考虑手机系统的差异(不论是安卓、IOS还是其他手机系统),只需要一套代码(接口对接程序)即可访问不同手机系统中的NFC接口,实现不同手机系统下的NFC智能卡读取,拓宽了WEB开发应用程序的访问功能。
一些实施例中,所述NFC接口原生方法包括是否支持NFC、NFC开关状态、NFC贴卡状态回调、NFC打开通道、NFC通信以及NFC关闭通道的接口原生方法,还可以是NFC卡片类型回调或者启动NFC扫描等其他的NFC接口原生方法。
一些实施例中,步骤S010还包括步骤:
S011:将NFC接口原生方法进行封装形成封装代码;
S012:将所述封装代码注入浏览器控件;
所述封装代码用于调用对应的NFC接口原生方法。
在一些实施例中,步骤S011还包括步骤:将NFC接口原生方法的数据类型转换成JavaScript数据类型并以此形成封装代码。
在一些实施例中,步骤S012还包括步骤:在安卓系统下,调用addJavascriptInterface接口;在IOS系统下,调用addUserScript接口。
具体地,在安卓系统下,可参考:
https://developer.android.google.cn/reference/android/webkit/WebView?hl=en,根据网页中所记载的方法调用addJavascriptInterface接口;在IOS系统下,可参考:
https://developer.apple.com/documentation/webkit/wkusercontentcontroller?language=occ,根据网页中所记载的方法调用addUserScript接口。
在一些实施例中,步骤S020包括步骤:
S021:根据所述访问NFC接口指令找出对应的封装代码;
S022:通过调用所述封装代码调用对应的NFC接口原生方法。
具体的,在步骤S022中,在安卓系统下,可参考:
https://developer.android.google.cn/reference/android/nfc/NfcManager?hl=en,根据网页提供的方法调用getDefaultAdapter方法。
在IOS系统下,可参考:
https://developer.apple.com/documentation/corenfc/nfcreadersession/3043845-readingavailable,根据网页提供的方法调用readingAvailable方法。
可以理解的是,文中提到的“调用”是指:当有类或程序调用该接口所描述的方法、属性、索引器或事件(即接口成员)时,编译器会通过接口找到对应的那个”接口功能类或结构”,然后执行里面的功能代码。
在一些实施例中,在步骤S020之后,还包括步骤:以NFC接口原生方法调用手机的原生系统接口;获取原生系统接口的返回结果;将所述返回结果反馈给浏览器控件。
在一些实施例中,将所述返回结果反馈给浏览器控件还包括步骤:将所述返回结果的数据类型转换为JavaScript数据类型;将数据类型转换后的返回结果发送至浏览器控件。
如图1所示,在一个具体的实施例中,WEB应用程序访问NFC卡的流程为:
步骤a:将NFC接口原生方法注入到浏览器控件中;
步骤b:浏览器控件接收用户下达的NFC接口访问指令;
步骤c:浏览器控件根据用户下达的NFC接口访问指令在已注入的NFC接口原生方法中找到与访问指令对应的原生方法;
步骤d:根据与访问指令对应的原生方法调用手机系统接口执行访问指令;
步骤e:手机系统接口将执行访问指令后的返回结果反馈至浏览器控件;
步骤f:用户通过浏览器获取返回结果。
需要说明的是,步骤a中所述的NFC接口原生方法包括适用于安卓系统、IOS系统以及其他手机系统的NFC接口,且上述NFC接口的具体内容还包括:手机是否支持NFC、NFC开关状态、NFC贴卡状态回调、NFC打开通道、NFC通信以及NFC关闭通道等。注入的方法可参考:在安卓系统下:
https://developer.android.google.cn/reference/android/webkit/WebView?hl=en,根据网页中所记载的方法调用addJavascriptInterface接口;
在IOS系统下:
https://developer.apple.com/documentation/webkit/wkusercontentcontroller?language=occ,根据网页中所记载的方法调用addUserScript接口。
步骤b中,用户输入WEB应用的URL地址下达NFC接口访问指令,该访问指令可以是读取公交卡余额。浏览器控件进行相应的WEB页面解析和渲染。
步骤c中,用户下达NFC接口访问指令后,浏览器控件接收到改访问指令即可通过封装代码在已注入的NFC接口原生方法中识别出与 访问指令对应的原生方法。
步骤d中,根据原生方法调用不同手机系统接口时:
在安卓系统下,可参考:
https://developer.android.google.cn/reference/android/nfc/NfcManager?hl=en,根据网页提供的方法调用getDefaultAdapter方法。
在IOS系统下,可参考:
https://developer.apple.com/documentation/corenfc/nfcreadersession/3043845-readingavailable,根据网页提供的方法调用readingAvailable方法。
步骤e中,将执行访问指令后的返回结果反馈至浏览器控件前,还对返回结果的数据类型进行转换,使符合JavaScript数据类型。
需要说明的是,在步骤a之后,根据用户下达的不同的NFC访问指令,可以循环上述步骤b至f,以满足WEB应用程序访问NFC智能卡的不同需求。
本发明实施例还提供一种WEB应用程序访问NFC智能卡的中间件,其用于:将NFC接口原生方法注入浏览器控件;收到访问NFC接口指令时调用对应的NFC接口原生方法;所述NFC接口原生方法包括适用于不同手机系统的NFC接口原生方法。
在一些实施例中,所述的中间件包括:封装模块,其用于将NFC接口原生方法进行封装形成封装代码并将所述封装代码注入浏览器控件。
如图2所示,在一个具体的实施例中,WEB应用程序访问NFC智能卡的中间件内已经注入了适用于不同手机系统NFC接口原生方法,当WEB端收到用户下达的NFC接口访问指令后,所述中间件找到与所述访问指令对应的原生方法,再根据原生方法调用对应手机系统的系统接口实现系统执行,并将系统执行后的返回结果反馈至WEB端。
通过本实施例提供的中间件,可向WEB应用开发者提供一个统一 的虚拟接口,WEB应用开发者不用考虑手机系统的差异(不论是安卓、IOS还是其他手机系统),只需要一套JavaScript代码(接口对接程序)即可访问不同手机系统中的NFC接口,实现不同手机系统下的NFC智能卡读取,拓宽了WEB开发应用程序的访问功能。
在本发明的描述中,需要说明的是,术语“上”、“下”等指示的方位或位置关系为基于附图所示的方位或位置关系,仅是为了便于描述本发明和简化描述,而不是指示或暗示所指的装置或元件必须具有特定的方位、以特定的方位构造和操作,因此不能理解为对本发明的限制。除非另有明确的规定和限定,术语“安装”、“相连”、“连接”应做广义理解,例如,可以是固定连接,也可以是可拆卸连接,或一体地连接;可以是机械连接,也可以是电连接;可以是直接相连,也可以通过中间媒介间接相连,可以是两个元件内部的连通。对于本领域的普通技术人员而言,可以根据具体情况理解上述术语在本发明中的具体含义。
需要说明的是,在本发明中,诸如“第一”和“第二”等之类的关系术语仅仅用来将一个实体或者操作与另一个实体或操作区分开来,而不一定要求或者暗示这些实体或操作之间存在任何这种实际的关系或者顺序。而且,术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、方法、物品或者设备不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、方法、物品或者设备所固有的要素。在没有更多限制的情况下,由语句“包括一个……”限定的要素,并不排除在包括所述要素的过程、方法、物品或者设备中还存在另外的相同要素。
以上所述仅是本发明的具体实施方式,使本领域技术人员能够理解或实现本发明。对这些实施例的多种修改对本领域的技术人员来说将是显而易见的,本文中所定义的一般原理可以在不脱离本发明的精神或范围的情况下,在其它实施例中实现。因此,本发明将不会被限 制于本文所示的这些实施例,而是要符合与本文所申请的原理和新颖特点相一致的最宽的范围。

Claims (10)

  1. 一种WEB应用程序访问NFC智能卡的方法,其特征在于,其包括:
    将NFC接口原生方法注入浏览器控件;
    所述浏览器控件收到访问NFC接口指令时调用对应的NFC接口原生方法;
    所述NFC接口原生方法包括适用于不同手机系统的NFC接口原生方法。
  2. 如权利要求1所述的WEB应用程序访问NFC智能卡的方法,其特征在于,
    所述NFC接口原生方法包括是否支持NFC、NFC开关状态、NFC贴卡状态回调、NFC打开通道、NFC通信以及NFC关闭通道的接口原生方法。
  3. 如权利要求1所述的WEB应用程序访问NFC智能卡的方法,其特征在于,
    所述将NFC接口原生方法注入浏览器控件,包括步骤:
    将NFC接口原生方法进行封装形成封装代码;
    将所述封装代码注入浏览器控件;
    所述封装代码用于调用对应的NFC接口原生方法。
  4. 如权利要求3所述的WEB应用程序访问NFC智能卡的方法,其特征在于,
    所述将NFC接口原生方法进行封装形成封装代码,包括步骤:
    将NFC接口原生方法的数据类型转换成JavaScr ipt数据类型并以此形成封装代码。
  5. 如权利要求3所述的WEB应用程序访问NFC智能卡的方法,其特征在于,
    所述将所述封装代码注入浏览器控件,包括步骤:
    在安卓系统下,调用addJavascriptInterface接口;
    在IOS系统下,调用addUserScript接口。
  6. 如权利要求3所述的WEB应用程序访问NFC智能卡的方法,其特征在于,
    所述收到访问NFC接口指令时调用对应的NFC接口原生方法,包括步骤:
    根据所述访问NFC接口指令找出对应的封装代码;
    通过调用所述封装代码调用对应的NFC接口原生方法。
  7. 如权利要求1所述的WEB应用程序访问NFC智能卡的方法,其特征在于,
    所述收到访问NFC接口指令时调用对应的NFC接口原生方法之后,包括步骤:
    以NFC接口原生方法调用手机的原生系统接口;
    获取原生系统接口的返回结果;
    将所述返回结果反馈给浏览器控件。
  8. 如权利要求7所述的WEB应用程序访问NFC智能卡的方法,其特征在于,
    所述将所述返回结果反馈给浏览器控件,包括步骤:
    将所述返回结果的数据类型转换为JavaScript数据类型;
    将数据类型转换后的返回结果发送至浏览器控件。
  9. 一种WEB应用程序访问NFC智能卡的中间件,其特征在于,其用于:
    将NFC接口原生方法注入浏览器控件;
    收到访问NFC接口指令时调用对应的NFC接口原生方法;
    所述NFC接口原生方法包括适用于不同手机系统的NFC接口原生方法。
  10. 如权利要求9所述的一种WEB应用程序访问NFC智能卡的中间件,其特征在于,其包括:
    封装模块,其用于:
    将NFC接口原生方法进行封装形成封装代码;
    将所述封装代码注入浏览器控件。
PCT/CN2021/104179 2021-04-09 2021-07-02 一种web应用程序访问nfc智能卡的方法及中间件 WO2022213496A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202110387493.9A CN113515342A (zh) 2021-04-09 2021-04-09 一种web应用程序访问nfc智能卡的方法及中间件
CN202110387493.9 2021-04-09

Publications (1)

Publication Number Publication Date
WO2022213496A1 true WO2022213496A1 (zh) 2022-10-13

Family

ID=78061885

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2021/104179 WO2022213496A1 (zh) 2021-04-09 2021-07-02 一种web应用程序访问nfc智能卡的方法及中间件

Country Status (2)

Country Link
CN (1) CN113515342A (zh)
WO (1) WO2022213496A1 (zh)

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20090064301A1 (en) * 2007-08-31 2009-03-05 Gemalto, Inc. System and Method for Browser Based Access to Smart Cards
CN106201610A (zh) * 2016-07-06 2016-12-07 青岛海信移动通信技术股份有限公司 Web应用访问终端原生功能的方法及装置
CN107870821A (zh) * 2016-09-26 2018-04-03 平安科技(深圳)有限公司 应用程序的跨平台调用方法及系统
CN109976831A (zh) * 2019-03-28 2019-07-05 山东浪潮通软信息科技有限公司 一种JavaScript和原生APP之间数据交互方法
CN110908704A (zh) * 2019-11-14 2020-03-24 亚信科技(中国)有限公司 一种移动端跨平台原生功能的调用方法及装置

Family Cites Families (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8566420B2 (en) * 2007-11-13 2013-10-22 Nokia Corporation Method and an apparatus comprising a browser
CN102209098B (zh) * 2010-03-30 2015-06-03 北京华虹集成电路设计有限责任公司 智能卡远程检测方法及系统
CN101841569A (zh) * 2010-05-17 2010-09-22 成都中联信通科技有限公司 一种基于web技术实现跨平台的手机支付方法
CN104714890A (zh) * 2015-04-13 2015-06-17 东信和平科技股份有限公司 一种跨平台检测智能卡的方法及系统
CN105741415B (zh) * 2016-01-21 2019-04-16 广东华大互联网股份有限公司 智能卡自动服务终端系统及其应用方法
CN110908712A (zh) * 2019-12-04 2020-03-24 北京中启智源数字信息技术有限责任公司 移动端跨平台的数据处理方法和设备

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20090064301A1 (en) * 2007-08-31 2009-03-05 Gemalto, Inc. System and Method for Browser Based Access to Smart Cards
CN106201610A (zh) * 2016-07-06 2016-12-07 青岛海信移动通信技术股份有限公司 Web应用访问终端原生功能的方法及装置
CN107870821A (zh) * 2016-09-26 2018-04-03 平安科技(深圳)有限公司 应用程序的跨平台调用方法及系统
CN109976831A (zh) * 2019-03-28 2019-07-05 山东浪潮通软信息科技有限公司 一种JavaScript和原生APP之间数据交互方法
CN110908704A (zh) * 2019-11-14 2020-03-24 亚信科技(中国)有限公司 一种移动端跨平台原生功能的调用方法及装置

Also Published As

Publication number Publication date
CN113515342A (zh) 2021-10-19

Similar Documents

Publication Publication Date Title
JP6740373B2 (ja) ページコンポーネント動的レイアウト
CN102209111B (zh) 云计算移动网络终端设备开放性跨平台系统
WO2016192556A1 (zh) 接口调用方法、装置及终端
TWI767182B (zh) 基於h5的接入組件及移動終端
US11706331B2 (en) Information processing method and apparatus, storage medium, and electronic device
WO2012116542A1 (zh) 移动终端浏览器调用本地应用的方法及装置
WO2021169150A1 (zh) 宿主平台层中的应用接口实现方法、装置、设备和介质
JP2020505681A (ja) データ取得方法およびデバイス
CN109240697B (zh) 调用处理方法及装置、存储介质
WO2010072159A1 (zh) 一种获取界面数据方法、系统及数字电视接收终端
US20140258891A1 (en) Electronic device, storage medium and method for processing information
CN103870490A (zh) 一种文件上传的方法及装置
CN110968340A (zh) 一种实现多版本依赖隔离的方法和装置
CN109491802A (zh) 一种基于Unity的RESTFul网络请求的方法及适配器
WO2022213496A1 (zh) 一种web应用程序访问nfc智能卡的方法及中间件
CN102904925B (zh) 一种基于三屏互动的跨平台widget中间件系统
WO2021057390A1 (zh) 一种启动快应用的方法及相关装置
CN110457013B (zh) 程序组件配置装置及方法
WO2023045510A1 (zh) 语音通道建立方法、装置、电子设备及存储介质
CN113315829B (zh) 客户端离线化h5页面加载方法、装置、计算机设备及介质
CN112565031B (zh) 一种ppp连接的参数配置方法与终端
CN114925120A (zh) 保险业务信息查询方法及相关设备
CN113779122B (zh) 导出数据的方法和装置
WO2020221033A1 (zh) 管理设备对远端存储设备进行管理的方法
WO2021203343A1 (zh) Web请求处理方法和装置

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 21935716

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 21935716

Country of ref document: EP

Kind code of ref document: A1