Communication method and system for WeChat applet WebView and native component

A communication method and communication system technology, which are applied in the field of communication methods and systems between WeChat applet WebView and native components, and can solve problems such as limited trigger timing and complex WebView development.

Active Publication Date: 2019-09-27
CTRIP COMP TECH SHANGHAI
View PDF8 Cites 7 Cited by
  • Summary
  • Abstract
  • Description
  • Claims
  • Application Information

AI Technical Summary

Problems solved by technology

[0002] In the current WeChat applet, only through bindmessage (binding message, a property of WebView) can the communication between WebView and native components be realized, and the timing of triggering is very limited. Will trigger, this situation will make the use of WebView development very complicated

Method used

the structure of the environmentally friendly knitted fabric provided by the present invention; figure 2 Flow chart of the yarn wrapping machine for environmentally friendly knitted fabrics and storage devices; image 3 Is the parameter map of the yarn covering machine
View more

Image

Smart Image Click on the blue labels to locate them in the text.
Viewing Examples
Smart Image
  • Communication method and system for WeChat applet WebView and native component
  • Communication method and system for WeChat applet WebView and native component

Examples

Experimental program
Comparison scheme
Effect test

Embodiment 1

[0028] This embodiment provides a communication method between the WeChat applet WebView and native components, such as figure 1 As shown, the method includes the following steps:

[0029] S101. Build a WebSocket server.

[0030] WebSocket is a computer communication protocol that performs full-duplex communication on a single TCP connection. It makes data exchange between the client and the server easier and allows the server to actively push data to the client. WebSocket only needs to complete an HTTP (Hypertext Transfer Protocol) handshake, and a persistent connection can be directly established between the client and the server, and two-way data transmission can be performed. To build a WebSocket server, multiple WebSocket connections can be established with it, and two-way communication can be carried out independently.

[0031] S102. Create a first WebSocket connection connected to the WebSocket server through the native component of the user's WeChat applet.

[0032]...

Embodiment 2

[0047] This embodiment provides a communication system between the WeChat applet WebView and native components, such as figure 2 As shown, the system includes the WebSocket server building module 1, the native component 2 of the user's WeChat applet, and the WebView3 of the user's WeChat applet.

[0048] The server building module 1 is used to build a WebSocket server. A WebSocket server can establish WebSocket connections with multiple clients, and conduct two-way communication independently.

[0049] The WeChat applet may be used by multiple users at the same time, and it is necessary to establish an independent two-way communication mechanism for each user's native component and WebView. The native component 2 of the user's WeChat applet is used to create the first WebSocket connection connected to the WebSocket server.

[0050] After the user's first WebSocket connection is established, the native component 2 of the user's WeChat applet is also used to upload the corres...

the structure of the environmentally friendly knitted fabric provided by the present invention; figure 2 Flow chart of the yarn wrapping machine for environmentally friendly knitted fabrics and storage devices; image 3 Is the parameter map of the yarn covering machine
Login to View More

PUM

No PUM Login to View More

Abstract

The invention discloses a communication method and system for a WeChat applet WebView and a native component. The method comprises the following steps: a WebSocket server is established; a native component of the WeChat applet of the user creates a first WebSocket connection connected with the server; the native component uploads the OpenID corresponding to the user to a server; the WebView creates a second WebSocket connection connected with the server and uploads the OpenID to the server; and according to the OpenID, the WebView is in bidirectional communication with the original component through the first WebSocket and the second WebSocket, and the server. A WebSocket server is established, WebView and a native component respectively establish WebSocket connection connected with the server, association identification is made through an OpenID of a user, and bidirectional communication between the WebView and the native component is achieved.

Description

technical field [0001] The present invention relates to the field of computer software, in particular to a method and system for communicating between a WeChat applet WebView (web view, a component of the WeChat applet) and native components. Background technique [0002] In the current WeChat applet, only through bindmessage (binding message, a property of WebView) can the communication between WebView and native components be realized, and the timing of triggering is very limited. Will trigger, this situation will make the use of WebView development very complicated. Contents of the invention [0003] The technical problem to be solved by the present invention is to overcome the defect that the communication between WebView and native components can only be realized through bindmessage in the prior art, and the trigger timing is very limited, and to provide a communication method between WebView and native components of WeChat applet and system. [0004] The present in...

Claims

the structure of the environmentally friendly knitted fabric provided by the present invention; figure 2 Flow chart of the yarn wrapping machine for environmentally friendly knitted fabrics and storage devices; image 3 Is the parameter map of the yarn covering machine
Login to View More

Application Information

Patent Timeline
no application Login to View More
Patent Type & AuthorityApplications(China)
IPC IPC(8): H04L12/58H04L29/08
CPCH04L51/04H04L67/02H04L67/141
Inventor于磊陈剑崔广宇
OwnerCTRIP COMP TECH SHANGHAI