Cross-platform API sharing method, device, system and storage medium

By defining cross-platform API sharing methods in the Flutter and React Native frameworks, determining the API call method according to the development platform type, and running a unified listener, the high development cost problem caused by inconsistent API call logic of different platforms in the existing technology is solved, and API compatibility and consistency are achieved.

CN112947897BActive Publication Date: 2025-04-15BEIJING JINGDONG SHANGKE INFORMATION TECH CO LTD +1
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN201911171393.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2019-11-26
Publication Date
2025-04-15
Estimated Expiration
2039-11-26

AI Technical Summary

Technical Problem

When calling native APIs, the existing Flutter and React Native frameworks use different logic to create APIs separately, resulting in high development costs.

Method used

By defining a cross-platform API sharing method, determine the API's call method based on the type of application development platform (such as React Native or Flutter), and run the listener corresponding to the target API. This listener contains the function set that abstracts the API into an interface operation to implement unified calls to the API.

Benefits of technology

It realizes API compatibility of different application development platforms, ensures the consistency of interface calls, and reduces development costs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112947897B_ABST
    Figure CN112947897B_ABST
Patent Text Reader

Abstract

The present application provides a cross-platform API sharing method, device, system and storage medium, the method comprising: determining the calling method of the application programming interface API according to the type of application development platform; running a listener corresponding to the target API according to the calling method; wherein the listener includes a listening program compiled after abstracting the API into a function set of interface operations. The present application can achieve API compatibility of different application development platforms, ensure the consistency of interface calls, and reduce development costs.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a cross-platform API sharing method, device, system and storage medium. Background Art

[0002] There are more and more cross-platform development solutions, such as React Native / Weex, Flutter, etc. However, this framework is dependent on the basic API of the Android / IOS platform. Therefore, when developing applications on these platforms, it is often necessary to develop many native-related APIs to complete certain specific functions.

[0003] The existing Flutter and React Native have two different logics for calling and encapsulating native APIs. React Native registers all APIs to the JS side by marking React Method. Flutter, on the other hand, directly tells the native side the name of the interface to be called through the method channel, and then the native side determines the calling logic based on the required name. Since the calling methods and encapsulation logic of Flutter and React Native are different, it is necessary to develop APIs separately, which has high development costs. Summary of the invention

[0004] The present application provides a cross-platform API sharing method, device, system and storage medium, which can achieve API compatibility of different application development platforms, ensure the consistency of interface calls, and reduce development costs.

[0005] In a first aspect, an embodiment of the present application provides a cross-platform API sharing method, including:

[0006] Determine the calling method of the application programming interface API according to the type of application development platform;

[0007] According to the calling method, a listener corresponding to the target API is run; wherein the listener includes a listening program compiled after abstracting the API into a function set of interface operations.

[0008] In a possible design, the calling method of the application programming interface API is determined according to the type of application development platform, including:

[0009] If the application development platform is React Native, the target API is called using the React tag method;

[0010] If the application development platform is Flutter, the target API is called through the Flutter unified calling interface, wherein the Flutter unified calling interface is used to establish a mapping relationship between the target API and the corresponding listener.

[0011] In a possible design, the method of calling the target API using the React tag includes:

[0012] Register a module method in a React interface management object, wherein the module method is used to declare an API as a React tag method and register a listener corresponding to the React tag method;

[0013] Establish mutual calls between the module method and JS through the JS communication bridge;

[0014] The listener corresponding to the target API is called through the React tag method in the module method.

[0015] In a possible design, calling the target API through the Flutter unified calling interface includes:

[0016] Defining the Flutter unified calling interface in the Flutter framework;

[0017] The listener corresponding to the target API is called through the Flutter unified calling interface.

[0018] In a possible design, before calling the listener corresponding to the target API through the Flutter unified calling interface, the following is also included:

[0019] The mapping interface is saved in a cached table by means of Flutter method keywords;

[0020] Register the Flutter interface callback registration center with the Flutter method keyword;

[0021] When calling a keyword to an object method, the corresponding Flutter unified call interface is found from the cache according to the value of the keyword, and the data is converted into a table and method and then passed to the Flutter unified call interface.

[0022] In one possible design, it also includes:

[0023] The running result of the listener is fed back to the Flutter result callback interface through the Flutter unified call interface, so that the Flutter result callback interface returns the running result to the calling end.

[0024] In a second aspect, an embodiment of the present application provides a cross-platform API sharing device, including:

[0025] A determination module, used to determine a calling method of an application programming interface API according to the type of application development platform;

[0026] The calling module is used to run the listener corresponding to the target API according to the calling method; wherein the listener includes a listening program compiled after abstracting the API into a function set of interface operations.

[0027] In a possible design, the determining module is specifically used to:

[0028] If the application development platform is React Native, the target API is called using the React tag method;

[0029] If the application development platform is Flutter, the target API is called through the Flutter unified calling interface, wherein the Flutter unified calling interface is used to establish a mapping relationship between the target API and the corresponding listener.

[0030] In a possible design, the method of calling the target API using the React tag includes:

[0031] Register a module method in a React interface management object, wherein the module method is used to declare an API as a React tag method and register a listener corresponding to the React tag method;

[0032] Establish mutual calls between the module method and JS through the JS communication bridge;

[0033] The listener corresponding to the target API is called through the React tag method in the module method.

[0034] In a possible design, calling the target API through the Flutter unified calling interface includes:

[0035] Defining the Flutter unified calling interface in the Flutter framework;

[0036] The listener corresponding to the target API is called through the Flutter unified calling interface.

[0037] In one possible design, it also includes:

[0038] A cache module, used to save the mapping interface into a cache table by means of a Flutter method keyword before calling the listener corresponding to the target API by means of the Flutter unified call interface;

[0039] The registration module is used to register the Flutter interface callback registration center with the Flutter method keyword;

[0040] The transmission module is used to find the corresponding Flutter unified call interface from the cache according to the value of the keyword when calling the keyword to the object method, and convert the data into a table and method and then pass it to the Flutter unified call interface.

[0041] In one possible design, it also includes:

[0042] The feedback module is used to feed back the running result of the listener to the Flutter result callback interface through the Flutter unified call interface, so that the Flutter result callback interface returns the running result to the calling end.

[0043] In a third aspect, an embodiment of the present application provides a cross-platform API sharing system, comprising: a memory and a processor, wherein executable instructions of the processor are stored in the memory; wherein the processor is configured to execute the cross-platform API sharing method described in any one of the first aspects by executing the executable instructions.

[0044] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the cross-platform API sharing method described in any one of the first aspects.

[0045] In a fifth aspect, an embodiment of the present application provides a program product, comprising: a computer program, the computer program being stored in a readable storage medium, at least one processor of a server being able to read the computer program from the readable storage medium, and the at least one processor executing the computer program so that the server executes any cross-platform API sharing method described in the first aspect.

[0046] The present application provides a cross-platform API sharing method, device, system and storage medium, which determines the calling method of the application programming interface API according to the type of application development platform; according to the calling method, runs a listener corresponding to the target API; wherein the listener includes a listening program compiled after abstracting the API into a function set of interface operations. Thus, API compatibility of different application development platforms can be achieved, consistency of interface calls can be guaranteed, and development costs can be reduced. BRIEF DESCRIPTION OF THE DRAWINGS

[0047] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, a brief introduction will be given below to the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.

[0048] Figure 1 This is a schematic diagram of the principle of an application scenario of this application;

[0049] Figure 2 A flowchart of a cross-platform API sharing method provided in Example 1 of the present application;

[0050] Figure 3 A schematic diagram of the structure of a cross-platform API sharing device provided in Example 2 of the present application;

[0051] Figure 4 This is a structural diagram of the cross-platform API sharing system provided in Example 3 of the present application.

[0052] The above drawings show clear embodiments of the present disclosure, which will be described in more detail below. These drawings and text descriptions are not intended to limit the scope of the present disclosure in any way, but to illustrate the concepts of the present disclosure to those skilled in the art by referring to specific embodiments. DETAILED DESCRIPTION

[0053] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0054] The terms "first", "second", "third", "fourth", etc. (if any) in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein, for example. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0055] The technical solution of the present application is described in detail with specific embodiments below. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be described in detail in some embodiments.

[0056] Below, some terms in this application are explained to facilitate understanding by those skilled in the art:

[0057] 1) Flutter is a new cross-platform, open-source UI framework developed by Google that supports iOS and Android system development and is the default development kit for the future new operating system Fuchsia. Flutter's goal is to make the same set of code run on both Android and iOS systems, and have performance comparable to native applications. Flutter even provides two sets of controls to adapt to Android and iOS (scrolling effects, fonts, control icons, etc.), in order to make the App look more like a native application in details.

[0058] 2) React Native (RN for short) is a cross-platform mobile application development framework that Facebook opened up in April 2015. It is a derivative of Facebook's earlier open-source JS framework React on the native mobile application platform. It currently supports iOS and Android platforms. RN uses Java script language, similar to HTML's JSX, and CSS to develop mobile applications. Therefore, technicians familiar with Web front-end development only need to learn a little to enter the field of mobile application development.

[0059] There are more and more cross-platform development solutions, such as React Native / Weex, Flutter, etc. However, this framework is dependent on the basic API of the Android / IOS platform. Therefore, when developing applications on these platforms, it is often necessary to develop many native-related APIs to complete certain specific functions.

[0060] The existing Flutter and React Native have two different logics for calling and encapsulating native APIs. React Native registers all APIs to the JS side by marking React Method. Flutter, on the other hand, directly tells the native side the name of the interface to be called through the method channel, and then the native side determines the calling logic based on the required name. Since the calling methods and encapsulation logic of Flutter and React Native are different, it is necessary to develop APIs separately, which has high development costs.

[0061] In response to the above problems, the present application provides a cross-platform API sharing method, device, system and storage medium, which can achieve API compatibility of different application development platforms, ensure the consistency of interface calls, and reduce development costs. Figure 1 This is a schematic diagram of the principle of an application scenario of this application, such as Figure 1 As shown in the figure, this solution defines a new set of interfaces to separate and abstract Flutter and ReactNative interfaces into several layers to achieve interface unification. From bottom to top, they are Core API layer, Jdreact framework layer, SDK layer, and business API layer.

[0062] The specific functions of the API are completed in the Core API layer, so that developers only need to care about the role of the API, without having to worry about the problem of redevelopment due to inconsistent interfaces across frameworks. When developers write native APIs, they need to abstract these APIs into interfaces and implement them as listeners. This is a set of APIs that are completely independent of Flutter and React Native to implement this abstract interface, which is then provided to both ends for use.

[0063] On the core API, you can define a jd react framework layer, which is an abstract layer used to smooth out the inconsistencies between the interfaces on both sides. For the application development platform React Native, you need to add a module method (Moudle API), declare all APIs as React tag methods, and register the interface operation function set (interface) mentioned in the core API, so that all React tag methods can uniformly call the method corresponding to the interface operation function set. Because the module method must be registered in the React interface management object to take effect, it is necessary to register the listener corresponding to the module method when registering, so that the corresponding API call will be directly called to the specific implementation in the listener. If the application development platform is Flutter, you can define a new abstract unified call interface (JD Flutter Call) in the jd react framework layer. Define and implement the Flutter method call handler (MethodCall Handler) as a standard interface (JD Flutter Method Call Handler, also known as the Flutter interface callback registration center). This setting is mainly to unify all Flutter interfaces so that developers no longer need to pay attention to Flutter's interface implementation.

[0064] Optionally, above the jd react framework layer, there can be an SDK layer as a bridge between the business API layer and the defined jd react framework layer. For the application development platform React Native, the mutual call between the module method and JS can be established through the JS communication bridge, and then the listener corresponding to the target API can be called through the React tag method in the module method. If the application development platform is Flutter, the method channel is used to realize the interaction between the business API layer and the jd react framework layer. When calling the business, maintain the cache of all implemented Flutter unified call interfaces. For example, it can be stored in a table (map) and then saved according to the Flutter method keyword (method channel key). Inject the keyword of the Flutter method into the table. In the specific implementation, the interface will be registered in the Flutter View in flutter. After receiving the call, the corresponding Flutter unified call interface is found in the cache according to the corresponding keyword, and the method and parameters therein are passed to the Flutter unified call interface.

[0065] Optionally, the top layer is set as the business API layer, which is consistent with the original architecture implementation. Then, the calling method of the application programming interface API can be determined according to the type of application development platform. Finally, according to the calling method, the listener corresponding to the target API is run, thereby realizing cross-platform API sharing.

[0066] The technical solution of the present application and how the technical solution of the present application solves the above-mentioned technical problems are described in detail below with specific embodiments. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments. The embodiments of the present application will be described below in conjunction with the accompanying drawings.

[0067] Figure 2 A flowchart of a cross-platform API sharing method provided in Example 1 of the present application, such as Figure 2 As shown, the method in this embodiment may include:

[0068] S101. Determine a calling method of an application programming interface (API) according to the type of application development platform.

[0069] In this embodiment, when the service needs to call an API, the calling method of the application programming interface API is first determined according to the type of application development platform. If the application development platform is React Native, the target API is called using the React tag method; if the application development platform is Flutter, the target API is called through the Flutter unified calling interface, where the Flutter unified calling interface is used to establish a mapping relationship between the target API and the corresponding listener.

[0070] Specifically, this solution defines a new set of interfaces to separate and abstract Flutter and React Native interfaces into several levels to achieve interface unification. From bottom to top, they are the core API layer, Jd react framework layer, SDK layer, and business API layer. Finally, the functions of the API are completed in the core API, so that developers only need to care about the role of the API, without having to worry about the problem of redevelopment due to inconsistent interfaces across frameworks. When developers write native APIs, they need to abstract these APIs into interfaces and implement them into listeners. The core API is the specific function to be implemented. Here, you can first define an abstract interface containing a set of functional APIs to be implemented, and implement this set of separate API functions in the listener.

[0071] Because all APIs of React Native are implemented by implementing the Java class React Context Base JavaModule, all APIs exposed to JS are marked with @React Method. Therefore, in order to maintain consistency between the APIs on both sides, it is necessary to register the previously declared listener in the Module and call back the listener in all marked methods. Therefore, when the business needs to call an API, if the application development platform is React Native, use @React Method to mark the method to call the target API.

[0072] The Flutter interface is implemented by implementing on Method Call in the Method Call Handler. On Method Call tells the native side the name of the API to be called, and the native side will map it. Therefore, the Flutter side can abstract a new unified call interface to map all APIs without relying on any Flutter, and implement the interface in the listener. Therefore, when the business needs to call an API, if the application development platform is Flutter, the target API is called through the new unified call interface.

[0073] Optionally, the target API is called using a React tag method, including: registering a module method in a React interface management object, where the module method is used to declare the API as a React tag method, and registering a listener corresponding to the React tag method; establishing a mutual call between the module method and JS through a JS communication bridge; and calling the listener corresponding to the target API through the React tag method in the module method.

[0074] Specifically, on the core API, a jd react framework layer can be defined, which is an abstract layer used to smooth out the inconsistencies between the interfaces on both sides. For the application development platform React Native, a new module (moudle) needs to be added, all APIs are declared as React tag methods, and the interface mentioned in the core API is registered, so that all React tag methods uniformly call the methods corresponding to the interface. Because the new module must be registered in the React interface management object to take effect, the listener corresponding to the module needs to be registered together when registering, so that after the corresponding API is called, it will directly call the specific implementation in the listener. On the jd react framework layer, there can be an SDK layer, which is a bridge between the business API layer and the defined jd react framework layer. For the application development platform ReactNative, the mutual call between the module method and JS can be established through the JS communication bridge, and then the listener corresponding to the target API can be called through the React tag method in the module method.

[0075] Optionally, calling the target API through the Flutter unified calling interface includes: defining the Flutter unified calling interface in the Flutter framework; and calling a listener corresponding to the target API through the Flutter unified calling interface.

[0076] Specifically, if the application development platform is Flutter, a new unified call interface can be defined and abstracted in the jd react framework layer. Define and implement Flutter's method call handler as a standard interface. At the SDK layer, use method channel to implement the interaction between the business API layer and the jd react framework layer. When calling the business, maintain a cache of all implemented Flutter unified call interfaces, which can be stored in a table and saved according to the Flutter method keyword. In specific implementation, the interface will be registered in Flutter View. After receiving the call, the corresponding Flutter unified call interface will be found in the cache according to the corresponding keyword, and the method and parameters in it will be passed to the Flutter unified call interface.

[0077] Optionally, before calling the listener corresponding to the target API through the Flutter unified call interface, it also includes: saving the mapping interface to the cached table by means of Flutter method keywords; registering the Flutter interface callback registration center with the Flutter method keyword; when calling the keyword to the object method, finding the corresponding Flutter unified call interface from the cache according to the keyword value, and passing the data to the Flutter unified call interface after converting it into a table and method.

[0078] Specifically, all Flutter unified call interfaces can be saved in the cached hash table through Flutter method keywords. When the system calls back to the keyword-to-object method, it will retrieve the corresponding Flutter unified call interface according to the keyword, convert the data into a hash map and pass it to the Flutter unified call interface in a just-posted manner. Finally, the Flutter unified call interface will call back the corresponding listener to complete the corresponding function, and pass the data to dart through the Flutter unified call interface.

[0079] S102: Run the listener corresponding to the target API according to the calling method.

[0080] In this embodiment, the listener includes a listening program compiled by abstracting the API into a function set of interface operations. According to the calling method, the listener corresponding to the target API is run to realize the final function in the core API.

[0081] Specifically, the top layer is the business API layer, which is consistent with the original implementation. Depending on whether the application development platform is Flutter or React Native, the SDK layer can interact with the Flutter unified call interface or module API in the jd reactframework layer through the method channel or JS bridge, and finally run the listener corresponding to the target API in the core API layer. This embodiment can smooth out the inconsistency of the interfaces at both ends by abstracting a layer of Flutter unified call interface and listener. Then, all Flutter unified call interfaces are cached and customized to unify the standard Method Call Handler interface. The Flutter method keyword corresponds to the Flutter unified call interface, so that developers who encapsulate the API do not have to repeatedly encapsulate the Method Call Handler. In this mode, developers only need to care about the implementation of the listener / Flutter unified call interface, and do not have to worry about the inconsistency of the frameworks on both sides.

[0082] Optionally, the running result of the listener is fed back to the Flutter result callback interface through the Flutter unified call interface, so that the Flutter result callback interface returns the running result to the calling end.

[0083] Specifically, the abstract Flutter data returns the Flutter result callback interface, including success and failure callbacks. When the JD Flutter Call returns data, the data will eventually be returned to the caller through the result of the JD Flutter Method Call Handler.

[0084] In this embodiment, the calling method of the application programming interface API is determined according to the type of application development platform; according to the calling method, the listener corresponding to the target API is run; wherein the listener includes a listening program compiled after abstracting the API into a function set of interface operations. Thus, the API compatibility of different application development platforms can be achieved, the consistency of interface calling can be guaranteed, and the development cost can be reduced.

[0085] Figure 3 A schematic diagram of the structure of a cross-platform API sharing device provided in Example 2 of the present application is shown in FIG. Figure 3 As shown, the device in this embodiment may include:

[0086] A determination module 31, used to determine a calling method of an application programming interface API according to the type of application development platform;

[0087] The calling module 32 is used to run the listener corresponding to the target API according to the calling mode; wherein the listener includes a listening program compiled by abstracting the API into a function set of interface operations.

[0088] In a possible design, the determination module 31 is specifically configured to:

[0089] If the application development platform is React Native, the target API is called using the React tag method;

[0090] If the application development platform is Flutter, the target API is called through the Flutter unified call interface, where the Flutter unified call interface is used to establish a mapping relationship between the target API and the corresponding listener.

[0091] In a possible design, a React tag method is used to call the target API, including:

[0092] Register the module method in the React interface management object. The module method is used to declare the API as a React tag method and register the listener corresponding to the React tag method.

[0093] Establish mutual calls between module methods and JS through JS communication bridge;

[0094] Call the listener corresponding to the target API through the React tag method in the module method.

[0095] In a possible design, the target API is called through the Flutter unified call interface, including:

[0096] Define the Flutter unified call interface in the Flutter framework;

[0097] Call the listener corresponding to the target API through the Flutter unified call interface.

[0098] In one possible design, it also includes:

[0099] The cache module 33 is used to save the mapping interface into the cache table by means of Flutter method keywords before calling the listener corresponding to the target API through the Flutter unified call interface;

[0100] A registration module 34 is used to register a Flutter interface callback registration center with a Flutter method keyword;

[0101] The transmission module 35 is used to find the corresponding Flutter unified call interface from the cache according to the value of the keyword when calling the keyword to the object method, and convert the data into a table and method and then pass it to the Flutter unified call interface.

[0102] In one possible design, it also includes:

[0103] The feedback module 36 is used to feed back the running result of the listener to the Flutter result callback interface through the Flutter unified call interface, so that the Flutter result callback interface returns the running result to the calling end.

[0104] The cross-platform API sharing device of this embodiment can execute Figure 2 For the technical solution in the method shown, its specific implementation process and technical principles can be found in Figure 2 The relevant descriptions in the method shown will not be repeated here.

[0105] In this embodiment, the calling method of the application programming interface API is determined according to the type of application development platform; according to the calling method, the listener corresponding to the target API is run; wherein the listener includes a listening program compiled after abstracting the API into a function set of interface operations. Thus, the API compatibility of different application development platforms can be achieved, the consistency of interface calling can be guaranteed, and the development cost can be reduced.

[0106] Figure 4 This is a schematic diagram of the structure of the cross-platform API sharing system provided in Example 3 of the present application, such as Figure 4 As shown, the cross-platform API sharing system 40 of this embodiment may include: a processor 41 and a memory 42 .

[0107] The memory 42 is used to store programs; the memory 42 may include volatile memory (English: volatile memory), such as random-access memory (English: random-access memory, abbreviated: RAM), such as static random-access memory (English: static random-access memory, abbreviated: SRAM), double data rate synchronous dynamic random access memory (English: Double Data Rate Synchronous Dynamic Random Access Memory, abbreviated: DDR SDRAM), etc.; the memory may also include non-volatile memory (English: non-volatile memory), such as flash memory (English: flash memory). The memory 42 is used to store computer programs (such as applications, functional modules, etc. that implement the above method), computer instructions, etc., and the above computer programs, computer instructions, etc. can be partitioned and stored in one or more memories 42. And the above computer programs, computer instructions, data, etc. can be called by the processor 41.

[0108] The above-mentioned computer programs, computer instructions, etc. may be stored in one or more memories 42 in partitions. And the above-mentioned computer programs, computer instructions, data, etc. may be called by the processor 41.

[0109] The processor 41 is used to execute the computer program stored in the memory 42 to implement the various steps in the method involved in the above embodiment.

[0110] For details, please refer to the relevant description in the previous method embodiment.

[0111] The processor 41 and the memory 42 may be independent structures or integrated structures. When the processor 41 and the memory 42 are independent structures, the memory 42 and the processor 41 may be coupled and connected via a bus 43 .

[0112] The cross-platform API sharing system of this embodiment can execute Figure 2 For the technical solution in the method shown, its specific implementation process and technical principles can be found in Figure 2 The relevant descriptions in the method shown will not be repeated here.

[0113] In addition, an embodiment of the present application further provides a computer-readable storage medium, in which computer-executable instructions are stored. When at least one processor of a user device executes the computer-executable instructions, the user device executes the above-mentioned various possible methods.

[0114] Among them, computer-readable media include computer storage media and communication media, wherein the communication media include any media that facilitates the transmission of computer programs from one place to another. The storage medium can be any available medium that can be accessed by a general or special-purpose computer. An exemplary storage medium is coupled to the processor so that the processor can read information from the storage medium and write information to the storage medium. Of course, the storage medium can also be an integral part of the processor. The processor and the storage medium can be located in an ASIC. In addition, the ASIC can be located in a user device. Of course, the processor and the storage medium can also be present in a communication device as discrete components.

[0115] The present application also provides a program product, which includes a computer program, which is stored in a readable storage medium. At least one processor of the server can read the computer program from the readable storage medium, and at least one processor executes the computer program so that the server implements any method of the above-mentioned embodiments of the present application.

[0116] Those skilled in the art can understand that all or part of the steps of implementing the above-mentioned method embodiments can be completed by hardware related to program instructions. The aforementioned program can be stored in a computer-readable storage medium. When the program is executed, the steps of the above-mentioned method embodiments are executed; and the aforementioned storage medium includes: ROM, RAM, disk or optical disk and other media that can store program codes.

[0117] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit it. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or replace some or all of the technical features therein with equivalents. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present application.

Claims

1. A cross-platform API sharing method, characterized in that: include: Determine a calling method of an application programming interface (API) according to a type of application development platform, wherein the types of application development platforms include React Native and Flutter; According to the calling method, a listener corresponding to the target API is run; wherein the listener includes a listening program compiled after abstracting the API into a function set of interface operations.

2. The method according to claim 1, characterized in that Determine how to call the application programming interface (API) based on the type of application development platform, including: If the application development platform is React Native, the target API is called using the React tag method; If the application development platform is Flutter, the target API is called through the Flutter unified calling interface, wherein the Flutter unified calling interface is used to establish a mapping relationship between the target API and the corresponding listener.

3. The method according to claim 2, characterized in that The method of using the React tag to call the target API includes: Register a module method in a React interface management object, wherein the module method is used to declare an API as a React tag method and register a listener corresponding to the React tag method; Establish mutual calls between the module method and JS through the JS communication bridge; The listener corresponding to the target API is called through the React tag method in the module method.

4. The method according to claim 2, characterized in that: Calling the target API through the Flutter unified calling interface includes: Defining the Flutter unified calling interface in the Flutter framework; The listener corresponding to the target API is called through the Flutter unified calling interface.

5. The method according to claim 4, characterized in that Before calling the listener corresponding to the target API through the Flutter unified calling interface, the method further includes: Save the mapping interface to the cache table by using the Flutter method keyword; Register the Flutter interface callback registration center with the Flutter method keyword; When calling a keyword to an object method, the corresponding Flutter unified call interface is found from the cache according to the value of the keyword, and the data is converted into a table and method and then passed to the Flutter unified call interface.

6. The method according to claim 4, characterized in that Also includes: The running result of the listener is fed back to the Flutter result callback interface through the Flutter unified call interface, so that the Flutter result callback interface returns the running result to the calling end.

7. A cross-platform API sharing device, characterized in that: include: A determination module, used to determine a calling method of an application programming interface API according to a type of an application development platform, wherein the types of the application development platform include React Native and Flutter; The calling module is used to run the listener corresponding to the target API according to the calling method; wherein the listener includes a listening program compiled after abstracting the API into a function set of interface operations.

8. The device according to claim 7, characterized in that The determination module is specifically used for: If the application development platform is React Native, the target API is called using the React tag method; If the application development platform is Flutter, the target API is called through the Flutter unified calling interface, wherein the Flutter unified calling interface is used to establish a mapping relationship between the target API and the corresponding listener.

9. A cross-platform API sharing system, characterized in that: include: A memory and a processor, wherein executable instructions of the processor are stored in the memory; wherein the processor is configured to execute the cross-platform API sharing method according to any one of claims 1 to 6 by executing the executable instructions.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the cross-platform API sharing method described in any one of claims 1 to 6 is implemented.

11. A computer program product having a computer program stored thereon, characterized in that: When the program is executed by a processor, the cross-platform API sharing method described in any one of claims 1 to 6 is implemented.

Citation Information

Patent Citations

  • Design method of cross-platform application, design device of cross-platform application, mobile terminal and storage medium

    CN107908426A

  • Cross-platform development method and system

    CN109976752A