Cross-platform interaction method, apparatus and device

CN115878282BActive Publication Date: 2026-11-03BEIJING WATERDROP TECH GRP CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202211329294.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-10-27
Publication Date
2026-11-03
Estimated Expiration
2042-10-27

AI Technical Summary

Technical Problem

When using method channels for cross-platform interaction in existing technologies, there are bottlenecks that prevent the development platform from directly calling the native application platform's interfaces, thus increasing the development cost of cross-platform interaction.

Method used

By encapsulating a general method library corresponding to the native application platform interface in the framework layer of the development platform, using external function interfaces as a cross-platform interaction mechanism, responding to the interaction instructions of the development platform, querying the target communication method, and performing code language conversion and parameter object transmission in the framework layer, the interaction between the development platform and the native application platform is realized.

Benefits of technology

It reduces the development cost of cross-platform interaction, improves the efficiency of interaction execution, and enables the development platform to directly call the interface of native applications, reducing the need to write native code.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115878282B_ABST
    Figure CN115878282B_ABST
Patent Text Reader

Abstract

The application discloses a cross-platform interaction method and device and equipment, and relates to the technical field of computers, which can directly call the interface of a native application platform using development code to execute a target communication method, thereby improving interaction execution efficiency. The method comprises the following steps: using an external function interface as a cross-platform interaction mechanism of a development platform and a native application platform, encapsulating a general method library corresponding to the interface of the native application platform in a framework layer of the development platform; in response to a cross-platform interaction instruction initiated by the development platform, calling the general method library using the external function interface, querying a target communication method of cross-platform interaction from the general method library; performing code language conversion on a parameter object of the target communication method in the framework layer of the development platform to obtain a parameter object in a general code language; and transmitting the parameter object in the general code language to the native application platform.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer technology, and in particular to a cross-platform interaction method, apparatus, and device. Background Technology

[0002] The user interface is the medium between humans and computers. Users interact with computers through the user interface, and the quality of the user interface is crucial to whether the application functions can be fully utilized.

[0003] In related technologies, cross-platform development frameworks help developers build multi-platform development toolkits with a single codebase. This is particularly prevalent in mobile development, where applications include UI and user interaction logic. Cross-platform frameworks can help quickly build interfaces that run on two platforms with a single codebase. However, complex business scenarios still rely on native application system functionalities. Therefore, developers need to implement interaction between the development platform and the native application platform. Since a cross-platform development framework is a UI framework, when using features such as location, system and device information, and microphone, it's necessary to call the native application platform's interfaces through the development platform. In practical applications, the development platform can use method channels to send messages to the host application of other applications. The host listens to the platform's method channel, receives the message, calls the platform-specific interface, and sends the response back to the development platform, thus achieving cross-platform interaction between the development platform and the native application. However, the method channel approach has limitations. Because messages and responses are asynchronously transmitted during interaction, both ends need to write native code, preventing the development platform from directly calling the native application platform's interfaces and increasing the development cost of cross-platform interaction. Summary of the Invention

[0004] In view of this, this application provides a cross-platform interaction method, apparatus and device, the main purpose of which is to solve the problem that the existing technology of using communication channels for cross-platform interaction has certain bottlenecks, which makes it impossible for the development platform to directly call the interface of the native application platform using development code, thus increasing the development cost of cross-platform interaction.

[0005] According to the first aspect of this application, a cross-platform interaction method is provided, comprising:

[0006] External function interfaces are used as a cross-platform interaction mechanism between the development platform and the native application platform. A general method library corresponding to the native application platform interface is encapsulated in the framework layer of the development platform.

[0007] In response to a cross-platform interaction command initiated by the development platform, the external function interface is used to call the general method library to query the target communication method for cross-platform interaction from the general method library;

[0008] In the framework layer of the development platform, the parameter object of the target communication method is converted into a code language to obtain a parameter object in a general code language;

[0009] The parameter object of the general-purpose code language is transmitted 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 general-purpose code language and returns the execution result to the development platform.

[0010] Furthermore, the use of external function interfaces as a cross-platform interaction mechanism between the development platform and the native application platform, specifically includes encapsulating a general method library corresponding to the native application platform interfaces within the framework layer of the development platform:

[0011] The development platform provides a caller for the native application platform using an external function interface. The caller is used to call the compilation library of the code language adapted to the native application platform at the framework layer of the development platform.

[0012] Each function in the compilation library of the code language adapted by the native application platform is converted into the corresponding function called by the framework layer of the development platform;

[0013] The cross-platform interaction mechanism between the development platform and the native application platform is implemented using the functions called by the framework layer of the development platform as the same code. A general method library corresponding to the interface of the native application platform is encapsulated in the framework layer of the development platform.

[0014] Furthermore, the method of using the functions called by the framework layer of the development platform as the same code to implement the cross-platform interaction mechanism between the development platform and the native application platform, and encapsulating a general method library corresponding to the interface of the native application platform in the framework layer of the development platform, specifically includes:

[0015] Using the functions called by the framework layer of the development platform as the same code, define a data structure for a general code language;

[0016] Using the data structures of the general-purpose code language, a general-purpose method library corresponding to the native application platform interface is encapsulated in the framework layer of the development platform.

[0017] Furthermore, the step of responding to a cross-platform interaction command initiated by the development platform by using the external function interface to call the general method library and querying the target communication method for cross-platform interaction from the general method library specifically includes:

[0018] In response to cross-platform interaction commands initiated by the development platform, the external function interface is used to call the general method library and load the dynamic link library;

[0019] The dynamic link library is used to parse the binary file symbols that are statically linked to the general methods corresponding to the native application platform interface, and the cross-platform interaction communication method pointers are determined based on the binary file symbols.

[0020] Based on the cross-platform interaction communication method pointer, the target cross-platform interaction communication method is queried from the general method library.

[0021] Furthermore, the step of performing 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 in a general code language specifically includes:

[0022] The language code conversion interface is called within the framework layer of the development platform;

[0023] The parameter object of the target communication method is converted to the data type of the code language adapted to the native application platform using the language conversion interface described above.

[0024] After converting the data type of the parameter object and performing a function signature, the function returns a parameter object in a generic code language.

[0025] Furthermore, after using external function interfaces as a cross-platform interaction mechanism between the development platform and the native application platform, and encapsulating a general method library corresponding to the native application platform interface in the framework layer of the development platform, the method further includes:

[0026] After aggregating the communication methods in the general method library involved in the native application platform interface, a unified interface object is exposed in the framework layer of the development platform.

[0027] When a data communication request triggered by the development platform through the unified interface object is detected, a cross-platform interaction instruction is initiated to the native application according to the data communication request.

[0028] Furthermore, before responding to a cross-platform interaction command initiated by the development platform and using the external function interface to call the general method library to query the target communication method for cross-platform interaction from the general method library, the method further includes:

[0029] Obtain the system method library corresponding to the native application platform interface, and encapsulate the system method library in the framework layer of the development platform using a bridging method, so that the development platform can call the system method library using cross-platform interaction commands.

[0030] According to a second aspect of this application, a cross-platform interactive device is provided, comprising:

[0031] The first encapsulation unit is used to use external function interfaces as a cross-platform interaction mechanism between the development platform and the native application platform, and to encapsulate a general method library corresponding to the native application platform interface in the framework layer of the development platform.

[0032] The query unit is used to respond to cross-platform interaction instructions initiated by the development platform, and use the external function interface to call the general method library to query the target communication method for cross-platform interaction from the general method library;

[0033] The conversion unit is used 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 in a general code language.

[0034] The transmission unit is used to transmit the parameter object of the general-purpose 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 general-purpose code language and returns the execution result to the development platform.

[0035] Furthermore, the first packaging unit includes:

[0036] A module is provided for using an external function interface to provide a calling program for the native application platform on the development platform. The calling program is used to call the compilation library of the code language adapted to the native application platform at the framework layer of the development platform.

[0037] The conversion module is used to convert each function in the compilation library of the code language adapted by the native application platform into the function called by the framework layer of the development platform.

[0038] The encapsulation module is used to implement a cross-platform interaction mechanism between the development platform and the native application platform by using the functions called by the framework layer of the development platform as the same code, and to encapsulate a general method library corresponding to the interface of the native application platform in the framework layer of the development platform.

[0039] Furthermore, the encapsulation module is specifically used to define a data structure of a general-purpose code language using the functions called by the framework layer of the development platform as the same code; and to encapsulate a general-purpose method library corresponding to the native application platform interface in the framework layer of the development platform using the data structure of the general-purpose code language.

[0040] Furthermore, the query unit includes:

[0041] The loading module is used to respond to cross-platform interaction commands initiated by the development platform, and to call the general method library and load the dynamic link library using the external function interface;

[0042] The determination module is used to parse the binary file symbols that are statically linked to the general methods corresponding to the native application platform interface using the dynamic link library, and determine the cross-platform interaction communication method pointers based on the binary file symbols.

[0043] The query module is used to query the target communication method for cross-platform interaction from the general method library based on the pointer to the cross-platform interaction communication method.

[0044] Furthermore, the conversion unit includes:

[0045] The calling module is used to call the language code conversion interface in the framework layer of the development platform;

[0046] The conversion module is used to convert the parameter object of the target communication method into the data type of the code language adapted by the native application platform using the conversion interface of the language code.

[0047] The signature module is used to perform function signatures on parameter objects after data type conversion, and then return parameter objects in a general-purpose code language.

[0048] Furthermore, the device also includes:

[0049] The exposure unit is used to expose a unified interface object in the framework layer of the development platform after encapsulating the general method library corresponding to the native application platform interface in the framework layer of the development platform using the external function interface as a cross-platform interaction mechanism between the development platform and the native application platform, aggregating the communication methods in the general method library involved in the native application platform interface.

[0050] The initiating unit is used to initiate cross-platform interaction instructions to the native application according to the data communication requirements when a data communication requirement is detected by the development platform through the unified interface object.

[0051] Furthermore, the device also includes:

[0052] The second encapsulation unit is used to obtain the system method library corresponding to the native application platform interface before the system method library is called using the external function interface in response to the cross-platform interaction instruction initiated by the development platform, and before the target communication method for cross-platform interaction is queried from the general method library, and the system method library is encapsulated in the framework layer of the development platform in a bridging manner, so that the development platform can call the system method library using the cross-platform interaction instruction.

[0053] According to a third aspect of this application, a computer device is provided, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps of the method described in the first aspect above.

[0054] According to a fourth aspect of this application, a readable storage medium is provided having a computer program stored thereon, which, when executed by a processor, implements the steps of the method described in the first aspect above.

[0055] By utilizing the above technical solutions, this application provides a cross-platform interaction method, apparatus, and device. Compared with the existing methods that use method channels to achieve cross-platform interaction between the development platform and the native application platform, this application uses an external function interface as the cross-platform interaction mechanism between the development platform and the native application platform. It encapsulates a general method library corresponding to the native application platform interface in the framework layer of the development platform. Responding to cross-platform interaction commands initiated by the development platform, it uses the cross-platform interaction commands to call the general method library, queries the target communication method for cross-platform interaction from the general method library, and further uses the external function interface in the framework layer of the development platform to interact with the parameter objects received by the development platform. The code language is converted to obtain a parameter object in a general-purpose code language. This parameter object is then transmitted to the native application platform, enabling the native application platform to call the target communication method based on the parameter object. The execution result of the parameter object is then returned to the development platform, achieving cross-platform interaction. The entire process uses external functions as the cross-platform interaction mechanism, eliminating the need to write native code for method channels and reducing the development cost of cross-platform interaction. By converting the parameter object received by the development platform into a parameter object in a general-purpose code language, the development platform can directly call the interface of the native application platform to execute the target communication method using its own code, thus improving the efficiency of interaction execution.

[0056] The above description is only an overview of the technical solution of this application. In order to better understand the technical means of this application and to implement it in accordance with the contents of the specification, and to make the above and other objects, features and advantages of this application more obvious and understandable, the following are specific embodiments of this application. Attached Figure Description

[0057] The accompanying drawings, which are included to provide a further understanding of this application and form part of this application, illustrate exemplary embodiments and are used to explain this application, but do not constitute an undue limitation of this application. In the drawings:

[0058] Figure 1 This is a flowchart illustrating a cross-platform interaction method in one embodiment of this application;

[0059] Figure 2 yes Figure 1 A flowchart illustrating a specific implementation method of step 101;

[0060] Figure 3 yes Figure 1 A flowchart illustrating a specific implementation method for step 102;

[0061] Figure 4 yes Figure 1 A flowchart illustrating a specific implementation method for step 103;

[0062] Figure 5 yes Figure 1 A flowchart following step 101;

[0063] Figure 6 This is a schematic diagram of the structure of a cross-platform interaction device according to an embodiment of this application;

[0064] Figure 7 This is a schematic diagram of the device structure of a computer device provided in an embodiment of the present invention. Detailed Implementation

[0065] The invention will now be discussed with reference to several exemplary embodiments. It should be understood that these embodiments are described merely to enable those skilled in the art to better understand and thus implement the invention, and are not intended to imply any limitation on the scope of the invention.

[0066] As used herein, the term "comprising" and its variations are to be interpreted as open-ended terms meaning "including but not limited to". The term "based on" is to be interpreted as "at least partially based on". The terms "one embodiment" and "an embodiment" are to be interpreted as "at least one embodiment". The term "another embodiment" is to be interpreted as "at least one other embodiment".

[0067] In cross-platform interaction scenarios, the development platform can use method channels to send messages to the host of other applications. The host listens to the platform's method channel, receives the message, calls the platform-specific interface, and sends the response back to the development platform, thereby enabling cross-platform interaction between the development platform and the native application. However, the method channel approach has certain bottlenecks. Since messages and responses are transmitted asynchronously during the interaction, both ends need to write native code, which prevents the development platform from directly calling the native application platform's interface using its own code, increasing the development cost of cross-platform interaction.

[0068] To address this issue, this embodiment provides a cross-platform interaction method, such as... Figure 1 As shown, this method is applied to the development platform and includes the following steps:

[0069] 101. Use external function interfaces as a cross-platform interaction mechanism between the development platform and the native application platform, and encapsulate a general method library corresponding to the native application platform interface in the framework layer of the development platform.

[0070] The external function interface provides a calling mechanism for the development platform to interact with the native application platform. When using the external function interface, it's necessary to map the methods or functions of the code languages ​​adapted to different platforms, thus converting the code language adapted to the native application platform to the code language adapted to the development platform. Here, the code language adapted to the development platform is Dart, and the code language adapted to the native application platform is C. By using the external function interface in the development platform, methods or functions in C language used in the native application platform can be called from within the development platform.

[0071] In practical applications, development platforms are usually designed as scalable, layered systems that contain a series of independent libraries that depend on their lower layers. Specifically, a development platform can be divided into three layers: the upper framework layer, the middle engine layer, and the lower embedding layer. Here, the main focus is on the interaction between the development platform's framework layer and the native application platform.

[0072] Specifically, in the process of encapsulating the generic method library corresponding to the native application platform interface within the framework layer of the development platform, the calling methods corresponding to the native application platform interface can be exported. These calling methods can then be recompiled to create the generic method library corresponding to the native application platform interface. This generic method library is then encapsulated within the development platform. Here, recompilation can replace the data structures in the calling methods using code language, and the replaced data results can be encoded as pointer addresses. Subsequent method calls are then executed based on these addresses.

[0073] The execution entity in this embodiment can be a cross-platform interactive device or equipment, which can be configured on the development platform. By using external interface functions, the function methods corresponding to the native application platform interface are recompiled to form a general method library. The general method library is encapsulated in the framework layer of the development platform. This encapsulated general method library can be regarded as a shared library, which can realize cross-platform code language method calls, get rid of the development platform's dependence on the function methods in the native application platform, and improve the flexibility of cross-platform interaction.

[0074] 102. In response to the cross-platform interaction command initiated by the development platform, the external function interface is used to call the general method library to query the target communication method for cross-platform interaction from the general method library.

[0075] Among them, cross-platform interaction commands can be functional interactions triggered by any business in the development platform, such as obtaining device battery level, using device microphone, and assisted positioning.

[0076] In this embodiment of the invention, the external function interface is essentially a new language feature of the code language tools adapted to the development platform. It provides a dynamic loader that can directly search for existing function symbols in memory and also supports loading libraries from specified paths into memory. By holding the file handle of this library in the framework layer of the development platform, the target communication method corresponding to the native application platform interface is located using the system query method exposed by the framework layer of the development platform.

[0077] When using an external function interface to call a generic method library, the framework layer of the development platform will load the dynamic link library into memory when it detects the entry function and if the generic method library is used. The dynamic link library references the library file handle, which can access the function symbols of the generic method library and return the function pointer corresponding to the native application platform interface to the development platform side. This allows the development platform side to locate the target communication method from the generic method library based on the library file handle.

[0078] 103. In the framework layer of the development platform, perform code language conversion on the parameter object of the target communication method to obtain a parameter object in a general code language.

[0079] In this embodiment of the application, the code language conversion involves the conversion of the return value and parameter type of the function corresponding to the target communication method. Here, the type is determined by the runtime environment of the code language in the development platform. The parameter object after code language conversion has the structural characteristics of the code language adapted by the native application platform and can execute method calls in the native application platform interface.

[0080] It is understandable that, since the code language adapted by the development platform does not yet support some functions of the general code language, such as file description operations and video decoding, the corresponding functions can be called through the target communication method. Similarly, the target communication method can also be called directly when using the native application platform.

[0081] 104. The parameter object of the general-purpose code language is transmitted 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 general-purpose code language and returns the execution result to the development platform.

[0082] Understandably, the purpose of cross-platform interaction is to call system functions in a business scenario from the native application platform. These system functions are usually not possible in the development platform. After converting the parameter object into a general code language, it is necessary to transfer the parameter object to the native application platform to realize the corresponding system functions.

[0083] In this application example, considering the operating environment of the native application platform, the native application platform can receive cross-platform interaction instructions initiated by the development platform. In other words, the native application platform receives the function call of the target communication method, further executes the function call of the target communication method according to the parameter object of the general code language transmitted by the development platform, and returns the execution result to the development platform.

[0084] The cross-platform interaction method provided in this application, compared with the existing method of using method channels to achieve cross-platform interaction between the development platform and the native application platform, uses an external function interface as the cross-platform interaction mechanism between the development platform and the native application platform. A general method library corresponding to the native application platform interface is encapsulated in the framework layer of the development platform. In response to a cross-platform interaction command initiated by the development platform, the general method library is called using the cross-platform interaction command. The target communication method for cross-platform interaction is queried from the general method library. Furthermore, the external function interface is used in the framework layer of the development platform to perform code language conversion on the parameter object received by the development platform. The development platform obtains a parameter object in a generic code language and transmits it to the native application platform. This allows the native application platform to call the target communication method based on the generic code language parameter object and return the execution result of the parameter object to the development platform, thus achieving cross-platform interaction. The entire process uses external functions as the cross-platform interaction mechanism, eliminating the need to write native code for method channels and reducing the development cost of cross-platform interaction. By converting the parameter object received by the development platform into a generic code language parameter object, the development platform can directly call the native application platform's interface to execute the target communication method using its own code, improving the efficiency of interaction execution.

[0085] Specifically, in the above embodiments, such as Figure 2 As shown, step 101 includes the following steps:

[0086] 201. Use external function interfaces to provide the calling program of the native application platform on the development platform.

[0087] 202. Convert each function in the compilation library of the code language adapted to the native application platform into the corresponding function called by the framework layer of the development platform.

[0088] 203. Implement a cross-platform interaction mechanism between the development platform and the native application platform by using the functions called by the framework layer of the development platform as the same code, and encapsulate a general method library corresponding to the interface of the native application platform in the framework layer of the development platform.

[0089] The calling program is used to call the compilation library of the native application platform's code language at the framework layer of the development platform. In the process of converting each function in the compilation library of the native application platform's code language into the corresponding function called at the framework layer of the development platform, considering the compilation characteristics of code languages ​​on different platforms, the compiler can be used to generate binding files for code languages ​​of different platforms, and the function conversion corresponding to different platforms can be implemented by compiling according to the binding files.

[0090] Specifically, in the process of encapsulating the generic method library corresponding to the native application platform interface within the framework layer of the development platform, the functions called by the framework layer of the development platform are used as the same code. A data structure in a generic code language is defined, and this data structure is used to encapsulate the generic method library corresponding to the native application platform interface within the framework layer of the development platform. Here, the data structure in the generic code language is defined using different data types, and values ​​can be created and assigned within the data structure for the called functions.

[0091] Specifically, in the above embodiments, such as Figure 3 As shown, step 102 includes the following steps:

[0092] 301. In response to a cross-platform interaction command initiated by the development platform, the external function interface is used to call the general method library and load the dynamic link library.

[0093] 302. Use the dynamic link library to parse the binary file symbols that are statically linked to the general methods corresponding to the native application platform interface, and determine the cross-platform interaction communication method pointers based on the binary file symbols.

[0094] 303. Based on the cross-platform interaction communication method pointer, query the target cross-platform interaction communication method from the general method library.

[0095] Understandably, each platform has its own existing method libraries. If the common code language implements communication method library functions that are either system devices or built into the underlying communication methods of the system devices, then each function in the communication method library can be converted into a function that the development platform can call. That is, the function is adapted to the code language of the development platform, and the converted function is used to compile a device-wide dynamic link library. This way, there is no need to compile dynamic link libraries separately for different system devices. The device-wide dynamic link library contains pointers to call communication methods, and the target communication method for cross-platform interaction can be found by using the pointers to the communication methods in the device-wide dynamic link library.

[0096] The dynamic link library here can be directly generated using the parser's text library, enabling its use in applications across different platforms. The entire parser's text library consists of a code language file and a header. Specifically, after loading the dynamic link library, helper functions can be used to parse the target communication method that requires the code language conversion parameter object. Typically, after triggering a cross-platform interaction instruction, the binary file symbol of the corresponding communication method call is bound to the native application platform interface. Using the binary file symbol, the pointer to the cross-platform interaction communication method can be determined. This communication method pointer is equivalent to a function pointer in a general method library, allowing for quick location of the target communication method.

[0097] Specifically, in the above embodiments, such as Figure 4 As shown, step 103 includes the following steps:

[0098] 401. Call the language code conversion interface in the framework layer of the development platform.

[0099] 402. Use the language code conversion interface to convert the parameter object of the target communication method to the data type of the code language adapted to the native application platform.

[0100] 403. After converting the data type of the parameter object, perform a function signature and return the parameter object in a general code language.

[0101] Understandably, cross-platform interaction requires all functions and data types to be converted to different language code environments. In order to enable the parameter objects of methods in the code language environment adapted by the development platform to be used in the native application platform, a language code conversion interface is used as a plugin to generate binding code between different code languages, thereby realizing the conversion of the parameter objects of the target communication method in different code language environments.

[0102] In this embodiment of the application, when the framework layer of the development platform calls the method function of the native application platform interface, in order to achieve automatic conversion of parameters and return types when calling different code languages ​​across platforms, it is necessary to obtain the method signature of the native application platform. Here, the parameter object after data type conversion is signed by function and the parameter object of the general code language is returned so that the development platform can call the communication method in the native application platform according to the parameter object of the general code language.

[0103] Furthermore, in the above embodiments, such as Figure 5 As shown, step 101 is followed by:

[0104] 501. After aggregating the communication methods in the general method library involved in the native application platform interface, expose a unified interface object in the framework layer of the development platform.

[0105] 502. When a data communication request triggered by the development platform through the unified interface object is detected, a cross-platform interaction instruction is initiated to the native application according to the data communication request.

[0106] Furthermore, considering that the development platform can be applied to different device types, and different device types will involve different communication methods when using the native application platform to make method calls, in order to be compatible with the operating systems of different device types, the communication methods in the common method library involved in the native application platform interface can be aggregated and then a unified interface object can be exposed in the framework layer of the development platform, so that the interaction logic of the native application platform can call the unified interface object for different operating systems.

[0107] Taking the interaction between the development platform and the native application platform to obtain battery information as an example, the development platform first uses a bridging layer to obtain the battery information and passes it to the framework layer of the development platform. In the framework layer of the development platform, data type conversion is performed, the function signature of the code language adapted to the native application platform is encapsulated, and the function is called, waiting for the native application platform to return the execution result. At the same time, after receiving the function call, the native application platform encapsulates the parameter object passed from the framework layer of the development platform into the runtime environment, executes the function call, and returns the execution result. The framework layer of the development platform converts the data type corresponding to the execution result to the code language adapted to the development platform and returns it to the bridging layer of the development platform.

[0108] It is understandable that the encapsulation of the general method library is equivalent to the encapsulation of the functions called by the native application platform. In order to further facilitate the execution of system calls by the native application platform, the following is included before step 103 in the above embodiment:

[0109] Obtain the system method library corresponding to the native application platform interface, and encapsulate the system method library in the framework layer of the development platform using a bridging approach, so that the development platform can call the system method library using cross-platform interaction commands.

[0110] In practical application scenarios, the interaction between the development platform and the native application platform requires the use of the bridging pattern. Here, the bridging pattern is equivalent to an auxiliary tool for communication between the development platform and the native application platform. Since the development platform cannot directly call the corresponding interface functions of the native application platform, a bridging layer needs to be defined in the development platform to complete the data interaction between the development platform and the native application platform. This allows the development platform to receive the data information obtained after the native application performs the corresponding operation, and then use the corresponding data information in the development platform.

[0111] To facilitate function calls from the native application platform, the system method library corresponding to the native application platform interface can be encapsulated in the framework layer of the development platform using a bridging approach. This makes it easier for developers to directly call functions from the framework layer of the development platform. The specific function calls are not limited to system interfaces; functions in other native application platform-compatible code languages ​​can also be directly called through this method without writing any glue code.

[0112] Furthermore, as Figure 1-5 To specifically implement the method, this application provides a cross-platform interactive device, such as... Figure 6 As shown, the device includes: an acquisition unit 71, a query unit 72, a first adjustment unit 73, and a generation unit 74.

[0113] The first encapsulation unit 61 is used to use an external function interface as a cross-platform interaction mechanism between the development platform and the native application platform, and to encapsulate a general method library corresponding to the native application platform interface in the framework layer of the development platform.

[0114] The query unit 62 is used to respond to the cross-platform interaction command initiated by the development platform, use the external function interface to call the general method library, and query the target communication method for cross-platform interaction from the general method library;

[0115] The conversion unit 63 is used 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 in a general code language.

[0116] The transmission unit 64 is used to transmit the parameter object of the general 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 general code language and returns the execution result to the development platform.

[0117] The cross-platform interaction device provided in this invention, compared with the existing method of using method channels to achieve cross-platform interaction between the development platform and the native application platform, uses an external function interface as the cross-platform interaction mechanism between the development platform and the native application platform. A general method library corresponding to the native application platform interface is encapsulated in the framework layer of the development platform. In response to a cross-platform interaction command initiated by the development platform, the general method library is invoked using the cross-platform interaction command to query the target communication method for cross-platform interaction from the general method library. Furthermore, the external function interface is used in the framework layer of the development platform to perform code language conversion on the parameter object received by the development platform. The development platform obtains a parameter object in a generic code language and transmits it to the native application platform. This allows the native application platform to call the target communication method based on the generic code language parameter object and return the execution result of the parameter object to the development platform, thus achieving cross-platform interaction. The entire process uses external functions as the cross-platform interaction mechanism, eliminating the need to write native code for method channels and reducing the development cost of cross-platform interaction. By converting the parameter object received by the development platform into a generic code language parameter object, the development platform can directly call the native application platform's interface to execute the target communication method using its own code, improving the efficiency of interaction execution.

[0118] In a specific application scenario, the first packaging unit 61 includes:

[0119] A module is provided for using an external function interface to provide a calling program for the native application platform on the development platform. The calling program is used to call the compilation library of the code language adapted to the native application platform at the framework layer of the development platform.

[0120] The conversion module is used to convert each function in the compilation library of the code language adapted by the native application platform into the function called by the framework layer of the development platform.

[0121] The encapsulation module is used to implement a cross-platform interaction mechanism between the development platform and the native application platform by using the functions called by the framework layer of the development platform as the same code, and to encapsulate a general method library corresponding to the interface of the native application platform in the framework layer of the development platform.

[0122] In specific application scenarios, the encapsulation module is specifically used to define a data structure of a general code language using the functions called by the framework layer of the development platform as the same code; and to encapsulate a general method library corresponding to the native application platform interface in the framework layer of the development platform using the data structure of the general code language.

[0123] In specific application scenarios, the query unit 62 includes:

[0124] The loading module is used to respond to cross-platform interaction commands initiated by the development platform, and to call the general method library and load the dynamic link library using the external function interface;

[0125] The determination module is used to parse the binary file symbols that are statically linked to the general methods corresponding to the native application platform interface using the dynamic link library, and determine the cross-platform interaction communication method pointers based on the binary file symbols.

[0126] The query module is used to query the target communication method for cross-platform interaction from the general method library based on the pointer to the cross-platform interaction communication method.

[0127] In specific application scenarios, the conversion unit 63 includes:

[0128] The calling module is used to call the language code conversion interface in the framework layer of the development platform;

[0129] The conversion module is used to convert the parameter object of the target communication method into the data type of the code language adapted by the native application platform using the conversion interface of the language code.

[0130] The signature module is used to perform function signatures on parameter objects after data type conversion, and then return parameter objects in a general-purpose code language.

[0131] In specific application scenarios, the device further includes:

[0132] The exposure unit is used to expose a unified interface object in the framework layer of the development platform after encapsulating the general method library corresponding to the native application platform interface in the framework layer of the development platform using the external function interface as a cross-platform interaction mechanism between the development platform and the native application platform, aggregating the communication methods in the general method library involved in the native application platform interface.

[0133] The initiating unit is used to initiate cross-platform interaction instructions to the native application according to the data communication requirements when a data communication requirement is detected by the development platform through the unified interface object.

[0134] In specific application scenarios, the device further includes:

[0135] The second encapsulation unit is used to obtain the system method library corresponding to the native application platform interface before the system method library is called using the external function interface in response to the cross-platform interaction instruction initiated by the development platform, and before the target communication method for cross-platform interaction is queried from the general method library, and the system method library is encapsulated in the framework layer of the development platform in a bridging manner, so that the development platform can call the system method library using the cross-platform interaction instruction.

[0136] It should be noted that other corresponding descriptions of the functional units involved in the cross-platform interactive device provided in this embodiment can be found in [reference]. Figures 1-5 The corresponding descriptions in [the document] will not be repeated here.

[0137] Based on the above, Figures 1-5 Accordingly, this application embodiment also provides a storage medium storing a computer program thereon, which, when executed by a processor, implements the above-described method. Figures 1-2 The cross-platform interaction method shown.

[0138] Based on this understanding, the technical solution of this application can be embodied in the form of a software product. This software product can be stored in a non-volatile storage medium (such as a CD-ROM, USB flash drive, or portable hard drive), and includes several instructions to cause a computer device (such as a personal computer, server, or network device) to execute the methods described in the various implementation scenarios of this application.

[0139] Based on the above, Figures 1-5 The method shown, and Figure 6 To achieve the above objectives, the virtual device embodiment shown in this application also provides a cross-platform interactive physical device, specifically a computer, smartphone, tablet, smartwatch, server, or network device, etc. This physical device includes a storage medium and a processor; the storage medium stores a computer program; the processor executes the computer program to achieve the above-described objectives. Figures 1-5 The cross-platform interaction method shown.

[0140] Optionally, the physical device may also include a user interface, a network interface, a camera, radio frequency (RF) circuitry, sensors, audio circuitry, a Wi-Fi module, etc. The user interface may include a display screen, input units such as a keyboard, etc., and optional user interfaces may also include USB interfaces, card reader interfaces, etc. The network interface may optionally include standard wired interfaces, wireless interfaces (such as Wi-Fi interfaces), etc.

[0141] In an exemplary embodiment, see Figure 7 The aforementioned physical device includes a communication bus, a processor, a memory, and a communication interface. It may also include input / output interfaces and a display device. The various functional units can communicate with each other via the bus. The memory stores computer programs, and the processor executes the programs stored in the memory to perform the painting mounting method described in the above embodiments.

[0142] Those skilled in the art will understand that the cross-platform interactive physical device structure provided in this embodiment does not constitute a limitation on the physical device, and may include more or fewer components, or combine certain components, or have different component arrangements.

[0143] The storage medium may also include an operating system and a network communication module. The operating system is a program that manages the hardware and software resources of the physical device for processing store search information, supporting the operation of the information processing program and other software and / or programs. The network communication module is used to enable communication between the various components within the storage medium, as well as communication with other hardware and software within the information processing physical device.

[0144] Through the above description of the embodiments, those skilled in the art can clearly understand that this application can be implemented using software plus necessary general-purpose hardware platforms, or it can be implemented in hardware. Compared with existing methods, by applying the technical solution of this application, this application uses external functions as a cross-platform interaction mechanism, eliminating the need to write native code for method channels, reducing the development cost of cross-platform interaction. By converting the parameter objects received by the development platform into parameter objects of a general-purpose code language, the development platform can directly call the interface of the native application platform to execute the target communication method using the development code, thus improving the efficiency of interaction execution.

[0145] Those skilled in the art will understand that the accompanying drawings are merely schematic diagrams of a preferred embodiment, and the modules or processes shown in the drawings are not necessarily essential for implementing this application. Those skilled in the art will understand that the modules in the apparatus of the embodiment can be distributed within the apparatus of the embodiment as described, or can be modified to be located in one or more apparatuses different from this embodiment. The modules of the above-described embodiment can be combined into one module, or further divided into multiple sub-modules.

[0146] The serial numbers in this application are for descriptive purposes only and do not represent the superiority or inferiority of any particular implementation scenario. The above disclosures are merely a few specific implementation scenarios of this application; however, this application is not limited thereto, and any variations conceived by those skilled in the art should fall within the protection scope of this application.

Claims

1. A cross-platform interaction method, characterized in that, include: External function interfaces are used as a cross-platform interaction mechanism between the development platform and the native application platform. The calling methods corresponding to the native application platform interfaces are exported, and the calling methods are recompiled to create a general method library corresponding to the native application platform interfaces. The general method library corresponding to the native application platform interfaces is encapsulated in the development platform. The recompilation replaces the data structures in the calling methods with code language, and the replaced data results are encoded as pointer addresses. Subsequent method calls are executed based on these addresses. In response to cross-platform interaction commands initiated by the development platform, the external function interface is used to call the general method library and load the dynamic link library; The dynamic link library is used to parse the binary file symbols that are statically linked to the general methods corresponding to the native application platform interface, and the cross-platform interaction communication method pointers are determined based on the binary file symbols. Based on the cross-platform interaction communication method pointer, the target cross-platform interaction communication method is queried from the general method library; In the framework layer of the development platform, the parameter object of the target communication method is converted into a code language to obtain a parameter object in a general code language; The parameter object of the general-purpose code language is transmitted 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 general-purpose code language and returns the execution result to the development platform.

2. The method according to claim 1, characterized in that, The use of external function interfaces as a cross-platform interaction mechanism between the development platform and the native application platform, specifically includes encapsulating a general method library corresponding to the native application platform interfaces within the framework layer of the development platform: The development platform provides a caller for the native application platform using an external function interface. The caller is used to call the compilation library of the code language adapted to the native application platform at the framework layer of the development platform. Each function in the compilation library of the code language adapted by the native application platform is converted into the corresponding function called by the framework layer of the development platform; The cross-platform interaction mechanism between the development platform and the native application platform is implemented using the functions called by the framework layer of the development platform as the same code. A general method library corresponding to the interface of the native application platform is encapsulated in the framework layer of the development platform.

3. The method according to claim 2, characterized in that, The mechanism for cross-platform interaction between the development platform and the native application platform is implemented by using the functions called by the framework layer of the development platform as the same code. Specifically, the framework layer of the development platform encapsulates a general method library corresponding to the interfaces of the native application platform, including: Using the functions called by the framework layer of the development platform as the same code, define a data structure for a general code language; Using the data structures of the general-purpose code language, a general-purpose method library corresponding to the native application platform interface is encapsulated in the framework layer of the development platform.

4. The method according to claim 1, characterized in that, The step of performing 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 in a general code language specifically includes: The language code conversion interface is called within the framework layer of the development platform; The parameter object of the target communication method is converted to the data type of the code language adapted to the native application platform using the language conversion interface described above. After converting the data type of the parameter object and performing a function signature, the function returns a parameter object in a generic code language.

5. The method according to any one of claims 1-4, characterized in that, After using external function interfaces as a cross-platform interaction mechanism between the development platform and the native application platform, and encapsulating a general method library corresponding to the native application platform interface in the framework layer of the development platform, the method further includes: After aggregating the communication methods in the general method library involved in the native application platform interface, a unified interface object is exposed in the framework layer of the development platform. When a data communication request triggered by the development platform through the unified interface object is detected, a cross-platform interaction instruction is initiated to the native application according to the data communication request.

6. The method according to any one of claims 1-4, characterized in that, Before responding to a cross-platform interaction command initiated by the development platform, and using the external function interface to call the general method library to query the target communication method for cross-platform interaction from the general method library, the method further includes: Obtain the system method library corresponding to the native application platform interface, and encapsulate the system method library in the framework layer of the development platform using a bridging method, so that the development platform can call the system method library using cross-platform interaction commands.

7. A cross-platform interactive device, characterized in that, include: The first encapsulation unit is used to use an external function interface as a cross-platform interaction mechanism between the development platform and the native application platform. It exports the calling methods corresponding to the native application platform interface, recompiles the calling methods to create a general method library corresponding to the native application platform interface, and encapsulates the general method library corresponding to the native application platform interface in the development platform. The recompiling replaces the data structure in the calling method with code language, encodes the replaced data result into the address of a pointer, and executes subsequent method calls based on the address. The query unit is used to respond to cross-platform interaction commands initiated by the development platform, and to call the general method library and load the dynamic link library using the external function interface; The dynamic link library is used to parse the binary file symbols that are statically linked to the general methods corresponding to the native application platform interface, and the cross-platform interaction communication method pointers are determined based on the binary file symbols. Based on the cross-platform interaction communication method pointer, the target cross-platform interaction communication method is queried from the general method library; The conversion unit is used 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 in a general code language. The transmission unit is used to transmit the parameter object of the general-purpose 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 general-purpose code language and returns the execution result to the development platform.

8. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the cross-platform interaction method according to any one of claims 1 to 6.

9. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the cross-platform interaction method according to any one of claims 1 to 6.

Citation Information

Patent Citations

  • Interaction method and tool of Web end and iOS end

    CN113703999A

  • Business processing system, method, equipment and medium

    CN114461411A