The invention relates to the technical field of cross-platform application communication, in particular to a cross-platform
sky-map component
bidirectional communication method and device based on a
message queue, and the method aims at the
bidirectional communication requirements of an
application layer and a WebView layer in a cross-platform
sky-map component, manages concurrent requests through the
message queue, generates a
unique identifier for each instruction, and transmits the
unique identifier to the
application layer through the WebView layer. Accurate matching of messages is realized; data
serialization and deserialization are combined to ensure that cross-layer data formats are uniform, main thread blocking is avoided through an asynchronous calling mechanism, and quick result feedback is achieved through timing
polling; meanwhile, an error retry mechanism is designed for temporary faults such as network errors and WebView abnormity, and the communication reliability is guaranteed. According to the invention, a communication
closed loop from the
application layer to the
communication layer to the WebView layer to the
communication layer to the application layer is realized, the problems of concurrence
processing disorder, easy blocking and weak fault
recovery capability of the existing communication scheme are solved, the method is adaptive to a unit-app X framework and multiple mobile platforms, and the communication efficiency and stability of a cross-platform
sky map component are improved.