CN111309407B - Processing method and device for integrated third party library - Google Patents

Processing method and device for integrated third party library Download PDF

Info

Publication number
CN111309407B
CN111309407B CN202010108828.4A CN202010108828A CN111309407B CN 111309407 B CN111309407 B CN 111309407B CN 202010108828 A CN202010108828 A CN 202010108828A CN 111309407 B CN111309407 B CN 111309407B
Authority
CN
China
Prior art keywords
party application
party
class
function
parameter
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202010108828.4A
Other languages
Chinese (zh)
Other versions
CN111309407A (en
Inventor
唐鹏
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
China Mobile Communications Group Co Ltd
MIGU Culture Technology Co Ltd
Original Assignee
China Mobile Communications Group Co Ltd
MIGU Culture Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by China Mobile Communications Group Co Ltd, MIGU Culture Technology Co Ltd filed Critical China Mobile Communications Group Co Ltd
Priority to CN202010108828.4A priority Critical patent/CN111309407B/en
Publication of CN111309407A publication Critical patent/CN111309407A/en
Application granted granted Critical
Publication of CN111309407B publication Critical patent/CN111309407B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/448Execution paradigms, e.g. implementations of programming paradigms
    • G06F9/4482Procedural
    • G06F9/4484Executing subprograms
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/448Execution paradigms, e.g. implementations of programming paradigms
    • G06F9/4488Object-oriented
    • G06F9/449Object-oriented method invocation or resolution
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Abstract

The embodiment of the invention provides a processing method and a processing device for an integrated third party library, wherein the method comprises the following steps: a first method for registering a third party application in a class of the third party application is dynamically called in the SDK, wherein the third party application is determined according to identification information transmitted by a target application program; sending an authorization request to a server of the third party application by dynamically calling a second method in the class of the third party application, so that the server of the third party application returns parameters related to the function of the third party application to the target application program; and calling back parameters related to the functions of the third party application, which are transmitted from the target application program, by dynamically calling a third method in the class of the third party application. According to the embodiment of the invention, the function of the third party library is used as required, and all the third party libraries are not required to be introduced into engineering, so that the workload of client integration is effectively reduced, and the bag size of the APP is reduced.

Description

Processing method and device for integrated third party library
Technical Field
The present invention relates to the field of computer technologies, and in particular, to a method and an apparatus for processing an integrated third party library.
Background
When integrating a third party library in an IOS-SDK, the method to be called into the third party library is called, and therefore, a header file to be introduced into the third party library is required so that the corresponding function method can be found. For example, when integrating the authorized login function of WeChat, WXAPi.h header file needs to be introduced into code before compiling successfully. When the application program APP uses the IOS-SDK, APPID and APPKey of a third-party application to be used are transmitted into the IOS-SDK, and a corresponding third-party SDK library is introduced into the Xcode engineering file, so that the authorized login function of the third-party application can be used by one key.
If the IOS-SDK has the functions of a plurality of third party applications such as QQ, weChat, microblog and payment treasures, but only needs to use the functions of one or a plurality of third party applications, if the existing technical scheme of introducing a third party header file to use the functions of a third party SDK library is used, the SDK libraries of all third party applications need to be introduced into the Xcode engineering file, otherwise, the header file introduced into the IOS-SDK will not find the compiling errors of the corresponding method. The problems with this are mainly two: one is to increase the workload of client integration and introduce unnecessary third party SDK libraries; the second is to increase the inclusion size of the APP because some third party SDK libraries that do not need to be used are also compiled.
Disclosure of Invention
In order to solve the problems of large client integration workload and large APP inclusion caused by the fact that the IOS-SDK needs to introduce a third party header file to use a third party SDK library function, the embodiment of the invention provides a processing method and a processing device for integrating a third party library.
In a first aspect, an embodiment of the present invention provides a method for processing an integrated third party library, including:
a first method for registering a third party application in a class of the third party application is dynamically called in a Software Development Kit (SDK), wherein the third party application is determined according to identification information transmitted by a target application program;
sending an authorization request to a server of the third party application by dynamically calling a second method in the class of the third party application, so that the server of the third party application returns parameters related to the function of the third party application to the target application program;
and calling back parameters related to the functions of the third party application, which are transmitted from the target application program, by dynamically calling a third method in the class of the third party application.
The first method for registering the third party application in the class of the third party application is dynamically called in the software development kit SDK, and specifically comprises the following steps:
dynamically generating the first method;
if the first method exists in the instantiation object of the class of the third party application, the first method is found, the identification information is used as the reference of the first method, and the first method is instantiated.
Before the step of dynamically calling the second method in the class of the third party application, the method further comprises the steps of:
and determining that the third party application is installed on the user terminal by dynamically calling a fourth method in the class of the third party application.
And sending an authorization request to the server of the third party application by dynamically calling a second method in the class of the third party application, so that the server of the third party application returns parameters related to the function of the third party application to the target application program, wherein the parameters are specifically as follows:
dynamically generating the second method;
if the second method exists in the instantiation object of the class of the third party application, the second method is found;
and taking the type of the parameter related to the function of the third party application and the position returned by the parameter which need to be acquired as the parameters of the second method, and instantiating the second method so that the server of the third party application returns the parameter related to the function of the third party application to the target application program according to the type of the parameter and the position returned by the parameter.
The method includes the steps that the type of parameters and the positions of parameter returns, which are required to be acquired and related to the functions of the third party application, are used as the parameters of the second method, the second method is instantiated, and the server of the third party application returns the parameters related to the functions of the third party application to the target application program according to the type of the parameters and the positions of parameter returns, wherein the parameters are specifically as follows:
capturing an authorization request sending pointer in the target application program by utilizing a character string construction class example function, and if the authorization request sending pointer is captured, constructing an authorization request sending class object, wherein the authorization request sending class object is used for indicating the type of parameters related to the functions of the third party application to be acquired;
and taking the authorization request sending class object, the parameter returning position and the self parameter as the parameters of the second method, and instantiating the second method so that the server of the third party application returns the parameters related to the functions of the third party application to the target application program according to the authorization request sending class object, the parameter returning position and the self parameter.
And calling back parameters related to the functions of the third party application, which are transmitted from the target application program, by dynamically calling a third method in the class of the third party application, wherein the parameters are specifically as follows:
dynamically generating the third method;
if the third method exists in the instantiation object of the class of the third party application, the third method is found, and parameters which are transmitted from the target application program and related to the function of the third party application are taken as parameters of the third method, and the third method is instantiated.
Wherein, after the step of callback of parameters related to the function of the third party application, which are imported from the target application program, further comprises:
analyzing parameters related to the functions of the third party application by calling a callback function to obtain user data related to the functions of the third party application;
and uploading the user data to a unified user center background to obtain corresponding user information and a user unique identifier, and returning the user information and the user unique identifier to the target application program.
In a second aspect, an embodiment of the present invention provides a processing apparatus for integrating a third party library, including:
the third party application registration module is used for calling a first method for registering the third party application in the class of the third party application, wherein the third party application is determined according to the identification information transmitted by the target application program;
the dynamic authorization module is used for sending an authorization request to the server of the third party application by dynamically calling a second method in the class of the third party application so that the server of the third party application returns parameters related to the function of the third party application to the target application program;
and the parameter callback module is used for calling the parameters which are transmitted from the target application program and related to the functions of the third party application by dynamically calling the third method in the class of the third party application.
In a third aspect, an embodiment of the present invention provides an electronic device, including a memory, a processor, and a computer program stored on the memory and executable on the processor, the processor implementing the steps of the processing method of the integrated third party library as provided in the first aspect when the program is executed.
In a fourth aspect, embodiments of the present invention provide a non-transitory computer readable storage medium having stored thereon a computer program which, when executed by a processor, implements the steps of the method of processing an integrated third party library as provided in the first aspect.
The processing method and the processing device for the integrated third-party library solve the problem that the IOS-SDK can only use the third-party library function by introducing the header file by utilizing a dynamic calling mechanism, so that the IOS-SDK and the APP can use the function of the third-party library as required without depending on the existence of the third-party library in compiling, all the third-party libraries are not required to be introduced into engineering, the workload of client integration is effectively reduced, and the bag size of the APP is reduced.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions of the prior art, the following description will briefly explain the drawings used in the embodiments or the description of the prior art, and it is obvious that the drawings in the following description are some embodiments of the present invention, and other drawings can be obtained according to these drawings without inventive effort for a person skilled in the art.
FIG. 1 is a flow chart of a method for processing an integrated third party library according to an embodiment of the present invention;
fig. 2 is a schematic flow chart of implementing a WeChat authorization login function through a dynamic integrated third party library according to an embodiment of the present invention;
fig. 3 is a schematic structural diagram of a processing device integrated with a third party library according to an embodiment of the present invention;
fig. 4 is a schematic diagram of an entity structure of an electronic device according to an embodiment of the present invention.
Detailed Description
For the purpose of making the objects, technical solutions and advantages of the embodiments of the present invention more apparent, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention, and it is apparent that the described embodiments are some embodiments of the present invention, but not all embodiments of the present invention. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
As shown in fig. 1, a flow chart of a processing method for integrating a third party library according to an embodiment of the present invention includes:
step 100, a first method for registering a third party application in a class of the third party application is dynamically called in a Software Development Kit (SDK), wherein the third party application is determined according to identification information transmitted by a target application program;
specifically, the execution main body of the embodiment of the invention is a Software Development Kit (SDK), in order to integrate the functions of the third party application in the target application program (APP), a run mechanism in the IOS is utilized, namely, corresponding classes and methods are dynamically loaded when the target application program runs, and all third party libraries are not required to be introduced into engineering.
Among them, third party applications include, but are not limited to: functions of the third party application include, but are not limited to, functions of authorized login, payment, sharing, and the like.
In the embodiment of the invention, firstly, a third party application selected by a user at a target application program APP client is required to be determined, and particularly, the third party application selected by the user is determined according to the identification information transmitted by the target application program, and then, the class related to the function of integrating the third party application is dynamically loaded, and for convenience of description, the class related to the function of integrating the third party application is simply called as the class of the third party application.
In one embodiment, if a valued input of a parameter transmission interface of a third party application provided for a target application program APP client is detected, dynamically loading a class of the third party application; wherein the value is in particular identification information of the third party application. For example, if it is detected that a value is input to a WeChat parameter interface provided for a target application program APP client, it is determined that a third party application selected by a user is WeChat, and at the moment, the value is an APPID of WeChat, and then a WeChat class WXapi is dynamically loaded.
In order to call a function in a class of a third party application, the class of the third party application needs to be instantiated, and then the function in the class of the third party application is dynamically called by using an instantiation object of the class of the third party application. In the embodiment of the invention, the class of the third party application is dynamically loaded, and the method specifically comprises the following steps:
capturing pointers of classes of the third party application by using a character string construction class instance function;
if a pointer to the class of the third party application is captured, determining that an instantiation object of the class of the third party application exists.
The character string construction class instance function can be an NSCLASSFromString function, and the NSCLASSFromString function can directly acquire a class from the character string, so that dynamic loading of the class is realized. Capturing pointers to classes of the third party application using string build class instance functions, the specific code may be expressed as:
Class*wxClass=NSClassFromString(@“WXApi”)
if a pointer wxClass to the class of the third party application can be captured (hook), then an instantiation object exists that illustrates the class of the third party application.
After determining that the instantiation object of the class of the third party application exists, registering the third party application by dynamically calling a first method in the class of the third party application inside the SDK.
Step 101, sending an authorization request to a server of the third party application by dynamically calling a second method in the class of the third party application, so that the server of the third party application returns parameters related to the function of the third party application to the target application program;
specifically, after registering the third party application, the SDK sends an authorization request to a server of the third party application by dynamically calling a second method in the class of the third party application; after the authorization request is sent, the client of the third party application is jumped, after the user confirms the authorization, the server of the third party application returns parameters related to the functions of the third party application to the target application program, and then the target application program transmits the parameters related to the functions of the third party application into the SDK through a parameter transmission interface of the third party application provided by the SDK.
It should be noted that, in the embodiment of the present invention, the default user terminal is provided with the client of the third party application. In one embodiment, the authorization request carries the type of parameters required to integrate the functionality of the third party application and the location of parameter returns.
And 102, calling back parameters related to the functions of the third party application, which are transmitted from the target application program, by dynamically calling a third method in the class of the third party application.
Specifically, the third method is dynamically invoked in the SDK and is used for calling back parameters which are transmitted from the target application program and returned by the server of the third party application.
And acquiring parameters returned by the server of the third party application from the SDK, namely acquiring the authorization of the third party application, and utilizing the parameters to realize the function of the third party application.
According to the processing method for the integrated third-party library, which is provided by the embodiment of the invention, through a dynamic calling mechanism, the problem that the IOS-SDK can only use the function of the third-party library by introducing the header file is solved, so that the IOS-SDK and the APP can use the function of the third-party library as required without depending on the existence of the third-party library during compiling, and all the third-party libraries are not required to be introduced into engineering, thereby effectively reducing the workload of client integration and reducing the bag size of the APP.
Based on the foregoing embodiments, the first method for registering the third party application in the class of dynamically calling the third party application in the software development kit SDK specifically includes:
dynamically generating the first method;
if the first method exists in the instantiation object of the class of the third party application, the first method is found, the identification information is used as the reference of the first method, and the first method is instantiated.
Specifically, firstly, a class instance function is constructed by utilizing a character string, a pointer of a class of the third party application is captured when the target application program runs, and if the pointer of the class of the third party application is captured, the existence of an instantiation object of the class of the third party application is determined.
Then, a first method for registering the function of the third party application is dynamically generated, and whether the first method exists in a method table pointed to by a pointer of the class of the third party application is judged.
In one embodiment, the first method is dynamically generated by using a string-acquisition selector function, which is specifically a nsselector from string function, where the nsselector from string function may directly acquire a selector from the string, thereby implementing dynamic loading of the method. That is, a first method for registering the function of the third party application is dynamically generated by using an NSSelecterFromString function, and whether the first method exists in a method table pointed to by a pointer of the class of the third party application is judged by using a responsToSelecter function.
If the first method exists in the method table pointed by the pointer of the class of the third party application, the pointer corresponding to the first method is found, the identification information of the third party application is used as the reference of the first method, the first method is instantiated according to the pointer, and therefore the identification information of the third party application is transmitted into the first method, and the function of the third party application is registered. In one embodiment, the first method is found using an objc_msgsend assembly function. And the parameter transfer is realized by utilizing the objc_msgsend assembly function, so that the efficiency is high, the safety is high, and the method is not easy to crack.
Taking the implementation of the WeChat authorization login function as an example, detecting that a WeChat parameter transmission interface has a value to transmit in the SDK, using an NSCLASSFromString method to remove a WXAPI pointer wxClass in an active hook application when the APP is operated, and returning failure if no instantiation object exists, and terminating the steps. If yes, continuing to generate a register App dynamic method SEL1 by using NSSelecterFormString, then judging whether a SEL1 method exists in a wxClass-directed method table by using a responsToSelecterSelecter, if not, returning to a failure termination step, if so, using an obj_msgSend to find a pointer corresponding to the SEL1 method in the wxClass-directed method table, instantiating the method according to the pointer, and transmitting APPID to register a WeChat authorization login function. The above process can be implemented by the following pseudo code:
Figure BDA0002389256620000091
according to the processing method and the processing device for the integrated third-party library, the parameter transfer is realized by utilizing a dynamic calling mechanism and utilizing the objc_msgsend assembly function, so that a function method to be used in a third-party SDK library header file can be dynamically called when the APP is operated, the workload of client integration is effectively reduced, and the bag size of the APP is reduced.
Based on the foregoing embodiment, before the dynamically calling the second method in the class of the third party application, the method further includes:
and determining that the third party application is installed on the user terminal by dynamically calling a fourth method in the class of the third party application.
It can be understood that if the corresponding third party application is not installed on the user terminal, the integration of the functions of the third party application cannot be achieved, so that before the second method in the class of dynamically calling the third party application sends the authorization request, it needs to be determined that the corresponding third party application is installed on the user terminal.
And determining that the third party application is installed on the user terminal by dynamically calling a fourth method in the class of the third party application, wherein the method specifically comprises the following steps:
dynamically generating the fourth method;
if the fourth method exists in the instantiation object of the class of the third party application, searching and instantiating the fourth method;
and if the return value of the fourth method is true, determining that the third party application is installed on the user terminal.
In one embodiment, a fourth method is dynamically generated by using a string acquisition selector function nsselector from string, wherein the fourth method is used for judging whether the user terminal installs the third party application, and using a responstoselect function to judge whether the fourth method exists in a method table pointed by a pointer of a class of the third party application; if the fourth method exists in the method table pointed by the pointer of the class, using an objc_msgsend function to find a pointer corresponding to the fourth method in the method table pointed by the pointer of the class, and instantiating the second method according to the pointer corresponding to the second method; and if the return value of the fourth method is true, determining that the third party application is installed on the user terminal.
Taking the WeChat authorization login function as an example, after the WeChat authorization function is registered, returning the program to a target application program, calling a login page provided by an SDK by the target application program, after a user clicks a WeChat authorization login entry on the login page, generating an isWXApp implemented dynamic method SEL2 by using NSSelecterFormString in the SDK, judging whether a SEL2 method exists in a method table pointed by wxClass by using a responsecteiecteive function, returning to a failure termination step if the SEL2 method exists, finding a pointer corresponding to the SEL2 in the method table pointed by using objc_msgSend to the wxClass if the SEL2 corresponds to the pointer, and instantiating the method according to the pointer; if the isWXApp executed returns NO, the step is terminated if the user terminal is determined to not install the WeChat, if YES, the step is terminated if the user terminal is determined to install the WeChat client, and the next step is entered. The above process may be implemented using the following pseudocode:
Figure BDA0002389256620000101
Figure BDA0002389256620000111
based on the foregoing embodiment, by dynamically calling a second method in the class of the third party application, an authorization request is sent to the server of the third party application, so that the server of the third party application returns parameters related to the function of the third party application to the target application program, specifically:
dynamically generating the second method;
if the second method exists in the instantiation object of the class of the third party application, the second method is found;
and taking the type of the parameter related to the function of the third party application and the position returned by the parameter which need to be acquired as the parameters of the second method, and instantiating the second method so that the server of the third party application returns the parameter related to the function of the third party application to the target application program according to the type of the parameter and the position returned by the parameter.
Specifically, a second method for sending an authorization request to the server of the third party application can be dynamically generated by using a character string acquisition selector function NSSelectFormString in the SDK, and whether the second method exists in a method table pointed by a pointer of a class of the third party application is judged by using a responsToSelecter function; if it is determined that the second method exists in the instantiation object of the class of the third party application, the second method can be found by using an objc_msgsend assembly function, the type of the parameter related to the function of the third party application and the position where the parameter returns to be acquired are taken as the parameters of the second method, and the second method is instantiated, so that the server of the third party application returns the parameter related to the function of the third party application to the target application program according to the type of the parameter and the position where the parameter returns.
In an optional embodiment, the type of the parameter related to the function of the third party application and the position of the parameter returned to be acquired are taken as parameters of the second method, and the second method is instantiated, so that the server of the third party application returns the parameter related to the function of the third party application to the target application program according to the type of the parameter and the position of the parameter returned, specifically:
capturing an authorization request sending pointer in the target application program by utilizing a character string construction class example function, and if the authorization request sending pointer is captured, constructing an authorization request sending class object, wherein the authorization request sending class object is used for indicating the type of parameters related to the functions of the third party application to be acquired;
and taking the authorization request sending class object, the parameter returning position and the self parameter as the parameters of the second method, and instantiating the second method so that the server of the third party application returns the parameters related to the functions of the third party application to the target application program according to the authorization request sending class object, the parameter returning position and the self parameter.
Specifically, before instantiating the second method, capturing an authorization request sending pointer in the target application program by using a character string construction class instance function NSCLASSFromString, if the authorization request sending pointer is captured, constructing an authorization request sending class object, wherein the authorization request sending class object is used for indicating the type of parameters related to the functions of the third party application to be acquired,
in one embodiment, the grant request transmission pointer is specifically a SendAuthReq pointer. If the SendAuthReq pointer is captured, a SendAuthReq class object is constructed. The SendAuthReq class is used to indicate the specific type of parameters that need to be acquired that are relevant to the functionality of the third party application.
Then, the SendAuthReq object, the position of parameter return and self parameters are taken as parameters of the second method, the second method is instantiated, and the server of the third party application returns parameters related to the functions of the third party application to the target application program according to the SendAuthReq object, the position of parameter return and self parameters.
Taking the implementation of a WeChat authorization login function as an example, generating a sendAuthReq by using NSSelectFormString in the SDK, namely, a sendControler dynamic method SEL3, then judging whether a SEL3 method exists in a wxClass-directed method table by using a responsToSelecter, returning to a failure termination step if the SEL3 method does not exist, finding a pointer corresponding to the SEL3 method by using an obj_msgSend to wxClass-directed method table if the SEL3 method exists, instantiating the SEL3 method according to the pointer, wherein the sendAuthReq pointer in an application is unoccupied by using an NSCLasFromString method, and returning to the failure termination step if an object cannot be instantiated, wherein the sendAuthReq pointer does not exist. Otherwise, constructing a SendAuthReq class object, and transmitting the SendAuthReq class object, the parameter of the Send page object and the parameter of self into a SEL3 method, so that the method can jump to a WeChat client to perform authorized login. The above process can be implemented by the following code:
Figure BDA0002389256620000131
based on the content of the foregoing embodiment, by dynamically calling a third method in the class of the third party application, the parameters related to the function of the third party application, which are transmitted from the target application program, are called back, specifically:
dynamically generating the third method by using a character string acquisition selector function;
if the third method exists in the instantiation object of the class of the third party application, the third method is found, and parameters which are transmitted from the target application program and related to the function of the third party application are taken as parameters of the third method, and the third method is instantiated.
Specifically, the third method may be dynamically generated by using a string acquisition selector function nsselector form string, where the third method is used to call back parameters related to a function of the third party application, which are transmitted from the target application program, and determine whether the third method exists in the method table pointed by the pointer of the class of the third party application by using a responstoselect function.
If the third method exists in the method table pointed by the pointer of the class, the third method can be searched and instantiated by utilizing the objc_msgsend assembly function, and parameters related to the functions of the third party application, which are transmitted from the target application program, are transmitted into the third method, so that parameter callback is realized.
Taking the WeChat authorization login function as an example, after the WeChat authorization login is successful, the WeChat authorization login is skipped back to the target application program APP, and the WeChat related parameters are carried to respond to the application: openURL: options: callback functions in the APPDeleegate.m file under the target application program APP, and then the target application program APP transmits the callback parameters into the SDK through the interface provided by the SDK. When the SDK detects that parameters are input, continuing to generate a handleOpenURL, namely a delete, dynamic method SEL4 by using NSSelectFormString, judging whether a SEL4 method exists in a wxClass-directed method table by using a responsToSelecter, returning to a failure termination step if the SEL4 method does not exist, if the SEL4 method does not exist, using the obj_msgSend to find a pointer corresponding to the SEL4 method in the wxClass, instantiating the method, and inputting the related parameters of WeChat. The above process can be implemented using the following pseudo code:
Figure BDA0002389256620000141
based on the foregoing embodiment, after the step of calling back the parameters related to the function of the third party application, the parameters are further included:
analyzing parameters related to the functions of the third party application by calling a callback function to obtain user data related to the functions of the third party application;
and uploading the user data to a unified user center background to obtain corresponding user information and a user unique identifier, and returning the user information and the user unique identifier to the target application program.
Specifically, after acquiring parameters related to the functions of the third party application in the SDK, calling a callback function, analyzing the parameters related to the functions of the third party application, so as to acquire user data related to the functions of the third party application, acquiring user information and a user unique identifier corresponding to the functions of the third party application in a background server according to the user data, and returning the user information and the user unique identifier to the target application program for subsequent processing.
Still taking the WeChat authorization login function as an example, the parameters related to the functions of the third party application are analyzed inside the SDK by calling the onResp callback function under the file where the self parameters are located, so as to obtain accessToken and openID user authorization data corresponding to the WeChat authorization login function. And uploading the two parameters to a unified user center background to obtain corresponding user information and a user unique identifier in the SDK, returning the data to the APP by the SDK, and carrying out display processing by the APP.
It should be noted that, in the above embodiments of the present invention, a pointer of a class applied by a third party may be captured by using a nsclassfrom string function, where the nsclassfrom string function may directly obtain a class from a character string, so as to implement dynamic loading of the class; the NSSelecterFormString function is utilized to dynamically generate a method in the class of the third party application, and the NSSelecterFromString function can directly acquire a selector from the character string, so that the dynamic loading of the method is realized; judging whether the dynamically generated method exists in the pointer of the class of the third party application or not by utilizing a responstoselect function; and finding a pointer corresponding to the dynamically generated method in a method table pointed by the pointer of the class of the third party application by utilizing the objc_msgsend assembly function, and realizing parameter transfer.
The processing method for the integrated third-party library provided by the embodiment of the invention realizes the full-flow combination of dynamic call and SDK, and utilizes the objc_msgSend assembly function to realize parameter transfer, thereby effectively improving the code operation efficiency of the dynamic integrated third-party library.
Fig. 2 is a schematic flow chart of implementing a WeChat authorization login function by dynamically integrating a third party library according to an embodiment of the present invention.
As shown in fig. 3, a schematic structural diagram of a processing device for integrating a third party library according to an embodiment of the present invention includes:
a third party application registration module 310, configured to invoke a first method for registering a third party application in a class of the third party application, where the third party application is determined according to identification information that is transmitted by a target application program;
specifically, the third party application registration module 310 registers the third party application by invoking a first method in a class of the third party application. And the third party application is determined according to the identification information transmitted by the target application program.
A dynamic authorization module 320, configured to send an authorization request to a server of the third party application by dynamically calling a second method in the class of the third party application, so that the server of the third party application returns parameters related to the function of the third party application to the target application program;
specifically, the dynamic authorization module 320 dynamically invokes a second method in the class of the third party application to send an authorization request to the server of the third party application; after the authorization request is sent, the client of the third party application is jumped, and after the user confirms the authorization, the server of the third party application returns parameters related to the functions of the third party application to the target application program; the target application program transmits the parameters related to the functions of the third party application into the SDK through a parameter transmission interface of the third party application provided by the SDK.
And the parameter callback module 330 is configured to callback parameters related to the functions of the third party application, which are input from the target application program, by dynamically calling a third method in the class of the third party application.
Specifically, the parameter callback module 330 dynamically invokes a third method in the class of the third party application, where the third method is used to callback parameters that are returned from the server of the third party application and are transmitted from the target application program. And acquiring parameters returned by the server of the third-party application, and utilizing the parameters to realize the function authorization of the third-party application.
The processing device integrating the third party library solves the problem that the IOS-SDK can only use the third party library function by introducing the header file through a dynamic calling mechanism, so that the IOS-SDK and the APP can use the function of the third party library as required without depending on the existence of the third party library during compiling, and all the third party libraries are not required to be introduced into engineering, thereby effectively reducing the workload of client integration and reducing the bag size of the APP.
Fig. 4 is a schematic physical structure diagram of an electronic device according to an embodiment of the present invention, as shown in fig. 4, where the electronic device may include: processor 410, communication interface (Communications Interface) 420, memory 430 and communication bus 440, wherein processor 410, communication interface 420 and memory 430 communicate with each other via communication bus 440. The processor 410 may invoke a computer program stored in the memory 430 and executable on the processor 410 to perform the processing method of the integrated third party library provided by the above method embodiments, for example, including: a first method for registering a third party application in a class of the third party application is dynamically called in a Software Development Kit (SDK), wherein the third party application is determined according to identification information transmitted by a target application program; sending an authorization request to a server of the third party application by dynamically calling a second method in the class of the third party application, so that the server of the third party application returns parameters related to the function of the third party application to the target application program; and calling back parameters related to the functions of the third party application, which are transmitted from the target application program, by dynamically calling a third method in the class of the third party application.
Further, the logic instructions in the memory 430 described above may be implemented in the form of software functional units and may be stored in a computer-readable storage medium when sold or used as a stand-alone product. Based on such understanding, the technical solution of the embodiments of the present invention may be embodied in essence or a part contributing to the prior art or a part of the technical solution in the form of a software product stored in a storage medium, including several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in the embodiments of the present invention. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a random access Memory (RAM, random Access Memory), a magnetic disk, or an optical disk, or other various media capable of storing program codes.
The embodiments of the present invention further provide a non-transitory computer readable storage medium, on which a computer program is stored, where the computer program when executed by a processor implements the processing method of the integrated third party library provided in the foregoing method embodiments, for example, including: a first method for registering a third party application in a class of the third party application is dynamically called in a Software Development Kit (SDK), wherein the third party application is determined according to identification information transmitted by a target application program; sending an authorization request to a server of the third party application by dynamically calling a second method in the class of the third party application, so that the server of the third party application returns parameters related to the function of the third party application to the target application program; and calling back parameters related to the functions of the third party application, which are transmitted from the target application program, by dynamically calling a third method in the class of the third party application.
The apparatus embodiments described above are merely illustrative, wherein the elements illustrated as separate elements may or may not be physically separate, and the elements shown as elements may or may not be physical elements, may be located in one place, or may be distributed over a plurality of network elements. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment. Those of ordinary skill in the art will understand and implement the present invention without undue burden.
From the above description of the embodiments, it will be apparent to those skilled in the art that the embodiments may be implemented by means of software plus necessary general hardware platforms, or of course may be implemented by means of hardware. Based on this understanding, the foregoing technical solution may be embodied essentially or in a part contributing to the prior art in the form of a software product, which may be stored in a computer readable storage medium, such as ROM/RAM, a magnetic disk, an optical disk, etc., including several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute the method described in the respective embodiments or some parts of the embodiments.
Finally, it should be noted that: the above embodiments are only for illustrating the technical solution of the present invention, and are not limiting; although the invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical scheme described in the foregoing embodiments can be modified or some technical features thereof can be replaced by equivalents; such modifications and substitutions do not depart from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims (10)

1. A method of processing an integrated third party library, comprising:
a first method for registering a third party application in a class of the third party application is dynamically called in a Software Development Kit (SDK), wherein the third party application is determined according to identification information transmitted by a target application program;
sending an authorization request to a server of the third party application by dynamically calling a second method in the class of the third party application, so that the server of the third party application returns parameters related to the function of the third party application to the target application program;
and calling back parameters related to the functions of the third party application, which are transmitted from the target application program, by dynamically calling a third method in the class of the third party application.
2. The method for processing the integrated third party library according to claim 1, wherein the first method for registering the third party application in the class of the third party application dynamically called inside the software development kit SDK specifically comprises:
dynamically generating the first method;
if the first method exists in the instantiation object of the class of the third party application, the first method is found, the identification information is used as the reference of the first method, and the first method is instantiated.
3. The method for processing the integrated third party library according to claim 1, further comprising, before said dynamically invoking the second method in the class of the third party application:
and determining that the third party application is installed on the user terminal by dynamically calling a fourth method in the class of the third party application.
4. The method for processing the integrated third party library according to claim 1, wherein by dynamically calling the second method in the class of the third party application, an authorization request is sent to the server of the third party application, so that the server of the third party application returns parameters related to the function of the third party application to the target application program, specifically:
dynamically generating the second method;
if the second method exists in the instantiation object of the class of the third party application, the second method is found;
and taking the type of the parameter related to the function of the third party application and the position returned by the parameter which need to be acquired as the parameters of the second method, and instantiating the second method so that the server of the third party application returns the parameter related to the function of the third party application to the target application program according to the type of the parameter and the position returned by the parameter.
5. The method for processing the integrated third party library according to claim 4, wherein the type of the parameter related to the function of the third party application and the location of the parameter return to be acquired are taken as parameters of the second method, and the second method is instantiated so that the server of the third party application returns the parameter related to the function of the third party application to the target application program according to the type of the parameter and the location of the parameter return, specifically:
capturing an authorization request sending pointer in the target application program by utilizing a character string construction class example function, and if the authorization request sending pointer is captured, constructing an authorization request sending class object, wherein the authorization request sending class object is used for indicating the type of parameters related to the functions of the third party application to be acquired;
and taking the authorization request sending class object, the parameter returning position and the self parameter as the parameters of the second method, and instantiating the second method so that the server of the third party application returns the parameters related to the functions of the third party application to the target application program according to the authorization request sending class object, the parameter returning position and the self parameter.
6. The method for processing the integrated third party library according to claim 1, wherein the parameters related to the functions of the third party application, which are transmitted from the target application program, are recalled by dynamically calling the third party method in the class of the third party application, specifically:
dynamically generating the third method;
if the third method exists in the instantiation object of the class of the third party application, the third method is found, and parameters which are transmitted from the target application program and related to the function of the third party application are taken as parameters of the third method, and the third method is instantiated.
7. The method of claim 1, wherein the step of calling back parameters related to the functionality of the third party application, which are imported from the target application program, further comprises:
analyzing parameters related to the functions of the third party application by calling a callback function to obtain user data related to the functions of the third party application;
and uploading the user data to a unified user center background to obtain corresponding user information and a user unique identifier, and returning the user information and the user unique identifier to the target application program.
8. A processing apparatus for integrating a third party library, comprising:
the third party application registration module is used for calling a first method for registering the third party application in the class of the third party application, wherein the third party application is determined according to the identification information transmitted by the target application program;
the dynamic authorization module is used for sending an authorization request to the server of the third party application by dynamically calling a second method in the class of the third party application so that the server of the third party application returns parameters related to the function of the third party application to the target application program;
and the parameter callback module is used for calling the parameters which are transmitted from the target application program and related to the functions of the third party application by dynamically calling the third method in the class of the third party application.
9. An electronic device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, wherein the processor performs the steps of the method of integrating a third party library according to any one of claims 1 to 7 when the program is executed.
10. A non-transitory computer readable storage medium, on which a computer program is stored, characterized in that the computer program, when being executed by a processor, implements the steps of the processing method of the integrated third party library according to any one of claims 1 to 7.
CN202010108828.4A 2020-02-21 2020-02-21 Processing method and device for integrated third party library Active CN111309407B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010108828.4A CN111309407B (en) 2020-02-21 2020-02-21 Processing method and device for integrated third party library

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010108828.4A CN111309407B (en) 2020-02-21 2020-02-21 Processing method and device for integrated third party library

Publications (2)

Publication Number Publication Date
CN111309407A CN111309407A (en) 2020-06-19
CN111309407B true CN111309407B (en) 2023-07-11

Family

ID=71160160

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010108828.4A Active CN111309407B (en) 2020-02-21 2020-02-21 Processing method and device for integrated third party library

Country Status (1)

Country Link
CN (1) CN111309407B (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112764729B (en) * 2021-01-08 2024-02-06 深圳依时货拉拉科技有限公司 Application software development method, device, computer equipment and readable storage medium
CN114461226A (en) * 2022-04-07 2022-05-10 广州易方信息科技股份有限公司 Method and device for solving mandatory dependence

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103530156A (en) * 2013-10-17 2014-01-22 北京奇虎科技有限公司 Method and device for dynamically loading and calling program
CN105094878A (en) * 2014-05-22 2015-11-25 阿里巴巴集团控股有限公司 System library file integration method and apparatus
CN109582400A (en) * 2018-11-30 2019-04-05 北京小米移动软件有限公司 Routine call method and device
CN110427319A (en) * 2019-07-22 2019-11-08 上海易点时空网络有限公司 The hot restorative procedure of lightweight and device, storage medium based on IOS

Family Cites Families (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2016061762A1 (en) * 2014-10-22 2016-04-28 刘大澎 Multi-channel sdk access system and method for mobile terminal software
CN105656922A (en) * 2016-02-04 2016-06-08 腾讯科技(深圳)有限公司 Login method and device of application program and intelligent equipment
CN105843654A (en) * 2016-04-14 2016-08-10 广州市久邦数码科技有限公司 Method and system for implementing dynamic loading of advertisement SDK (software development kit)
US11340961B2 (en) * 2017-03-23 2022-05-24 Airwatch Llc Dynamically integrating a client application with third-party services
CN107977274B (en) * 2017-10-19 2021-01-05 北京奇艺世纪科技有限公司 SDK calling control method and device
CN108829467B (en) * 2018-04-28 2020-05-22 蜂助手股份有限公司 Third-party platform docking implementation method, device, equipment and storage medium
CN109522021B (en) * 2018-10-30 2022-03-25 咪咕文化科技有限公司 Parameter callback processing method and device, electronic equipment and storage medium

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103530156A (en) * 2013-10-17 2014-01-22 北京奇虎科技有限公司 Method and device for dynamically loading and calling program
CN105094878A (en) * 2014-05-22 2015-11-25 阿里巴巴集团控股有限公司 System library file integration method and apparatus
CN109582400A (en) * 2018-11-30 2019-04-05 北京小米移动软件有限公司 Routine call method and device
CN110427319A (en) * 2019-07-22 2019-11-08 上海易点时空网络有限公司 The hot restorative procedure of lightweight and device, storage medium based on IOS

Also Published As

Publication number Publication date
CN111309407A (en) 2020-06-19

Similar Documents

Publication Publication Date Title
US9141444B2 (en) Inter-application communication on mobile platforms
US8296445B1 (en) Software testing harness
US7877091B2 (en) Method and system for executing a container managed application on a processing device
US9280665B2 (en) Fast and accurate identification of message-based API calls in application binaries
US9342333B2 (en) Backend custom code extensibility
CN110096370B (en) Control inversion component service model for virtual environments
CN111309407B (en) Processing method and device for integrated third party library
US10754717B2 (en) Fast and accurate identification of message-based API calls in application binaries
CN111143087A (en) Interface calling method and device, storage medium and server
KR20110128632A (en) Method and device for detecting malicious action of application program for smartphone
CN112948835A (en) Applet risk detection method and device
CN113726943A (en) Control method and electronic device
CN109388388B (en) Information interaction method, device, equipment and storage medium between function modules
US8738755B2 (en) Providing external access to service versions via a bundle framework
CN113010892B (en) Method and device for detecting malicious behavior of small program
CN112154417A (en) Sharing a code base between a stand-alone version and a Web-based version of an application via an emulated network communication channel
CN112163193A (en) Broadcast registration control method, device, equipment and medium
CN112732547B (en) Service testing method and device, storage medium and electronic equipment
CN111049795B (en) Method and device for detecting sensitive data unencrypted vulnerability of distributed Web application
CN114301970A (en) Service calling method and device, electronic equipment and storage medium
CN113176907A (en) Interface data calling method and device, computer system and readable storage medium
CN111124627A (en) Method, device, terminal and storage medium for determining application program caller
CN116010112B (en) Method and device for calling hook function, computer equipment and readable storage medium
US11533282B1 (en) Specifying and testing open communication protocols
CN114385384B (en) Application programming interface calling method and related equipment

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant