A method, device, terminal and storage medium for detecting authorization
By obtaining and judging the authorization request description information of the target application in the applet, the crash problem caused by the applet due to the unconfigured purpose description is solved, and the safe operation without code modification is achieved and economic cost savings are achieved, which improves the user experience.
Patent Information
- Application Number
- CN202011559947.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-12-25
- Publication Date
- 2024-12-13
- Estimated Expiration
- 2040-12-25
AI Technical Summary
When the applet applies for permissions at runtime, the target application does not configure the corresponding purpose description, resulting in a crash. The existing solution requires modifying the code, which is time-consuming and laborious, and economically expensive, and is prone to errors.
By obtaining the description information of the target authorization request based on the preset string in the applet, we can determine whether the target application has a purpose description. If configured, an authorization request will be initiated. If not configured, it will not initiate, avoid crashes and save costs.
It effectively avoids the target application crash caused by the applet due to the unconfigured purpose description, saves economic costs, is not prone to errors, ensures the normal operation of the application and improves the user experience.
Smart Images

Figure CN112667421B_ABST
Abstract
Description
Technical Field
[0001] The present application belongs to the field of computer technology, and in particular, relates to a method for detecting authorization, a device for detecting authorization, a terminal for detecting authorization, and a storage medium. Background Art
[0002] Mini programs run in mobile applications (Application, APP). When running, they will apply for many permissions. Some permissions APP does not have, which will cause APP to crash. The traditional solution is to declare a repair through the host APP, or the mini program deletes the relevant permission application. No matter which solution is used, the corresponding code needs to be modified, which is time-consuming, labor-intensive, economically costly, and prone to errors. Summary of the invention
[0003] In view of this, the embodiments of the present application provide a method for detecting authorization, a device for detecting authorization, a terminal for detecting authorization, and a storage medium to solve the problem in the prior art that when a mini program applies for permission from an application, the application crashes because it does not have the permission.
[0004] A first aspect of an embodiment of the present application provides a method for detecting authorization, including:
[0005] Based on the first preset character string, in the target application corresponding to the mini program, obtain first description information corresponding to the target authorization request;
[0006] Based on a second preset character string, in the target application, obtaining second description information corresponding to the target authorization request;
[0007] Based on the first description information and the second description information, determining whether the target application is configured with a usage description corresponding to the target authorization request, the first description information and the second description information both corresponding to the usage description;
[0008] If the result of the determination is that the target application has the usage description configured therein, then initiating the target authorization request; or,
[0009] If the judgment result is that the usage description is not configured in the target application, the target authorization request is not initiated.
[0010] A second aspect of an embodiment of the present application provides a device for detecting authorization, including:
[0011] A first acquisition unit, configured to acquire, based on a first preset character string, first description information corresponding to a target authorization request in a target application corresponding to the mini program;
[0012] A second acquisition unit, configured to acquire, in the target application, second description information corresponding to the target authorization request based on a second preset character string;
[0013] A judging unit, configured to judge whether a usage description corresponding to the target authorization request is configured in the target application based on the first description information and the second description information, wherein both the first description information and the second description information correspond to the usage description;
[0014] A first processing unit, configured to initiate the target authorization request if a judgment result shows that the usage description is configured in the target application;
[0015] The second processing unit is configured to not initiate the target authorization request if the judgment result is that the usage description is not configured in the target application.
[0016] A third aspect of an embodiment of the present application provides a terminal for detecting authorization, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the method for detecting authorization as described in the first aspect above when executing the computer program.
[0017] A fourth aspect of an embodiment of the present application provides a computer storage medium, which stores a computer program. When the computer program is executed by a processor, the steps of the method for detecting authorization as described in the first aspect above are implemented.
[0018] A fifth aspect of an embodiment of the present application provides a computer program product. When the computer program product is run on a terminal for detecting authorization, the terminal for detecting authorization executes the steps of the method for detecting authorization described in the first aspect above.
[0019] The embodiments of the present application provide a method, device, terminal, and storage medium for detecting authorization, which have the following beneficial effects:
[0020] In the embodiment of the present application, based on the first preset string, the first description information corresponding to the target authorization request is obtained in the target application corresponding to the mini program; based on the second preset string, the second description information corresponding to the target authorization request is obtained in the target application; based on the first description information and the second description information, it is determined whether the target application is configured with the use description corresponding to the target authorization request; if the result of the determination is that the use description is configured in the target application, the target authorization request is initiated; if the result of the determination is that the use description is not configured in the target application, the target authorization request is not initiated. In the above method, the mini program does not initiate a target authorization request to its corresponding target application first, but first obtains the first description information and the second description information corresponding to the target authorization request based on the first preset string and the second preset string, respectively, and determines whether the target application is configured with the use description corresponding to the target authorization request based on the first description information and the second description information; if it is determined that the target application is configured with the use description, the target authorization request is initiated to the target mini program; if it is determined that the use description is not configured in the target application, the target authorization request is not initiated to the target mini program. This method can effectively avoid the situation where the corresponding use description is not configured in the target application, and the mini program initiates a target authorization request, which leads to the crash of the target application. Moreover, this way of mini-program authorization detection effectively prevents the target application from crashing without modifying the target application code or deleting the permission application with the mini-program, thus saving economic costs, being less prone to errors, ensuring the normal operation of the target application, and improving the user experience. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.
[0022] Figure 1 is a schematic flow chart of a method for detecting authorization provided in an embodiment of the present application;
[0023] Figure 2 is a schematic flow chart of a method for detecting authorization provided by another embodiment of the present invention;
[0024] Figure 3 is a schematic flow chart of a method for detecting authorization provided by another embodiment of the present invention;
[0025] Figure 4 This is a pop-up consultation schematic diagram provided by the present invention;
[0026] Figure 5 is a schematic flow chart of a method for detecting authorization provided by yet another embodiment of the present invention;
[0027] Figure 6 is a schematic diagram of a device for detecting authorization provided in an embodiment of the present application;
[0028] Figure 7 It is a schematic diagram of a terminal for detecting authorization provided in another embodiment of the present application. DETAILED DESCRIPTION
[0029] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0030] Mini programs are applications that can be used without downloading or installing, realizing the dream of having applications at your fingertips. Users can open applications by scanning or searching. The use of mini programs also reflects the concept of use and go. Applications will be ubiquitous and available at any time, but there is no need to install or uninstall them. Users no longer have to worry about installing too many applications and occupying memory. Therefore, the application of mini programs is becoming more and more widespread.
[0031] The inventors realized that when a mini program runs in a mobile application, it will apply for many permissions, some of which the APP does not have, which will cause the APP to crash. The traditional solution is to declare a repair through the host APP, or the mini program deletes the relevant permission application. Regardless of which solution is used, the corresponding code needs to be modified, which is time-consuming, labor-intensive, economically costly, and prone to errors.
[0032] In view of this, the embodiments of the present application provide a method for detecting authorization, an apparatus for detecting authorization, a terminal for detecting authorization, and a storage medium. In this method, the mini program does not first initiate a target authorization request to its corresponding target application, but first obtains the first description information and the second description information corresponding to the target authorization request based on the first preset character string and the second preset character string, respectively, and determines whether the target application is configured with a usage description corresponding to the target authorization request based on the first description information and the second description information; if the usage description is detected, then the target authorization request is initiated to the target mini program; if the usage description is not detected, the target authorization request is not initiated to the target mini program. This method can effectively avoid the situation where the target application is not configured with the corresponding usage description, and the mini program initiates a target authorization request, which in turn causes the target application to crash. And this mini program detection authorization method effectively prevents the target application from crashing without modifying the target application code or deleting the permission application with the mini program, saving economic costs, being less prone to errors, ensuring the normal operation of the target application, and improving the user experience.
[0033] See also Figure 1 , Figure 1 : is a schematic flow chart of a method for detecting authorization provided in an embodiment of the present application. The execution subject of the method for detecting authorization in this embodiment is a terminal, a server, etc., wherein the terminal includes but is not limited to mobile terminals such as smart phones, tablet computers, computers, personal digital assistants (PDAs), and may also include terminals such as desktop computers. In this embodiment, the execution subject is taken as an example for explanation, such as Figure 1 The authorization detection method shown may include S101 to S105. It is worth noting that S104 and S105 are arranged in parallel. According to different detection results in S103, it is determined whether S104 or S105 is executed after S103, rather than executing S105 after S104. The details are as follows:
[0034] S101: Based on a first preset character string, obtain first description information corresponding to a target authorization request in a target application corresponding to the mini program.
[0035] When the mini program runs in an application, the target application refers to the application in which the mini program runs. When the mini program runs in the target application, it will apply for many permissions from the target application, such as the permission to obtain user information, geographic location, camera, mailing address, invoice header, exercise step count, save to album, recording, read address book, video, and gallery, etc.
[0036] Correspondingly, the target authorization request includes user information authorization request, geographic location authorization request, camera authorization request, mailing address authorization request, invoice header authorization request, exercise step authorization request, save to album authorization request, recording authorization request, read address book authorization request, video recording authorization request, access album authorization request, get mobile phone information authorization request, access calendar authorization request, access mobile phone account authorization request, read and write mobile phone storage authorization request, turn on Bluetooth authorization request, turn on near field communication (NFC), desktop shortcut creation request, background pop-up interface request, display floating window request, etc.
[0037] However, the target application does not have all the permissions applied for by the mini program. The target application also needs to obtain these permissions from the terminal system in advance. When the target application does not have certain permissions, and the mini program happens to apply for permissions that the target application does not have, if the existing technology is used, the target application will crash, for example, the target application is forced to exit, the target application is stuck, the current function of the target application cannot be used, etc. This is only an exemplary description and is not limited to this.
[0038] In an embodiment of the present application, the mini program does not first initiate a target authorization request to the target application, but first detects based on the terminal whether a purpose description corresponding to the target authorization request is configured in the target application where the mini program is running. Among them, the purpose description corresponding to the target authorization request can also be called the purpose statement corresponding to the target authorization request, which can be understood as the purpose description is a specific explanation of what the permission that the target authorization request wants to obtain is used for. For example, the target authorization request is: geographic location authorization request, and the purpose description corresponding to the geographic location authorization request is: obtaining the current geographic location of the terminal used by the user. The target authorization request is: access album authorization request, and the purpose description corresponding to the access album authorization request is: accessing the album in the terminal used by the user. This is only an exemplary explanation and is not limited to this.
[0039] Exemplarily, detecting whether a usage description corresponding to a target authorization request is configured in a target application running the mini program can be based on a first preset character string, and obtaining first description information corresponding to the target authorization request in the target application corresponding to the mini program.
[0040] Specifically, the target application has a corresponding preset document, which is essentially a dictionary for storing purpose descriptions corresponding to all authorization requests. The first preset character string is used to pre-write the purpose description corresponding to the target authorization request into the preset document corresponding to the target application. The first description information is the purpose description corresponding to the target authorization request pre-written in the preset document corresponding to the target application. Accordingly, the description information written in the preset document by the target authorization request can also be obtained in the target application through the first preset character string, that is, the first description information corresponding to the target authorization request is obtained.
[0041] Exemplarily, the preset document may be an info.plist file, and the first preset string may include a key string, through which the usage description corresponding to the geolocation authorization request may be pre-written into the info.plist file corresponding to the target application. Accordingly, the first description information corresponding to the geolocation authorization request may be obtained in the target application through the key string, that is, the specific description information written in the info.plist file by the geolocation authorization request. For example, the first description information obtained may be "geolocation authorization request: obtain the current geographic location of the terminal used by the user".
[0042] If the usage description corresponding to the geolocation authorization request is not written into the info.plist file corresponding to the target application through the key string in advance, that is, the target application does not have the permission corresponding to the geolocation authorization request, then the first description information obtained may be "geolocation authorization request:". That is, the usage description corresponding to the geolocation authorization request is empty. This is only an exemplary description and is not limited to this.
[0043] For example, when the target authorization request is an authorization request for accessing the photo album, based on the key string, the first description information corresponding to the authorization request for accessing the photo album is obtained in the target application, and the first description information may be "Authorization request for accessing the photo album: accessing the photo album in the terminal used by the user"; or, the first description information may be "Authorization request for accessing the photo album:" (i.e., the purpose description corresponding to the authorization request for accessing the photo album is empty). This is only an exemplary description and is not limited to this.
[0044] For example, when the mini program is running in the target application, if it wants to initiate a geolocation authorization request, first based on the first preset string, in the target application corresponding to the mini program, obtain the first description information corresponding to the geolocation authorization request. Alternatively, when the mini program is running in the target application, if it wants to initiate an album access authorization request, first based on the first preset string, in the target application corresponding to the mini program, obtain the first description information corresponding to the album access authorization request. This is only an exemplary description and is not limited to this.
[0045] S102: Based on a second preset character string, in the target application, obtain second description information corresponding to the target authorization request.
[0046] The second preset string is used to read the specific description information corresponding to the target authorization request in the preset document. It can be understood that the first preset string is the description information corresponding to the target authorization request written in the preset document, and the second preset string is to read out the specific description information written by the first preset string. Therefore, both the first description information and the second description information are information corresponding to the purpose description. Through the second preset string, the specific description information written in the preset document based on the first preset string is obtained in the target application, that is, the second description information corresponding to the target authorization request is obtained.
[0047] When the first description information contains specific description information corresponding to the target authorization request, the second description information will obtain the specific description information corresponding to the target authorization request; when the first description information does not contain specific description information corresponding to the target authorization request, the second description information can only obtain the identification information corresponding to the target authorization request, such as "target authorization request:". This is only an exemplary description and is not limited to this.
[0048] Exemplarily, the second preset character string may include a value character string, through which specific description information of the geographic location authorization request written in the info.plist file based on the key character string can be obtained in the target application.
[0049] For example, when the first description information is "geolocation authorization request: obtain the current geographic location of the terminal used by the user", the second description information obtained is "obtain the current geographic location of the terminal used by the user". When the first description information is "geolocation authorization request:", the second description information obtained is "geolocation authorization request:". It can be understood that when there is specific description information corresponding to the geolocation authorization request in the first description information, the second description information will obtain the specific description information corresponding to the geolocation authorization request; when there is no specific description information corresponding to the geolocation authorization request in the first description information, the second description information can only obtain the identification information corresponding to the geolocation authorization request, that is, "geolocation authorization request:".
[0050] When the first description information is "Access Album Authorization Request: Access the album in the terminal used by the user", the second description information obtained is "Access the album in the terminal used by the user". When the first description information is "Access Album Authorization Request:", the second description information obtained is "Access Album Authorization Request:".
[0051] This is just an example and is not intended to be limiting.
[0052] S103: Based on the first description information and the second description information, determining whether the target application is configured with a usage description corresponding to the target authorization request, wherein both the first description information and the second description information correspond to the usage description;
[0053] Exemplarily, it is detected whether the first description information and the second description information are consistent. When it is detected that the first description information is inconsistent with the second description information, the judgment result is that the target application is configured with a usage description corresponding to the target authorization request. When it is detected that the first description information and the second description information are completely consistent, the judgment result is that the target application is not configured with a usage description corresponding to the target authorization request.
[0054] When the result of the determination in S103 is that a usage description corresponding to the target authorization request is configured in the target application, S104 is executed after S103.
[0055] S104: If the determination result is that the target application has the usage description configured therein, then the target authorization request is initiated.
[0056] When the judgment result is that the target application is configured with a usage description corresponding to the target authorization request, it means that the target application has obtained the permission corresponding to the target authorization request from the terminal system in advance. At this time, the mini program initiates a target authorization request to the target application. Since the target application has obtained the permission corresponding to the target authorization request from the terminal system in advance, the mini program initiates a target authorization request to the target application at this time, and the target application will not crash.
[0057] Exemplarily, when the mini program is running in the target application, if it wants to initiate a geolocation authorization request, it first determines whether the target application is configured with a usage description corresponding to the geolocation authorization request based on the first preset string obtained corresponding to the geolocation authorization request, and the second description information corresponding to the geolocation authorization request obtained based on the second preset string. When the judgment result is that the target application is configured with a usage description corresponding to the geolocation authorization request, it means that the target application has obtained the permission corresponding to the geolocation authorization request from the terminal system in advance. At this time, the mini program initiates a geolocation authorization request to the target application, and the target application will not crash.
[0058] Alternatively, when the mini program is running in the target application, if it wants to initiate an authorization request for accessing the photo album, it first determines whether the target application is configured with a usage description corresponding to the authorization request for accessing the photo album based on the first description information corresponding to the authorization request for accessing the photo album obtained based on the first preset character string, and the second description information corresponding to the authorization request for accessing the photo album obtained based on the second preset character string. When the judgment result is that the usage description corresponding to the authorization request for accessing the photo album is configured in the target application, it means that the target application has obtained the corresponding permission for the authorization request for accessing the photo album from the terminal system in advance. At this time, the mini program initiates an authorization request for accessing the photo album to the target application, and the target application will not crash. This is only an exemplary description and is not limited to this.
[0059] When the result of the determination in S103 is that the usage description corresponding to the target authorization request is not configured in the target application, S105 is executed after S103.
[0060] S105: If the result of the determination is that the usage description is not configured in the target application, then the target authorization request is not initiated.
[0061] When the judgment result is that the target application does not have a usage description corresponding to the target authorization request configured, it means that the target application has not obtained the permissions corresponding to the target authorization request from the terminal system in advance. At this time, the mini program does not initiate a target authorization request to the target application. Since the target application has not obtained the permissions corresponding to the target authorization request from the terminal system in advance, if the mini program initiates a target authorization request to the target application at this time, the target application will crash. In order to avoid this situation, the mini program does not initiate a target authorization request to the target application. In layman's terms, if the target application does not have the permissions corresponding to the target authorization request, the mini program will cause the target application to crash if it rashly initiates the target authorization request.
[0062] Exemplarily, when the mini program is running in the target application, if it wants to initiate a geolocation authorization request, it first determines whether the target application is configured with a usage description corresponding to the geolocation authorization request based on the first preset string, and the second description information corresponding to the geolocation authorization request based on the second preset string. If the judgment result is that the usage description corresponding to the geolocation authorization request is not configured in the target application, the mini program does not initiate a geolocation authorization request to the target application, so as to avoid the crash of the target application.
[0063] Alternatively, when the mini program is running in the target application, if it wants to initiate an authorization request for accessing the photo album, it first determines whether the target application is configured with a usage description corresponding to the authorization request for accessing the photo album based on the first description information corresponding to the authorization request for accessing the photo album obtained based on the first preset character string, and the second description information corresponding to the authorization request for accessing the photo album obtained based on the second preset character string. When the judgment result is that the usage description corresponding to the authorization request for accessing the photo album is not configured in the target application, at this time, the mini program does not initiate an authorization request for accessing the photo album to the target application, so as to avoid the crash of the target application. This is only an exemplary description and is not limited to this.
[0064] See also Figure 2 , Figure 2 is a schematic flow chart of a method for detecting authorization provided by another embodiment of the present invention. Optionally, in a possible implementation, Figure 2 As shown, the above S103 may include S1031 to S1033. It is worth noting that S1032 and S1033 are arranged in parallel. According to the execution result of S1031, it is determined whether S1032 or S1033 is executed after S1031, rather than executing S1033 after S1032. The details are as follows:
[0065] S1031: Detect whether the first description information is consistent with the second description information.
[0066] After obtaining the first description information corresponding to the target authorization request and the second description information corresponding to the target authorization request, it is detected whether the specific information contents of the first description information and the second description information are consistent.
[0067] When it is detected that the first description information is inconsistent with the second description information, S1032 is executed after S1031.
[0068] S1032: When it is detected that the first description information is inconsistent with the second description information, the judgment result is that the usage description is configured in the target application.
[0069] If the detection result is that the first description information is inconsistent with the second description information, it is determined that a usage description corresponding to the target authorization request is configured in the target application.
[0070] For example, the first description information obtained is "geolocation authorization request: obtain the current geographical location of the terminal used by the user", and the second description information obtained is "obtain the current geographical location of the terminal used by the user". The first description information is inconsistent with the second description information. Obviously, at this time, the target application is configured with a usage description corresponding to the geolocation authorization request.
[0071] For example, the first description information obtained is "Access to photo album authorization request: access to the photo album in the terminal used by the user", and the second description information obtained is "Access to the photo album in the terminal used by the user". The first description information is inconsistent with the second description information. Obviously, at this time, the target application is configured with a usage description corresponding to the access to photo album authorization request.
[0072] This is just an example and is not intended to be limiting.
[0073] When it is detected that the first description information is completely consistent with the second description information, S1033 is executed after S1031.
[0074] S1033: When it is detected that the first description information is completely consistent with the second description information, the judgment result is that the usage description is not configured in the target application.
[0075] If the detection result is that the first description information is completely consistent with the second description information, it is determined that the target application is not configured with a usage description corresponding to the target authorization request.
[0076] Exemplarily, the first description information obtained is "geolocation authorization request:", and the second description information obtained is "geolocation authorization request:". The first description information is completely consistent with the second description information. Obviously, at this time, the target application has not configured the usage description corresponding to the geolocation authorization request.
[0077] For example, the first description information obtained is "Access Album Authorization Request:", and the second description information obtained is "Access Album Authorization Request:". The first description information is completely consistent with the second description information. Obviously, at this time, the target application has not configured the usage description corresponding to the access album authorization request.
[0078] This is just an example and is not intended to be limiting.
[0079] See also Figure 3 , Figure 3 is a schematic flow chart of a method for detecting authorization provided by another embodiment of the present invention. Optionally, in a possible implementation, Figure 3 As shown, the above S104 may include S1041 to S1043. It is worth noting that S1042 and S1043 are in parallel. According to the execution result of S1041, it is determined whether S1042 or S1043 is executed after S1041, rather than S1043 being executed after S1042. The details are as follows:
[0080] S1041: If the judgment result is that the usage description is configured in the target application, a pop-up consultation is initiated in the display interface of the mini-program, and the pop-up consultation is used to consult the user whether to agree to the target authorization request.
[0081] When the judgment result is that the target application is configured with a usage description corresponding to the target authorization request, a pop-up window consultation is initiated on the display interface of the mini program. The pop-up window consultation is used to consult the user whether to agree to the target authorization request, that is, the pop-up window consultation is used to consult the user whether he is willing to authorize the permissions requested by the mini program.
[0082] See also Figure 4 , Figure 4 This is a pop-up consultation diagram provided by the present invention. For example, when the target authorization request is a geographic location authorization request, the specific information displayed in the pop-up consultation may be: request to grant the current location, and under "request to grant the current location" is displayed in different colors of text: need to obtain your geographic location, please confirm the authorization, and a "Cancel" touchable control is set on the left at the bottom of the pop-up window, and a "Confirm" touchable control is set on the right. This is only an exemplary description and is not limited to this.
[0083] S1042: When the user agrees to the target authorization request, the mini program is granted permissions corresponding to the target authorization request.
[0084] When the user's authorization consent instruction is obtained, that is, when the user agrees to grant the permission corresponding to the target authorization request, the permission corresponding to the target authorization request is granted to the mini program.
[0085] For example, Figure 4 As shown, when the user wants to agree to the target authorization request, he can click the "OK" touchable control in the lower right corner of the pop-up window to trigger the instruction to agree to the authorization. The terminal receives the instruction to agree to the authorization and grants the mini program the permissions corresponding to the geographic location authorization request based on the target application. That is, the mini program can obtain the geographic location of the terminal user. This is only an exemplary description and is not limited to this.
[0086] S1043: When the user disagrees with the target authorization request, authorization failure information is generated.
[0087] When the user's instruction to refuse authorization is obtained, that is, the user refuses to grant the permission corresponding to the target authorization request, the permission corresponding to the target authorization request will not be granted to the mini program, and authorization failure information is generated at the same time. The authorization failure information is used to prompt the current mini program that the permission corresponding to the target authorization request has failed.
[0088] For example, Figure 4As shown, when the user wants to reject the target authorization request, he can click the "Cancel" touchable control in the lower left corner of the pop-up window to trigger the instruction to reject authorization. The terminal receives the instruction to reject authorization and refuses to grant the mini program the permission corresponding to the geolocation authorization request based on the target application. That is, the mini program did not obtain the geographic location of the terminal user. At the same time, authorization failure information can also be generated. The authorization failure information can be: Failed to obtain the geographic location, please reauthorize, or: Your geographic location has not been obtained, etc. This is only an exemplary description and is not limited to this.
[0089] Optionally, in a possible implementation, the authorization detection method provided by the present application can be used in multiple applications at the same time. Exemplarily, when the mini program is running in multiple target applications, each target application corresponding to the mini program is detected to see whether a usage description corresponding to the target authorization request is configured; if the usage description is detected in the first application, a target authorization request is initiated in the first application, and the first application is any one of the multiple target applications; if the usage description is not detected in the first application, a target authorization request is not initiated in the first application.
[0090] Exemplarily, the applet can be run in multiple target applications, which can be different or the same. When the applet is run in multiple target applications, each target application corresponding to the applet is respectively detected to see whether a usage description corresponding to the target authorization request is configured.
[0091] For example, the mini program runs in target application A, target application B, and target application C. It detects whether the target application A corresponding to the mini program is configured with the purpose description corresponding to the target authorization request, detects whether the target application B corresponding to the mini program is configured with the purpose description corresponding to the target authorization request, and detects whether the target application C corresponding to the mini program is configured with the purpose description corresponding to the target authorization request.
[0092] In the embodiment of the present application, the mini program does not initiate a target authorization request to its corresponding target application first, but first detects whether the target application is configured with a usage description corresponding to the target authorization request; if the usage description is detected, then the target authorization request is initiated to the target mini program; if the usage description is not detected, the target authorization request is not initiated to the target mini program. The specific method of detecting whether the target application is configured with a usage description corresponding to the target authorization request can be referred to the description in S101 to S103, which will not be repeated here.
[0093] The above method can effectively avoid the situation where the target application is not configured with the corresponding usage description, and the mini program initiates the target authorization request, which then causes the target application to crash. And this mini program detection authorization method effectively prevents the target application from crashing without modifying the target application code or deleting the permission application by the mini program, saving economic costs, being less prone to errors, ensuring the normal operation of the target application, and improving the user experience.
[0094] On the other hand, the mini program can apply for any type of authorization without worrying about the target application crashing. This is because no matter what type of authorization the mini program applies for, it is necessary to first detect whether the target application is configured with a usage description corresponding to that type of authorization request. Only when the corresponding usage description is detected will the mini program initiate the corresponding authorization request. When the corresponding usage description is not detected, in order to avoid the target application crashing, the mini program will not initiate the corresponding authorization request.
[0095] Optionally, in a possible implementation, the target authorization request that the mini program wants to initiate in each target application can be the same or different. For example, the first application can be target application A, target application B, and target application C. If the mini program wants to initiate a geolocation authorization request in target application A, it will detect whether the target application A corresponding to the mini program is configured with a usage description corresponding to the geolocation authorization request. If the mini program wants to initiate an album access authorization request in target application B, it will detect whether the target application B corresponding to the mini program is configured with a usage description corresponding to the album access authorization request. If the mini program wants to initiate a geolocation authorization request in target application C, it will detect whether the target application C corresponding to the mini program is configured with a usage description corresponding to the geolocation authorization request. This is only an exemplary description and is not limited to this.
[0096] The mini program will initiate the target authorization request in the target application in which it detects the usage description corresponding to the target authorization request. The mini program will not initiate the target authorization request in the target application in which it does not detect the usage description corresponding to the target authorization request.
[0097] For example, if the detection result is that the target application A is configured with a usage description corresponding to the geolocation authorization request, a geolocation authorization request is initiated in the target application A. If the detection result is that the target application B is configured with a usage description corresponding to the photo album authorization request, a photo album authorization request is initiated in the target application B. If the detection result is that the target application C is not configured with a usage description corresponding to the geolocation authorization request, a geolocation authorization request is not initiated in the target application C, which can effectively avoid the crash of the target application.
[0098] In this implementation, the applet can be run in multiple different or the same target applications at the same time, and the method used to detect authorization is the same. There is no need to make compatibility with different target applications, which saves development costs and improves applicability.
[0099] See also Figure 5 , Figure 5 is a schematic flow chart of a method for detecting authorization provided by another embodiment of the present invention. Optionally, in a possible implementation, Figure 5 The authorization detection method shown may include S201 to S206. S201 to S205 in this embodiment are similar to Figure 1 S101 to S105 in the corresponding embodiments are the same and will not be described in detail here. S206 will be described in detail as follows:
[0100] If the target application does not have a usage description corresponding to the target authorization request configured in the target application, S205 is executed after S203, and then S206 is executed after S205.
[0101] S206: Generate prompt information, where the prompt information is used to prompt the developer that the target application does not have the authority corresponding to the target authorization request.
[0102] When the judgment result is that the target application does not have the usage description corresponding to the target authorization request configured in the target application, it means that the target application has not obtained the permission corresponding to the target authorization request from the terminal system in advance, and the applet does not initiate the target authorization request to the target application. At this time, a prompt message can be generated. The prompt message is used to prompt the developer that the target application does not have the permission corresponding to the target authorization request. The prompt message can be sent to the developer through the terminal, or it can be directly displayed on the display interface. This is only an exemplary description and is not limited to this.
[0103] Although this is equivalent to the authorization failure of the mini program, the authorization failure here is different from the authorization failure in S1043. The authorization failure in S1043 is that the target application has obtained the permission corresponding to the target authorization request from the terminal system in advance, and the user is unwilling to grant the mini program the permission corresponding to the target authorization request, resulting in the authorization failure. The authorization failure in S206 is caused by the target application not obtaining the permission corresponding to the target authorization request from the terminal system in advance. The authorization failure in S1043 can usually only be resolved by initiating the target authorization request again and waiting for the user to agree to the authorization. The authorization failure in S206 can prompt the developer that the target application does not have the permission corresponding to the target authorization request after the prompt information is generated. The developer can modify the code to enable the target application to obtain the permission corresponding to the target authorization request from the terminal system.
[0104] The prompt information in the embodiment of the present application can intuitively show the developer the reason for the authorization failure, which is convenient for the developer to promptly fix the problems in the target application and improve the user experience.
[0105] See also Figure 6 , Figure 6 Schematic diagram of a device for detecting authorization provided in an embodiment of the present application. The device includes units for executing Figure 1 , Figure 2 , Figure 3 , Figure 5 For details, please refer to the steps in the corresponding embodiment. Figure 1 , Figure 2 , Figure 3 , Figure 5 For the convenience of explanation, only the parts related to this embodiment are shown. Figure 6 ,include:
[0106] A first acquisition unit 310 is used to acquire first description information corresponding to a target authorization request in a target application corresponding to the mini program based on a first preset character string;
[0107] A second acquisition unit 320 is used to acquire, in the target application, second description information corresponding to the target authorization request based on a second preset character string;
[0108] A judging unit 330 is configured to judge whether a usage description corresponding to the target authorization request is configured in the target application based on the first description information and the second description information, and the first description information and the second description information both correspond to the usage description;
[0109] The first processing unit 340 is configured to initiate the target authorization request if the determination result is that the target application is configured with the usage description;
[0110] The second processing unit 350 is configured to not initiate the target authorization request if the judgment result is that the usage description is not configured in the target application.
[0111] Optionally, the judging unit 330 is specifically configured to:
[0112] Detecting whether the first description information is consistent with the second description information;
[0113] When it is detected that the first description information is inconsistent with the second description information, the judgment result is that the usage description is configured in the target application; or,
[0114] When it is detected that the first description information is completely consistent with the second description information, the judgment result is that the usage description is not configured in the target application.
[0115] Optionally, the device further comprises:
[0116] A third processing unit is used to detect whether a usage description corresponding to a target authorization request is configured in each target application corresponding to the mini program when the mini program is running in multiple target applications;
[0117] a fourth processing unit, configured to initiate a target authorization request in a first application if the usage description is detected in the first application, the first application being any one of the multiple target applications;
[0118] The fifth processing unit is configured to not initiate a target authorization request in the first application if the usage description is not detected in the first application.
[0119] Optionally, the first preset character string includes a key character string, and the second preset character string includes a value character string.
[0120] Optionally, the first processing unit 340 is specifically configured to:
[0121] If the result of the judgment is that the target application has the usage description configured, a pop-up window consultation is initiated on the display interface of the mini-program, and the pop-up window consultation is used to consult the user whether to agree to the target authorization request;
[0122] When the user agrees to the target authorization request, granting the mini program the permission corresponding to the target authorization request; or,
[0123] When the user does not agree to the target authorization request, an authorization failure message is generated.
[0124] Optionally, the device further comprises:
[0125] The information generating unit is used to generate prompt information, wherein the prompt information is used to prompt the developer that the target application does not have the authority corresponding to the target authorization request.
[0126] See also Figure 7 , Figure 7 FIG. 1 is a schematic diagram of a terminal for detecting authorization provided by another embodiment of the present application. Figure 7 As shown, the authorization detection terminal 4 of this embodiment includes: a processor 40, a memory 41, and a computer instruction 42 stored in the memory 41 and executable on the processor 40. When the processor 40 executes the computer instruction 42, the steps in the above-mentioned authorization detection method embodiments are implemented, for example Figure 1 Alternatively, when the processor 40 executes the computer instruction 42, the functions of each unit in the above embodiments are realized, for example, Figure 6 The functions of units 310 to 350 are shown.
[0127] Exemplarily, the computer instruction 42 can be divided into one or more units, and the one or more units are stored in the memory 41 and executed by the processor 40 to complete the present application. The one or more units can be a series of computer instruction segments that can complete specific functions, and the instruction segments are used to describe the execution process of the computer instruction 42 in the terminal 4 for detecting authorization. For example, the computer instruction 42 can be divided into a first acquisition unit, a second acquisition unit, a judgment unit, a first processing unit, and a second processing unit, and the specific functions of each unit are as described above.
[0128] The terminal for detecting authorization may include, but is not limited to, a processor 40 and a memory 41. Those skilled in the art will appreciate that Figure 7 It is only an example of the authorization detection terminal 4 and does not constitute a limitation on the authorization detection terminal. It may include more or fewer components than shown in the figure, or a combination of certain components, or different components. For example, the authorization detection terminal may also include input and output terminals, network access terminals, buses, etc.
[0129] The processor 40 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor, etc.
[0130] The memory 41 can be an internal storage unit of the terminal for the detection authorization, such as a hard disk or a memory of the terminal for the detection authorization. The memory 41 can also be an external storage terminal of the terminal for the detection authorization, such as a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card) etc. equipped on the terminal for the detection authorization. Further, the memory 41 can also include both an internal storage unit of the terminal for the detection authorization and an external storage terminal. The memory 41 is used to store the computer instructions and other programs and data required by the terminal. The memory 41 can also be used to temporarily store data that has been output or is about to be output.
[0131] The embodiments described above are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, a person skilled in the art should understand that the technical solutions described in the aforementioned embodiments can still be modified, or some of the technical features can be replaced by equivalents. These modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit of the technical solutions of the embodiments of the present application, and should all be included in the protection scope of the present application.
Claims
1. A method for detecting authorization, characterized in that: include: Pre-writing the usage description information corresponding to the target authorization request into a preset document corresponding to the target application program through a first preset character string; The first preset character string includes a key character string; Based on the first preset character string, in the target application corresponding to the mini program, obtain first description information corresponding to the target authorization request; The first description information is usage description information corresponding to the target authorization request pre-written in the preset document; The usage description information includes identification information corresponding to the target authorization request, or identification information and specific description information corresponding to the target authorization request; Based on a second preset string, in the target application, obtaining second description information corresponding to the target authorization request; the second preset string includes a value string; The second preset character string is used to read the usage description information corresponding to the target authorization request in the preset document; Based on the first description information and the second description information, determining whether the target application is configured with a usage description corresponding to the target authorization request, the first description information and the second description information both corresponding to the usage description; If the result of the determination is that the target application has the usage description configured therein, then initiating the target authorization request; or, If the judgment result is that the usage description is not configured in the target application, the target authorization request is not initiated.
2. The method according to claim 1, characterized in that The determining, based on the first description information and the second description information, whether the target application is configured with a usage description corresponding to the target authorization request includes: Detecting whether the first description information is consistent with the second description information; When it is detected that the first description information is inconsistent with the second description information, the judgment result is that the usage description is configured in the target application; or, When it is detected that the first description information is completely consistent with the second description information, the judgment result is that the usage description is not configured in the target application.
3. The method according to any one of claims 1 or 2, characterized in that The method further comprises: When the mini program is running in multiple target applications, detecting whether each target application corresponding to the mini program is configured with a usage description corresponding to the target authorization request; If the usage description is detected in a first application, a target authorization request is initiated in the first application, the first application being any one of the multiple target applications; If the usage description is not detected in the first application, a target authorization request is not initiated in the first application.
4. The method according to claim 1, characterized in that If the result of the determination is that the target application has the usage description configured therein, initiating the target authorization request includes: If the result of the judgment is that the target application has the usage description configured, a pop-up window consultation is initiated on the display interface of the mini-program, and the pop-up window consultation is used to consult the user whether to agree to the target authorization request; When the user agrees to the target authorization request, granting the mini program the permission corresponding to the target authorization request; or, When the user does not agree to the target authorization request, authorization failure information is generated.
5. The method according to claim 1, characterized in that If the result of the determination is that the usage description is not configured in the target application, then after not initiating the target authorization request, the method further includes: Prompt information is generated, where the prompt information is used to prompt the developer that the target application does not have the authority corresponding to the target authorization request.
6. A device for detecting authorization, characterized in that: include: A first acquisition unit, configured to pre-write the usage description information corresponding to the target authorization request into a preset document corresponding to the target application program through a first preset character string; The first preset character string includes a key character string; Based on the first preset character string, in the target application corresponding to the mini program, obtain first description information corresponding to the target authorization request; The first description information is usage description information corresponding to the target authorization request pre-written in the preset document; The usage description information includes identification information corresponding to the target authorization request, or identification information and specific description information corresponding to the target authorization request; A second acquisition unit is used to acquire, in the target application, second description information corresponding to the target authorization request based on a second preset character string; the second preset character string includes a value character string; The second preset character string is used to read the usage description information corresponding to the target authorization request in the preset document; A judging unit, configured to judge whether a usage description corresponding to the target authorization request is configured in the target application based on the first description information and the second description information, wherein both the first description information and the second description information correspond to the usage description; A first processing unit, configured to initiate the target authorization request if a judgment result shows that the usage description is configured in the target application; The second processing unit is configured to not initiate the target authorization request if the judgment result is that the usage description is not configured in the target application.
7. The device according to claim 6, characterized in that The judging unit is specifically used for: Detecting whether the first description information is consistent with the second description information; When it is detected that the first description information is inconsistent with the second description information, the judgment result is that the usage description is configured in the target application; or, When it is detected that the first description information is completely consistent with the second description information, the judgment result is that the usage description is not configured in the target application.
8. A terminal for detecting authorization, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the method according to any one of claims 1 to 5 is implemented.
9. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 5 is implemented.
