CN115878282A - Cross-platform interaction method, device and equipment - Google Patents
Cross-platform interaction method, device and equipment Download PDFInfo
- Publication number
- CN115878282A CN115878282A CN202211329294.3A CN202211329294A CN115878282A CN 115878282 A CN115878282 A CN 115878282A CN 202211329294 A CN202211329294 A CN 202211329294A CN 115878282 A CN115878282 A CN 115878282A
- Authority
- CN
- China
- Prior art keywords
- platform
- cross
- native application
- interface
- development
- Prior art date
- Legal status (The legal status 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 status listed.)
- Pending
Links
Images
Landscapes
- Stored Programmes (AREA)
Abstract
The application discloses a cross-platform interaction method, a cross-platform interaction device and cross-platform interaction equipment, relates to the technical field of computers, and can directly call an interface of a native application platform by using development codes to execute a target communication method so as to improve interaction execution efficiency. The method comprises the following steps: an external function interface is used as a cross-platform interaction mechanism of a development platform and a native application platform, and a universal method library corresponding to the native application platform interface is packaged in a framework layer of the development platform; responding to a cross-platform interaction instruction initiated by a development platform, calling a universal method library by using an external function interface, and inquiring a cross-platform interaction target communication method from the universal method library; performing code language conversion on the parameter object of the target communication method in a framework layer of a development platform to obtain a parameter object of a universal code language; and transmitting the parameter object of the universal code language to the native application platform.
Description
Technical Field
The present application relates to the field of computer technologies, and in particular, to a cross-platform interaction method, apparatus, and device.
Background
The user interface is a medium between a person and a computer, a user performs information interaction with the computer through the user interface, and the quality of the user interface is important for a software system as the quality of the user interface is related to whether the performance of an application function system is fully exerted.
In the related technology, a cross-platform development framework is used, a developer can be helped to construct a multi-platform development kit through a set of code blocks, the mobile development field is used in more scenes, a development application comprises a UI (user interface) and user interaction logic, the cross-platform development framework can help realize that a set of code rapid construction interfaces operate on two platforms, but complex business scenes are involved and system functions depending on native applications are needed, so that the interaction between the development platform and the native application platform needs to be realized by the developer, and the cross-platform development framework is a UI interface framework and needs to call the interfaces of the native application platform through the development platform when functions such as positioning, system and equipment information, microphones and the like are used. Specifically, in practical application, the development platform can send messages to hosts where other application programs are located in a method channel mode, the hosts monitor the method channels of the platform, after receiving the messages, the hosts call interfaces specific to the platform and send responses back to the development platform, cross-platform interaction of the development platform and native applications is further achieved, and the method channel mode has a certain bottleneck.
Disclosure of Invention
In view of this, the present application provides a cross-platform interaction method, device and apparatus, and mainly aims to solve the problem that a certain bottleneck exists in a cross-platform interaction manner using a communication channel in the prior art, so that a development platform cannot directly call an interface of a native application platform using a development code, and development cost of the cross-platform interaction is increased.
According to a first aspect of the application, a cross-platform interaction method is provided, which comprises the following steps:
the method comprises the steps that an external function interface is used as a cross-platform interaction mechanism of a development platform and a native application platform, and a universal method library corresponding to a native application platform interface is packaged in a framework layer of the development platform;
in response to a cross-platform interaction instruction initiated by a development platform, calling the universal method library by using the external function interface, and inquiring a target communication method of cross-platform interaction from the universal method library;
performing code language conversion on the parameter object of the target communication method in a framework layer of the development platform to obtain a parameter object of a universal code language;
and transmitting the parameter object of the universal code language to the native application platform, so that the native application platform executes the function call of the target communication method according to the parameter object of the universal code language, and returns an execution result to the development platform.
Further, the using an external function interface as a cross-platform interaction mechanism between a development platform and a native application platform, and packaging a general method library corresponding to the native application platform interface in a framework layer of the development platform specifically includes:
providing a calling program of the native application platform at a development platform by using an external function interface, wherein the calling program is used for calling a compiled library of a code language adapted to the native application platform at a framework layer of the development platform;
converting each function in a compiling library of the code language adapted to the native application platform into a function which is called by a framework layer of the development platform correspondingly;
and a function called correspondingly by the framework layer of the development platform is used as the same code to realize a cross-platform interaction mechanism of the development platform and the native application platform, and a general method library corresponding to the native application platform interface is packaged in the framework layer of the development platform.
Further, the method for implementing a cross-platform interaction mechanism between a development platform and a native application platform by using a function called correspondingly by a framework layer of the development platform as the same code, and packaging a general method library corresponding to a native application platform interface in the framework layer of the development platform specifically includes:
defining a data structure body of a universal code language by taking a function called correspondingly by a framework layer of the development platform as the same code;
and packaging a general method library corresponding to the native application platform interface in a framework layer of the development platform by using the data structure body of the general code language.
Further, the responding to a cross-platform interaction instruction initiated by a development platform, calling the general method library by using the external function interface, and querying a target communication method of cross-platform interaction from the general method library specifically includes:
responding to a cross-platform interaction instruction initiated by a development platform, calling the general method library and loading a dynamic link library by using the external function interface;
analyzing a binary file symbol statically linked to a corresponding universal method bound to a native application platform interface by using the dynamic link library, and determining a communication method pointer of cross-platform interaction according to the binary file symbol;
and inquiring a target communication method of cross-platform interaction from the general method library according to the communication method pointer of cross-platform interaction.
Further, the performing, in the framework layer of the development platform, code language conversion on the parameter object of the target communication method to obtain a parameter object of a universal code language specifically includes:
calling a conversion interface of language codes in a framework layer of the development platform;
converting the parameter object of the target communication method into a data type of a code language adapted by a native application platform by using a conversion interface of the language code;
and after the parameter object after the data type conversion is subjected to function signature, returning the parameter object of the universal code language.
Further, after the using the external function interface as a cross-platform interaction mechanism between the development platform and the native application platform, encapsulating a generic method library corresponding to the native application platform interface in a framework layer of the development platform, the method further includes:
after the communication methods in the general method library related to the native application platform interface are aggregated, exposing a uniform interface object in a framework layer of the development platform;
and when detecting a number communication requirement triggered by the development platform through the uniform interface object, initiating a cross-platform interaction instruction to the native application according to the number communication requirement.
Further, before the responding to a cross-platform interaction instruction initiated by a development platform, calling the general method library by using the external function interface, and inquiring a target communication method of cross-platform interaction from the general method library, the method further comprises:
the method comprises the steps of obtaining a system method library corresponding to a native application platform interface, and packaging the system method library in a framework layer of the development platform in a bridging mode, so that the development platform calls the system method library by utilizing a cross-platform interaction instruction.
According to a second aspect of the present application, there is provided a cross-platform interaction device, comprising:
the system comprises a first packaging unit, a second packaging unit and a third packaging unit, wherein the first packaging unit is used for packaging a general method library corresponding to a native application platform interface in a framework layer of a development platform by using an external function interface as a cross-platform interaction mechanism of the development platform and the native application platform;
the query unit is used for responding to a cross-platform interaction instruction initiated by a development platform, calling the general method library by using the external function interface and querying a cross-platform interaction target communication method from the general method library;
the conversion unit is used for executing code language conversion on the parameter object of the target communication method in a framework layer of the development platform to obtain a parameter object of a universal code language;
and the transmission unit is used for transmitting the parameter object of the universal code language to the native application platform, so that the native application platform executes the function call of the target communication method according to the parameter object of the universal code language and returns the execution result to the development platform.
Further, the first packaging unit includes:
the method comprises the steps that a module is provided, a calling program of a native application platform is provided on a development platform through an external function interface, and the calling program is used for calling a compiling library of a code language adapted to the native application platform on a framework layer of the development platform;
the conversion module is used for converting each function in the compiling library of the code language adapted to the native application platform into a function called by the framework layer of the development platform correspondingly;
and the packaging module is used for realizing a cross-platform interaction mechanism of the development platform and the native application platform by taking the function called correspondingly by the framework layer of the development platform as the same code, and packaging a general method library corresponding to the native application platform interface in the framework layer of the development platform.
Further, the encapsulation module is specifically configured to define a data structure of a universal code language by using a function called by the framework layer of the development platform as the same code; and packaging a general method library corresponding to the native application platform interface in a framework layer of the development platform by using the data structure body of the general code language.
Further, the query unit includes:
the loading module is used for responding to a cross-platform interaction instruction initiated by a development platform, calling the general method library and loading the dynamic link library by using the external function interface;
the determining module is used for analyzing a binary file symbol statically linked to a corresponding universal method bound to a native application platform interface by using the dynamic link library and determining a communication method pointer of cross-platform interaction according to the binary file symbol;
and the query module is used for querying the target communication method of the cross-platform interaction from the general method library according to the communication method pointer of the cross-platform interaction.
Further, the conversion unit includes:
the calling module is used for calling a conversion interface of a language code in a framework layer of the development platform;
the conversion module is used for converting the parameter object of the target communication method into a data type of a code language adapted to a native application platform by using a conversion interface of the language code;
and the signature module is used for returning the parameter object of the universal code language after the parameter object after the data type conversion is subjected to function signature.
Further, the apparatus further comprises:
the exposure unit is used for exposing a unified interface object in a framework layer of the development platform after the external function interface is used as a cross-platform interaction mechanism of the development platform and a native application platform, and a universal method library corresponding to the native application platform interface is packaged in the framework layer of the development platform and communication methods in the universal method library related to the native application platform interface are aggregated;
and the initiating unit is used for initiating a cross-platform interaction instruction to the native application according to the number communication requirement when the number communication requirement triggered by the development platform through the uniform interface object is detected.
Further, the apparatus further comprises:
the second packaging unit is used for obtaining a system method library corresponding to a native application platform interface before the cross-platform interaction instruction initiated by the development platform is responded, the general method library is called by using the external function interface, a target communication method of cross-platform interaction is inquired from the general method library, and the system method library is packaged in a framework layer of the development platform by using a bridging mode, so that the development platform calls the system method library by using the cross-platform interaction instruction.
According to a third aspect of the present application, there is provided a computer device comprising a memory and a processor, the memory storing a computer program, the processor implementing the steps of the method of the first aspect when executing the computer program.
According to a fourth aspect of the present application, there is provided a readable storage medium having stored thereon a computer program which, when executed by a processor, carries out the steps of the method of the first aspect described above.
By means of the technical scheme, compared with a cross-platform interaction mode of a development platform and a native application platform which is realized by using a method channel in the existing mode, the cross-platform interaction method, the cross-platform interaction device and the equipment provided by the application have the advantages that an external function interface is used as a cross-platform interaction mechanism of the development platform and the native application platform, a universal method library corresponding to a native application platform interface is packaged in a framework layer of the development platform, the universal method library is called by using a cross-platform interaction instruction in response to the cross-platform interaction instruction initiated by the development platform, a target communication method of cross-platform interaction is inquired from the universal method library, further, the external function interface is used in the framework layer of the development platform to perform code language conversion on a parameter object received by the development platform, a parameter object of a universal code language is obtained, the parameter object of the universal code language is transmitted to the native application platform, so that the native application platform calls the target communication method according to return an execution result of the parameter object to the development platform, the cross-platform interaction is realized, the whole process uses an external function as the cross-platform interaction mechanism, the cross-platform interaction method is not required to write a cross-platform interaction code, the cross-platform interaction method, the execution cost of the development platform is reduced, and the execution efficiency of the native application platform interaction method can be directly increased by using the target communication method, so that the target communication method, and the target communication method can be used for receiving the target communication method, and the target communication method can be used for the target communication method.
The foregoing description is only an overview of the technical solutions of the present application, and the present application can be implemented according to the content of the description in order to make the technical means of the present application more clearly understood, and the following detailed description of the present application is given in order to make the above and other objects, features, and advantages of the present application more clearly understandable.
Drawings
The accompanying drawings, which are included to provide a further understanding of the application and are incorporated in and constitute a part of this application, illustrate embodiment(s) of the application and together with the description serve to explain the application and not to limit the application. In the drawings:
FIG. 1 is a flowchart illustrating a cross-platform interaction method according to an embodiment of the present application;
FIG. 2 is a schematic flow chart of one embodiment of step 101 of FIG. 1;
FIG. 3 is a schematic flow chart diagram illustrating one embodiment of step 102 of FIG. 1;
FIG. 4 is a schematic flow chart of one embodiment of step 103 of FIG. 1;
FIG. 5 is a schematic flow chart of FIG. 1 after step 101;
FIG. 6 is a schematic structural diagram of a cross-platform interaction device according to an embodiment of the present application;
fig. 7 is a schematic device structure diagram of a computer apparatus according to an embodiment of the present invention.
Detailed Description
The contents of the present invention will now be discussed with reference to several exemplary embodiments. It is to be understood that these examples are discussed only to enable those of ordinary skill in the art to better understand and thus implement the teachings of the present invention, and are not meant to imply any limitations on the scope of the invention.
As used herein, the term "include" and its variants are to be read as open-ended terms meaning "including, but not limited to. The term "based on" is to be read as "based, at least in part, on". The terms "one embodiment" and "an embodiment" are to be read as "at least one embodiment". The term "another embodiment" is to be read as "at least one other embodiment".
In a cross-platform interaction scene, a development platform can send a message to a host where other application programs are located in a mode of using a method channel, the host monitors the method channel of the platform, and after receiving the message, the host calls an interface specific to the platform and sends a response back to the development platform, so that cross-platform interaction between the development platform and a native application is realized.
In order to solve the problem, this embodiment provides a cross-platform interaction method, as shown in fig. 1, which is applied to a development platform side and includes the following steps:
101. and using an external function interface as a cross-platform interaction mechanism of a development platform and a native application platform, and packaging a general method library corresponding to the native application platform interface in a framework layer of the development platform.
The external function interface provides a calling mechanism for interaction with the native application platform for the development platform, and when the external function interface is used, methods or functions of code languages adapted to different platforms need to be corresponded to convert the code language adapted to the native application platform and the code language adapted to the development platform. The code language adapted to the development platform is Dart language, the code language adapted to the native application platform is C language, and a method or a function using C language in the native application platform can be called in the development platform by using an external function interface in the development platform.
In practical applications, a development platform is usually designed as an extensible and layered system, and includes a series of independent libraries depending on its lower layer, and a specific development platform can be divided into three layers, including an upper framework layer, a middle engine layer and a lower embedded layer, where interaction with a native application platform is mainly implemented in the framework layer of the development platform.
Specifically, in the process of packaging the universal method library corresponding to the native application platform interface in the framework layer of the development platform, the calling method corresponding to the native application platform interface may be exported, the calling method may be recompiled to create the universal method library corresponding to the native application platform interface, and the universal method library corresponding to the native application platform interface may be packaged in the development platform. Here, recompilation may use code language substitution for the data structures in the calling method and encode the substituted data results as the address of the pointer from which the subsequent method call is performed.
The execution subject of the embodiment may be a cross-platform interaction device or equipment, and may be configured at a development platform end, the function method corresponding to the native application platform interface is recompiled by using an external interface function to form a universal method library, and the universal method library is encapsulated in a framework layer of the development platform, and the encapsulated universal method library may be equivalent to a shared library, so that method invocation of a cross-platform code language may be realized, dependency of the development platform on the function method in the native application platform may be eliminated, and flexibility of cross-platform interaction may be improved.
102. And in response to a cross-platform interaction instruction initiated by a development platform, calling the general method library by using the external function interface, and inquiring a target communication method of cross-platform interaction from the general method library.
The cross-platform interaction instruction can be function interaction triggered by any service in the development platform, for example, a function of acquiring the electric quantity of equipment, a function of using a microphone of the equipment, an auxiliary positioning function and the like.
In the embodiment of the invention, the external function interface is equivalent to a new language characteristic of a code language tool suitable for the development platform, a set of dynamic loader is provided, the existing function symbol in the memory can be directly searched, the library of the specified path is also supported to be loaded into the memory, and the corresponding target communication method corresponding to the native application platform interface is positioned by using a system query method exposed by a framework layer of the development platform through holding a file handle of the library in the framework layer of the development platform.
Specifically, when the external function interface is used for calling the universal method library, when the framework layer of the development platform detects an entry function, if the universal method library is used, the dynamic link library is loaded into a memory, the file handle of the library is quoted through the dynamic link library, the dynamic link library can access the function symbol of the universal method library and return a function pointer corresponding to the native application platform interface to the development platform side, so that the development platform side can position the target communication method from the universal method library according to the file handle of the library.
103. And performing code language conversion on the parameter object of the target communication method in a framework layer of the development platform to obtain a parameter object of a universal code language.
In the embodiment of the application, the code language conversion relates to the conversion of the return value and the parameter type of the function corresponding to the target communication method, wherein the type is determined by the running environment of the code language in the development platform, and the parameter object after the code language conversion has the structural characteristics of the code language adapted by the native application platform and can execute the method call in the native application platform interface.
It is understood that, since the code language adapted by the development platform does not support some functions of the general-purpose code language, such as operations on file descriptions, decoding of videos, etc., the functions of the corresponding functions can be called by the target communication method, and similarly, the target communication method can also be called directly by using the native application platform.
104. And transmitting the parameter object of the universal code language to the native application platform, so that the native application platform executes the function call of the target communication method according to the parameter object of the universal code language, and returns an execution result to the development platform.
It can be understood that the purpose of cross-platform interaction is to invoke a system function in a lower business scenario from a native application platform, the system function is usually not implemented in a development platform, and after a parameter object of a universal code language is obtained through conversion, the parameter object needs to be transmitted to the native application platform to implement a corresponding system function.
In the example of the present application, in consideration of the operating environment of the native application platform, a cross-platform interactive instruction initiated by the development platform may be received at the native application platform, that is, the native application platform receives a function call of the target communication method, further executes the function call of the target communication method according to a parameter object of the generic code language transmitted by the development platform, and returns an execution result to the development platform.
Compared with the existing cross-platform interaction mode which uses a method channel, the cross-platform interaction method which uses an external function interface as a cross-platform interaction mechanism of the development platform and the native application platform, the method which uses the external function interface as the cross-platform interaction mechanism of the development platform and the native application platform, a universal method library corresponding to a native application platform interface is packaged in a framework layer of the development platform, a cross-platform interaction instruction which is initiated by the development platform is responded, the universal method library is called by using the cross-platform interaction instruction, a cross-platform interaction target communication method is inquired from the universal method library, further, the external function interface is used in the framework layer of the development platform to perform code language conversion on a parameter object received by the development platform, a parameter object of a universal code language is obtained, the parameter object of the universal code language is transmitted to the native application platform, so that the native application platform calls a target communication method according to realize the cross-platform interaction, an execution result of the parameter object is returned to the development platform, the cross-platform interaction is realized, the external function is used as the cross-platform interaction mechanism, the native code of the cross-platform interaction channel is not needed, the development cost of the native application platform is reduced, the development platform, the execution result of the execution of the native application platform is converted into the execution parameter interaction method which can be directly used for programming the execution of the development platform, and the execution of the native application platform interaction target communication method, and the execution efficiency can be improved.
Specifically, in the above embodiment, as shown in fig. 2, the step 101 includes the steps of:
201. and providing a calling program of the native application platform at the development platform by using an external function interface.
202. And converting each function in the compiling library of the code language adapted to the native application platform into a function which is called by the framework layer of the development platform correspondingly.
203. And a function called correspondingly by the framework layer of the development platform is used as the same code to realize a cross-platform interaction mechanism of the development platform and the native application platform, and a general method library corresponding to the native application platform interface is packaged in the framework layer of the development platform.
The calling program is used for calling a compiling library of a code language adapted to a native application platform at a framework layer of a development platform, and in the process of converting each function in the compiling library of the code language adapted to the native application platform into a function called by the framework layer of the development platform correspondingly, binding files of different platform code languages can be generated by using a compiler in consideration of the compiling characteristics of the code languages in different platforms, and the function conversion called correspondingly by different platforms is realized by compiling according to the binding files.
Specifically, in the process of packaging a universal method library corresponding to a native application platform interface in a framework layer of a development platform, a function called correspondingly by the framework layer of the development platform is used as the same code, a data structure body of a universal code language is defined, and the universal method library corresponding to the native application platform interface is packaged in the framework layer of the development platform by using the data structure body of the universal code language. The data structure of the generic code language, in which the called functions can be created and assigned, is defined here using different data types.
Specifically, in the above embodiment, as shown in fig. 3, step 102 includes the following steps:
301. and in response to a cross-platform interaction instruction initiated by a development platform, calling the general method library and loading a dynamic link library by using the external function interface.
302. And analyzing a binary file symbol statically linked to a corresponding universal method bound to a native application platform interface by using the dynamic link library, and determining a cross-platform interactive communication method pointer according to the binary file symbol.
303. And inquiring a target communication method of cross-platform interaction from the general method library according to the communication method pointer of cross-platform interaction.
It can be understood that each platform has an existing method library, and if the universal code language implements communication method library functions of some system devices or system device bottom layers, each function in the communication method library functions can be converted into a function that can be called by the development platform correspondingly, that is, a function of a code language adapted to the development platform is used, and the converted function is used to compile a universal dynamic link library for the device, so that it is not necessary to compile dynamic link libraries for platforms of different system devices respectively, a pointer for calling a communication method is configured in the universal dynamic link library for the device, and a target communication method interacting across platforms can be queried by using the pointer for the communication method in the universal dynamic link library for the device.
The dynamic link library can be directly generated by using a text library of the parser, can be used for application programs of different platforms, and the whole text library of the parser consists of a code language file and a file header. Specifically, after a dynamic link library is loaded, a target communication method which needs to execute a code language conversion parameter object can be analyzed by using an auxiliary function, in a general case, after a cross-platform interaction instruction is triggered, a binary file symbol which correspondingly calls the communication method can be bound to a native application platform interface, a cross-platform interaction communication method pointer can be determined by using the binary file symbol, the communication method pointer is equivalent to a function pointer in a general method library, and the target communication method can be quickly positioned.
Specifically, in the above embodiment, as shown in fig. 4, step 103 includes the following steps:
401. and calling a conversion interface of language codes in a framework layer of the development platform.
402. And converting the parameter object of the target communication method into a data type of a code language adapted by a native application platform by using the conversion interface of the language code.
403. And after the parameter object after the data type conversion is subjected to function signature, returning the parameter object of the universal code language.
It can be understood that, cross-platform interaction requires conversion of all functions and data types to language code environments, and in order to enable parameter objects of methods in code language environments adapted by a development platform to be used in native application platforms, a conversion interface of language codes is used as a plug-in to automatically generate binding codes between different code languages, thereby realizing conversion of parameter objects of target communication methods in different code language environments.
In the embodiment of the application, when a framework layer of a development platform calls a method function of a native application platform interface, in order to realize automatic conversion between parameters and return types when calling different code languages in a cross-platform, a method signature called by a native application platform needs to be acquired, and after a parameter object after data type conversion is subjected to function signature, a parameter object of a universal code language is returned, so that the development platform can call a communication method in the native application platform according to the parameter object of the universal code language.
Further, in the above embodiment, as shown in fig. 5, step 101 includes, after:
501. and after the communication methods in the general method library related to the native application platform interface are aggregated, exposing a uniform interface object in a framework layer of the development platform.
502. And when detecting a number communication requirement triggered by the development platform through the uniform interface object, initiating a cross-platform interaction instruction to the native application according to the number communication requirement.
Further, considering that the development platform can be applied to different device types, and different device types may involve different communication methods when a native application platform is used for method invocation, in order to be compatible with operating systems of different device types, after aggregating processing communication methods in a general method library involved by a native application platform interface, a unified interface object may be exposed in a framework layer of the development platform, so that an interaction logic of the native application platform may invoke the unified interface object for different operating systems.
The method includes the steps that firstly, a bridge layer is used by a development platform to obtain electric quantity information, the electric quantity information is transmitted to a framework layer of the development platform, data types are converted in the framework layer of the development platform, function signatures of code languages adapted to the native application platform are packaged and called to wait for the native application platform to return execution results, meanwhile, the native application platform packages the execution results into an operating environment according to parameter objects transmitted by the framework layer of the development platform after receiving function calls, the function calls and returns the execution results, and the execution results are converted into the code languages adapted to the development platform corresponding to the data types in the framework layer of the development platform and then return to the bridge layer of the development platform.
It is understood that the encapsulation of the generic method library corresponds to the encapsulation of the function corresponding to the native application platform, and in order to further facilitate the native application platform to execute the system call, the method includes, before step 103 of the above embodiment:
the method comprises the steps of obtaining a system method library corresponding to a native application platform interface, and packaging the system method library in a framework layer of a development platform in a bridging mode so that the development platform calls the system method library by utilizing a cross-platform interaction instruction.
In an actual application scenario, a bridge mode is required to be used in an interaction process of a development platform and a native application platform, the bridge mode is equivalent to an auxiliary tool for communication between the development platform and the native application platform, and since the development platform cannot directly call a function of a corresponding interface of the native application platform, a bridge layer needs to be defined in the development platform to complete data interaction between the development platform and the native application platform, so that data information obtained after the native application executes corresponding operations is further received at the development platform, and then corresponding data information is used in the development platform.
In order to facilitate the native application platform to call functions, a system method library corresponding to a native application platform interface can be packaged in a framework layer of a development platform in a bridging mode, so that developers can more conveniently and directly call the functions from the framework layer of the development platform, the specific function call is not only a system interface, and the functions in code languages adapted by other native application platforms can be directly called by the method without writing any glue code.
Further, as a specific implementation of the method in fig. 1-5, an embodiment of the present application provides a cross-platform interaction apparatus, as shown in fig. 6, the apparatus includes: an acquisition unit 71, an inquiry unit 72, a first adjustment unit 73, and a generation unit 74.
The first encapsulation unit 61 is configured to encapsulate, in a framework layer of a development platform, a general method library corresponding to a native application platform interface, using an external function interface as a cross-platform interaction mechanism between the development platform and the native application platform;
the query unit 62 is configured to, in response to a cross-platform interaction instruction initiated by a development platform, use the external function interface to call the general method library, and query a target communication method of cross-platform interaction from the general method library;
a conversion unit 63, configured to perform code language conversion on the parameter object of the target communication method in the framework layer of the development platform to obtain a parameter object of a universal code language;
a transmission unit 64, configured to transmit the parameter object of the generic code language to the native application platform, so that the native application platform executes the function call of the target communication method according to the parameter object of the generic code language, and returns the execution result to the development platform.
Compared with the existing cross-platform interaction mode which uses a method channel to realize the cross-platform interaction mode of a development platform and a native application platform, the cross-platform interaction device provided by the embodiment of the invention uses an external function interface as a cross-platform interaction mechanism of the development platform and the native application platform, encapsulates a general method library corresponding to a native application platform interface in a framework layer of the development platform, responds to a cross-platform interaction instruction initiated by the development platform, calls the general method library by using the cross-platform interaction instruction, queries a cross-platform interaction target communication method from the general method library, further uses the external function interface in the framework layer of the development platform to perform code language conversion on a parameter object received by the development platform to obtain the parameter object of a general code language, transmits the parameter object of the general code language to the native application platform, so that the native application platform calls the target communication method according to the parameter object of the general code language, returns an execution result of the parameter object to the development platform to realize the cross-platform interaction, uses an external function as the cross-platform interaction mechanism in the whole process, does not need to write a native code of the method channel, reduces the development cost of the cross-platform, converts the development platform interaction target communication method into the execution target communication method of the development platform to directly, and can improve the execution efficiency of the native application platform.
In a specific application scenario, the first encapsulation unit 61 includes:
the method comprises the steps that a module is provided, a calling program of a native application platform is provided on a development platform through an external function interface, and the calling program is used for calling a compiling library of a code language adapted to the native application platform on a framework layer of the development platform;
the conversion module is used for converting each function in the compiling library of the code language adapted to the native application platform into a function called by the framework layer of the development platform correspondingly;
and the packaging module is used for realizing a cross-platform interaction mechanism of the development platform and the native application platform by taking the function called correspondingly by the framework layer of the development platform as the same code, and packaging a general method library corresponding to the native application platform interface in the framework layer of the development platform.
In a specific application scenario, the encapsulation module is specifically configured to define a data structure of a universal code language by using a function called by a framework layer of the development platform as a same code; and packaging a general method library corresponding to the native application platform interface in a framework layer of the development platform by using the data structure body of the general code language.
In a specific application scenario, the query unit 62 includes:
the loading module is used for responding to a cross-platform interaction instruction initiated by a development platform, calling the general method library and loading the dynamic link library by using the external function interface;
the determining module is used for analyzing a binary file symbol statically linked to a corresponding universal method bound to a native application platform interface by using the dynamic link library and determining a communication method pointer of cross-platform interaction according to the binary file symbol;
and the query module is used for querying the cross-platform interactive target communication method from the general method library according to the cross-platform interactive communication method pointer.
In a specific application scenario, the conversion unit 63 includes:
the calling module is used for calling a conversion interface of a language code in a framework layer of the development platform;
the conversion module is used for converting the parameter object of the target communication method into a data type of a code language adapted to a native application platform by using a conversion interface of the language code;
and the signature module is used for returning the parameter object of the universal code language after the parameter object after the data type conversion is subjected to function signature.
In a specific application scenario, the apparatus further includes:
the exposure unit is used for exposing a unified interface object in a framework layer of the development platform after the external function interface is used as a cross-platform interaction mechanism of the development platform and a native application platform, and a universal method library corresponding to the native application platform interface is packaged in the framework layer of the development platform and communication methods in the universal method library related to the native application platform interface are aggregated;
and the initiating unit is used for initiating a cross-platform interaction instruction to the native application according to the number communication requirement when the number communication requirement triggered by the development platform through the uniform interface object is detected.
In a specific application scenario, the apparatus further includes:
the second packaging unit is used for obtaining a system method library corresponding to a native application platform interface before the cross-platform interaction instruction initiated by the development platform is responded, the general method library is called by using the external function interface, a target communication method of cross-platform interaction is inquired from the general method library, and the system method library is packaged in a framework layer of the development platform by using a bridging mode, so that the development platform calls the system method library by using the cross-platform interaction instruction.
It should be noted that other corresponding descriptions of the functional units related to the cross-platform interaction device provided in this embodiment may refer to the corresponding descriptions in fig. 1 to fig. 5, and are not described herein again.
Based on the method shown in fig. 1 to fig. 5, correspondingly, an embodiment of the present application further provides a storage medium, on which a computer program is stored, and when the program is executed by a processor, the cross-platform interaction method shown in fig. 1 to fig. 2 is implemented.
Based on such understanding, the technical solution of the present application may be embodied in the form of a software product, which may be stored in a non-volatile storage medium (which may be a CD-ROM, a usb disk, a removable hard disk, etc.), and includes several instructions for enabling a computer device (which may be a personal computer, a server, or a network device, etc.) to execute the method according to the implementation scenarios of the present application.
Based on the method shown in fig. 1 to fig. 5 and the virtual device embodiment shown in fig. 6, in order to achieve the above object, an embodiment of the present application further provides a cross-platform interactive entity device, which may specifically be a computer, a smart phone, a tablet computer, a smart watch, a server, or a network device, and the entity device includes a storage medium and a processor; a storage medium for storing a computer program; a processor for executing a computer program to implement the cross-platform interaction method described above and illustrated in fig. 1-5.
Optionally, the entity device may further include a user interface, a network interface, a camera, a Radio Frequency (RF) circuit, a sensor, an audio circuit, a WI-FI module, and the like. The user interface may include a Display screen (Display), an input unit such as a keypad (Keyboard), etc., and the optional user interface may also include a USB interface, a card reader interface, etc. The network interface may optionally include a standard wired interface, a wireless interface (e.g., WI-FI interface), etc.
In an exemplary embodiment, referring to fig. 7, the entity device includes a communication bus, a processor, a memory, and a communication interface, and may further include an input/output interface and a display device, where the functional units may communicate with each other through the bus. The memory stores computer programs, and the processor is used for executing the programs stored in the memory and executing the painting mounting method in the embodiment.
Those skilled in the art will appreciate that the physical device structure for cross-platform interaction provided by the present embodiment does not constitute a limitation of the physical device, and may include more or fewer components, or combine some components, or arrange different components.
The storage medium may further include an operating system and a network communication module. The operating system is a program for managing hardware and software resources of the actual device for store search information processing, and supports the operation of the information processing program and other software and/or programs. The network communication module is used for realizing communication among components in the storage medium and other hardware and software in the information processing entity equipment.
Through the above description of the embodiments, those skilled in the art will clearly understand that the present application can be implemented by software plus a necessary general hardware platform, and can also be implemented by hardware. Compared with the prior art, the method and the device have the advantages that by applying the technical scheme, an external function is used as a cross-platform interaction mechanism, the native code of a method channel does not need to be written, the development cost of cross-platform interaction is reduced, the parameter object received by the development platform is converted into the parameter object of the universal code language, the development platform can directly call the interface of the native application platform to execute the target communication method by using the development code, and the interaction execution efficiency is improved.
Those skilled in the art will appreciate that the figures are merely schematic representations of one preferred implementation scenario and that the blocks or flow diagrams in the figures are not necessarily required to practice the present application. Those skilled in the art will appreciate that the modules in the devices in the implementation scenario may be distributed in the devices in the implementation scenario according to the description of the implementation scenario, or may be located in one or more devices different from the present implementation scenario with corresponding changes. The modules of the implementation scenario may be combined into one module, or may be further split into a plurality of sub-modules.
The above application serial number is merely for description and does not represent the superiority and inferiority of the implementation scenario. The above disclosure is only a few specific implementation scenarios of the present application, but the present application is not limited thereto, and any variations that can be made by those skilled in the art are intended to fall within the scope of the present application.
Claims (10)
1. A cross-platform interaction method is characterized by comprising the following steps:
the method comprises the steps that an external function interface is used as a cross-platform interaction mechanism of a development platform and a native application platform, and a universal method library corresponding to the native application platform interface is packaged in a framework layer of the development platform;
responding to a cross-platform interaction instruction initiated by a development platform, calling the general method library by using the external function interface, and inquiring a target communication method of cross-platform interaction from the general method library;
performing code language conversion on the parameter object of the target communication method in a framework layer of the development platform to obtain a parameter object of a universal code language;
and transmitting the parameter object of the universal code language to the native application platform, so that the native application platform executes the function call of the target communication method according to the parameter object of the universal code language, and returns an execution result to the development platform.
2. The method according to claim 1, wherein the using an external function interface as a cross-platform interaction mechanism between a development platform and a native application platform packages a generic method library corresponding to the native application platform interface in a framework layer of the development platform, specifically comprising:
providing a calling program of the native application platform at a development platform by using an external function interface, wherein the calling program is used for calling a compiled library of a code language adapted to the native application platform at a framework layer of the development platform;
converting each function in a compiling library of the code language adapted to the native application platform into a function called by a framework layer of the development platform correspondingly;
and a function called correspondingly by the framework layer of the development platform is used as the same code to realize a cross-platform interaction mechanism of the development platform and the native application platform, and a general method library corresponding to the native application platform interface is packaged in the framework layer of the development platform.
3. The method according to claim 2, wherein the cross-platform interaction mechanism between the development platform and the native application platform is implemented by using functions called by the framework layer of the development platform as the same code, and the packaging of the generic method library corresponding to the native application platform interface in the framework layer of the development platform specifically includes:
defining a data structure body of a universal code language by taking a function called correspondingly by a framework layer of the development platform as the same code;
and packaging a general method library corresponding to the native application platform interface in a framework layer of the development platform by using the data structure body of the general code language.
4. The method according to claim 1, wherein the step of calling the generic method library using the external function interface in response to a cross-platform interaction instruction initiated by a development platform, and querying the target communication method of the cross-platform interaction from the generic method library specifically comprises:
responding to a cross-platform interaction instruction initiated by a development platform, calling the general method library and loading a dynamic link library by using the external function interface;
analyzing a binary file symbol statically linked to a corresponding universal method bound to a native application platform interface by using the dynamic link library, and determining a communication method pointer of cross-platform interaction according to the binary file symbol;
and inquiring a target communication method of cross-platform interaction from the general method library according to the communication method pointer of cross-platform interaction.
5. The method according to claim 1, wherein performing code language conversion on the parameter object of the target communication method in a framework layer of the development platform to obtain a parameter object of a universal code language specifically includes:
calling a conversion interface of language codes in a framework layer of the development platform;
converting the parameter object of the target communication method into a data type of a code language adapted by a native application platform by using a conversion interface of the language code;
and after the parameter object after the data type conversion is subjected to function signature, returning the parameter object of the universal code language.
6. The method of any of claims 1-5, wherein after the packaging of a generic method library corresponding to a native application platform interface in a framework layer of a development platform using an external function interface as a cross-platform interaction mechanism for the development platform with the native application platform, the method further comprises:
after the communication methods in the general method library related to the native application platform interface are aggregated, exposing a uniform interface object in a framework layer of the development platform;
and when detecting a digital communication requirement triggered by the development platform through the unified interface object, initiating a cross-platform interaction instruction to the native application according to the digital communication requirement.
7. The method according to any one of claims 1-5, wherein before the calling the generic method library using the external function interface in response to a development platform initiated cross-platform interaction instruction, querying the generic method library for a target communication method of cross-platform interaction, the method further comprises:
the method comprises the steps of obtaining a system method library corresponding to a native application platform interface, and packaging the system method library in a framework layer of the development platform in a bridging mode, so that the development platform calls the system method library by utilizing a cross-platform interaction instruction.
8. A cross-platform interaction device, comprising:
the system comprises a first packaging unit, a second packaging unit and a third packaging unit, wherein the first packaging unit is used for packaging a general method library corresponding to a native application platform interface in a framework layer of a development platform by using an external function interface as a cross-platform interaction mechanism of the development platform and the native application platform;
the query unit is used for responding to a cross-platform interaction instruction initiated by a development platform, calling the general method library by using the external function interface and querying a cross-platform interaction target communication method from the general method library;
the conversion unit is used for executing code language conversion on the parameter object of the target communication method in a framework layer of the development platform to obtain a parameter object of a universal code language;
and the transmission unit is used for transmitting the parameter object of the universal code language to the native application platform, so that the native application platform executes the function call of the target communication method according to the parameter object of the universal code language and returns the execution result to the development platform.
9. A computer device comprising a memory and a processor, the memory storing a computer program, wherein the processor when executing the computer program implements the steps of the cross-platform interaction method of any one of claims 1 to 7.
10. A computer-readable storage medium, on which a computer program is stored, which, when being executed by a processor, carries out the steps of the cross-platform interaction method of any one of claims 1 to 7.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202211329294.3A CN115878282A (en) | 2022-10-27 | 2022-10-27 | Cross-platform interaction method, device and equipment |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202211329294.3A CN115878282A (en) | 2022-10-27 | 2022-10-27 | Cross-platform interaction method, device and equipment |
Publications (1)
Publication Number | Publication Date |
---|---|
CN115878282A true CN115878282A (en) | 2023-03-31 |
Family
ID=85759051
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202211329294.3A Pending CN115878282A (en) | 2022-10-27 | 2022-10-27 | Cross-platform interaction method, device and equipment |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN115878282A (en) |
-
2022
- 2022-10-27 CN CN202211329294.3A patent/CN115878282A/en active Pending
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US7337436B2 (en) | System and method for cross platform and configuration build system | |
CN111399840B (en) | Module development method and device | |
CN111930382B (en) | Application page access method, device and equipment | |
CN110928548B (en) | Data processing method and device | |
CN114942796B (en) | Plug-in compiling and calling method, device, equipment and storage medium | |
CN113297566A (en) | Sandbox implementation method, sandbox implementation device, sandbox implementation equipment and storage medium | |
CN112395098A (en) | Application program interface calling method and device, storage medium and electronic equipment | |
CN115934093A (en) | Applet cross-terminal application method, related device and computer storage medium | |
CN106775916B (en) | Method and device for reducing application installation packages and electronic equipment | |
CN115237481A (en) | Method, device and equipment for driving external equipment and storage medium | |
US10353700B1 (en) | Code base sharing between standalone and web-based versions of an application via an emulated network communication channel | |
CN109343970B (en) | Application program-based operation method and device, electronic equipment and computer medium | |
CN111324395B (en) | Calling method, device and computer readable storage medium | |
CN111488144B (en) | Data processing method and device | |
JP2005228183A (en) | Program execution method and computer system for executing the program | |
CN114860204B (en) | Program processing and running method and device, terminal, smart card and storage medium | |
CN113961194B (en) | Flutter cross-application-based engineering construction method, system, terminal and medium | |
CN115827278A (en) | Cross-module communication method, system, device and storage medium | |
CN117971350A (en) | Applet operating method, device and computer readable storage medium | |
CN115878282A (en) | Cross-platform interaction method, device and equipment | |
CN114358936A (en) | Intelligent contract operation method based on micro-service block chain | |
CN114064176A (en) | View interaction method and device, electronic equipment and computer readable medium | |
CN117724726B (en) | Data processing method and related device | |
KR20090122703A (en) | Server and method for providing converting contents | |
CN116991380B (en) | Application program construction method and device, electronic equipment and storage medium |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination |