LocalStorage data exception deletion protection method based on iOS APP end

By implementing data classification backup and real-time monitoring and recovery mechanisms on the iOS APP, the problem of the iOS system automatically clearing LocalStorage data is solved, improving the stability and user experience of the application, and reducing the cost of transformation.

CN118535389AActive Publication Date: 2024-08-23SUZHOU RUIYUN ZHIFU INFORMATION TECH CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202410993803.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-24
Publication Date
2024-08-23
Estimated Expiration
2044-07-24

AI Technical Summary

Technical Problem

The iOS system may automatically clear LocalStorage data after an update, affecting application stability and user experience. Existing technology modifications are costly and complex, and lack effective protection methods.

Method used

By obtaining the native local storage attribute value of the iOS APP, the backup data is classified, and simulated local storage and proxy local storage are used to realize real-time monitoring and recovery of data to avoid data loss and application failures.

Benefits of technology

It realizes instant backup and recovery of LocalStorage data, improves user experience and application reliability, reduces data loss and business interruption time, and reduces maintenance costs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118535389A
    Figure CN118535389A
Patent Text Reader

Abstract

The invention discloses a LocalStorage data exception deletion protection method based on an iOS APP end, and the method comprises the steps: obtaining the attribute value of the original local storage of the user iOS APP end, and classifying the data of the original local storage; creating three variable objects of original local storage, simulation local storage and proxy local storage, and backing up the classified data of the original local storage; monitoring the state of the original locally stored data in real time, comparing the original locally stored data with the data stored in the data backup module, and entering detection and judgment of an abnormal protection process; and after it is detected that the data of the original local storage is abnormally deleted, entering data recovery of an exception protection process, extracting a corresponding data object from the backup module, and recovering the data object to the original local storage through the data recovery module. According to the invention, data classification is carried out on Local Storage data, and the data backup module, the data detection module and the data recovery module are combined to carry out data monitoring and recovery.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of electronic digital data processing, and in particular to the technical field of a data conversion method without changing the number of bits or content of processed data, and specifically to a LocalStorage data abnormal deletion protection method based on an iOS APP. Background Art

[0002] LocalStorage is a type of web storage that allows web applications to store data in the user's browser. LocalStorage data is stored in key-value pairs, supports string format, and can be read and written through JavaScript. In mobile application APP development, LocalStorage is often used for client-side data storage. In addition, LocalStorage allows users to continue to use APP functions without a network connection in offline applications.

[0003] In some new versions of iOS, LocalStorage data may be abnormally cleared under certain circumstances. This usually happens after the iOS operating system is updated, especially when the device's storage space is almost exhausted, the iOS system may automatically clear LocalStorage data to reclaim storage space. Although this automatic optimization behavior is intended to improve device performance, it has an adverse impact on the stability of the application and the user experience.

[0004] For the abnormal deletion of LocalStorage data on the iOS APP side, in the existing technology, IndexedDB is used to replace or serve as the backup storage of LocalStorage. The disadvantage is that the existing storage method needs to be changed, and the original project needs to be completely and thoroughly transformed. It is also more likely to have transformation omissions or new problems. The disadvantage of using data synchronization and cloud storage is that an additional interface request connection with the server needs to be added, and other storage media such as servers, databases and cloud storage need to be deployed additionally, which increases development and maintenance costs.

[0005] Therefore, it is necessary to improve the LocalStorage data abnormal deletion protection method based on iOS APP in the prior art to solve the above problems. Summary of the invention

[0006] The present invention overcomes the shortcomings of the prior art and provides a method for protecting LocalStorage data from abnormal deletion based on the iOS APP side, aiming to solve the problem in the prior art that the original storage method needs to be changed or the external cost needs to be increased to realize the protection of LocalStorage data from abnormal deletion on the iOS APP side.

[0007] To achieve the above object, the technical solution adopted by the present invention is: a method for preventing abnormal deletion of LocalStorage data based on iOS APP, comprising the following steps: S1. Obtain the attribute values ​​of the native local storage of the user's iOS APP and classify the data in the native local storage; S2, create three variable objects: original local storage, simulated local storage, and proxy local storage, and back up the classified data of the original local storage; S3, real-time monitoring of the data status of the original local storage, comparison of the data stored in the original local storage with the data stored in the data backup module, and entering the detection and judgment of the abnormal protection process; S4: After detecting abnormal deletion of the original local stored data, enter the data recovery of the abnormal protection process, extract the corresponding data object from the backup module, and restore it to the original local storage through the data recovery module. In a preferred embodiment of the present invention, in step S1, the native locally stored data is classified according to the data usage, including: user-related data, application status and session data, performance and optimization data, development and operation and maintenance data; wherein the user-related data includes: user preference settings, user authentication information and multi-language support; the application status and session data includes: session information and application status; the performance and optimization data includes: cache data and temporary data storage; the development and operation and maintenance data includes: personalized content, error reporting and logging, and extended data.

[0008] In a preferred embodiment of the present invention, in step S2, S21. Create an original local storage object and reference the native local storage object; S22. Create a simulated local storage object, simulate the method of native local storage, and store the data of native local storage; S23. Create a proxy local storage object to simulate native local storage and obtain the attribute value by directly calling the attribute name.

[0009] In a preferred embodiment of the present invention, in step S22, the method of simulating native local storage includes: (1) Data acquisition method: compare the attribute values ​​in the original local storage and the simulated local storage, and restore the data based on the comparison results; (2) Data setting method: Store the data in the simulated local storage in the form of key-value pairs, ensure synchronization with the original local storage data, and trigger the data backup in step S2; (3) Data removal method: removes the specified attribute value data from the original local storage and simulated local storage, and triggers the data backup in step S2; (4) Data clearing method: Clear all data in the original local storage and simulated local storage to ensure complete deletion of the data and trigger the data backup in step S2.

[0010] In a preferred embodiment of the present invention, in step S23, the proxy local storage object can be linked with the simulated local storage by hijacking the proxy acquisition and proxy assignment of attributes: (1) Proxy acquisition: When the key value of the proxy object attribute stored locally is read, the proxy acquisition is triggered to determine whether the key value is a predefined attribute; when the key value is a predefined attribute, the attribute value of the simulated local storage is directly returned; when the key value is not a predefined attribute, the return value of the getItem method of the simulated local storage is returned; (2) Proxy assignment: When the key value of the proxy object attribute of the proxy local storage is assigned, the proxy assignment is triggered to determine whether the key value is a predefined attribute; when the key value is a predefined attribute, the attribute of the simulated local storage is assigned to the corresponding value; when the key value is not a predefined attribute, the setItem method of the simulated local storage is called to modify the attribute value of the simulated local storage.

[0011] In a preferred embodiment of the present invention, in step S3, the detection and determination of the abnormal protection process is as follows: S31. When the native local storage data is deleted abnormally, the original local storage attribute value is cleared; S32, when executing the function of reading the specified attribute from the native local storage, triggering the proxy acquisition method of the proxy local storage to read the attribute value in the simulated local storage; S33, obtaining a specified attribute value by simulating a method for obtaining data in local storage, and detecting an attribute value with the same name in the original local storage; S34: When the simulated local storage attribute value exists but the original local storage attribute value does not exist, it is determined that the native local storage is abnormally deleted.

[0012] In a preferred embodiment of the present invention, in step S4, data recovery of the abnormal protection process is as follows: S41, reassigning the attribute value stored in the simulated local storage to the specified attribute of the original local storage to ensure that the values ​​of both are the same; S42. Return the locally stored specified attribute value.

[0013] In a preferred embodiment of the present invention, each time the simulated local storage is changed, data backup is triggered by proxy operation of the proxy local storage.

[0014] In a preferred embodiment of the present invention, when the iOS APP is initialized, the original local storage reads the backed-up attribute values ​​to restore the initial state.

[0015] The present invention provides a device, which includes an electronic device, and the electronic device includes a memory, a processor, and a computer program stored in the memory and running on the processor. It is characterized in that when the processor executes the computer program, the steps of the LocalStorage data abnormal deletion protection method based on the iOS APP end are implemented in any one of the above-mentioned items.

[0016] The present invention solves the defects existing in the background technology and has the following beneficial effects: (1) The present invention provides a method for protecting LocalStorage data from abnormal deletion based on an iOS APP. The method classifies the data in LocalStorage and optimizes the storage structure. The method combines a data backup module, a data detection module, and a data recovery module to perform real-time data monitoring and data recovery. This avoids data loss and application failure caused by abnormal deletion of LocalStorage data, and further improves user experience and application reliability.

[0017] (2) The present invention utilizes original local storage, simulated local storage and proxy local storage to achieve instant backup of native local storage data. Simulated local storage allows data backup without changing the original storage method. Proxy local storage eliminates the need for external devices to increase costs, ensuring data consistency and security, avoiding data loss caused by single point failures, and improving data recovery efficiency and accuracy.

[0018] (3) The present invention utilizes a combination of real-time monitoring and proxy mechanisms. The data monitoring module performs real-time comparison of original and simulated storage data and automatically recovers data under abnormal conditions, thereby achieving rapid detection and response to data anomalies, ensuring data integrity, and reducing business interruption time caused by data anomalies.

[0019] (4) The present invention utilizes the classified storage of LocalStorage data, such as user-related data and application status data, etc. Through different categories of data usage and storage methods, it makes it more convenient to maintain and update native local storage data. During the data backup and recovery process, classified storage can help ensure that only relevant data is operated, reducing the risk of data loss or errors, making data management more orderly and convenient for maintenance and updating, avoiding data management problems caused by chaotic data structure, and simplifying the data backup and recovery process. BRIEF DESCRIPTION OF THE DRAWINGS

[0020] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art are briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in the present invention. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative work. Figure 1 It is a modular design of a preferred embodiment of the present invention; Figure 2 It is a schematic diagram of an abnormal protection design method according to a preferred embodiment of the present invention; Figure 3 It is a method for obtaining data according to a preferred embodiment of the present invention; Figure 4 It is a method for setting data of a preferred embodiment of the present invention; Figure 5 It is a method for removing data according to a preferred embodiment of the present invention; Figure 6 It is a method for clearing data according to a preferred embodiment of the present invention; Figure 7 It is an implementation of the proxy acquisition method of the preferred embodiment of the present invention; Figure 8 It is the implementation of the proxy assignment method of the preferred embodiment of the present invention; Fig. 9 This is the abnormal protection process of the preferred embodiment of the present invention. DETAILED DESCRIPTION

[0021] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0022] In the following description, many specific details are set forth to facilitate a full understanding of the present invention, but the present invention may also be implemented in other ways different from those described herein. Therefore, the protection scope of the present invention is not limited to the specific embodiments disclosed below.

[0023] A method for preventing abnormal deletion of LocalStorage data based on an iOS APP includes the following steps: S1. Obtain the attribute values ​​of the native local storage of the user's iOS APP and classify the data in the native local storage; S2, create three variable objects: original local storage, simulated local storage, and proxy local storage, and back up the classified data of the original local storage; S3: Real-time monitoring of the data status of the original local storage, comparison of the data stored in the original local storage with the data stored in the data backup module, and detection and judgment of the abnormal protection process; S4. After detecting abnormal deletion of the original local stored data, enter the data recovery of the abnormal protection process, extract the corresponding data object from the backup module, and restore it to the original local storage through the data recovery module.

[0024] Specifically, the native local storage in the present invention is: LocalStorage, which is data storage without time limit. It is a technology for storing data in the browser or device of the user's iOS APP, allowing the web page to retain data after closing until it is explicitly cleared.

[0025] Specifically, in step S1, the data in the native local storage, i.e. LocalStorage, is classified according to the data usage, including: user-related data, application status and session data, performance and optimization data, and development and operation data. Among them, user-related data includes: user preferences, user authentication information, and multi-language support; application status and session data includes: session information and application status; performance and optimization data includes: cache data and temporary data storage; development and operation data includes: personalized content, error reporting and logging, and extended data.

[0026] Table 1 Local Storage data classification

[0027] After data is classified according to its purpose, the stored data structure can be better organized and understood, the purpose and storage method of each type of data can be understood, and it becomes easier to maintain and update native local storage data. During data backup and recovery, classification can help ensure that only relevant data is operated, reducing the risk of data loss or errors.

[0028] Specifically, in step S2: S21. Create an original local storage object and reference the native local storage object; S22. Create a simulated local storage object, simulate the method of native local storage, and store the data of native local storage; S23. Create a proxy local storage object to simulate native local storage and obtain the attribute value by directly calling the attribute name.

[0029] Specifically, in step S21, the original local storage in the present invention is rawLocalStorage, which is a variable used to store data of the native local storage, namely LocalStorage; The browser native local storage of the present invention is window.localStorage, and the native local storage object is copied and referenced, that is, the window.localStorage attribute value is assigned to the rawLocalStorage variable; Specifically, in step S22, the simulated local storage in the present invention is fakeLocalStorage, which is a variable used to simulate the method of native local storage, i.e. LocalStorage. At the same time, all variable values ​​stored in window.localStorage will also be saved in fakeLocalStorage to prevent abnormal deletion of data in native local storage, i.e. LocalStorage. In fakeLocalStorage, the methods that need to be defined include: getting data method, i.e. getItem; setting data method, i.e. setItem; removing data method, i.e. removeItem; clearing data method, i.e. clear method, and the functions of the methods should be enhanced.

[0030] (1) Data acquisition method: Compare the attribute values ​​in the original local storage and the simulated local storage, and recover the data based on the comparison results. If the data in the original local storage is found to be lost or inconsistent, the data can be recovered from the simulated local storage to ensure that the data is not lost.

[0031] like Figure 3 As shown, the specific steps are: where value refers to the specific information or data stored; a. Read the attribute value value1 in rawLocalStorage and the attribute value value2 in fakeLocalStorage, and compare the two; b. If value1 does not exist but value2 does, it means that the LocalStorage data in rawLocalStorage has been deleted abnormally. The data needs to be refilled and the attribute values ​​in fakeLocalStorage are assigned to the corresponding attributes in rawLocalStorage. c. If value1 exists, but value1 and value2 are not equal, it means that the value in fakeLocalStorage is abnormal. It is necessary to update the fakeLocalStorage data, assign the attribute value in rawLocalStorage to the corresponding attribute of fakeLocalStorage, and trigger the data backup logic of step S2; d. Return the current attribute value in rawLocalStorage as the return result.

[0032] (2) Data setting method: Store data in the simulated local storage in the form of key-value pairs, ensure synchronization with the original local storage data, and trigger the S2 step data backup. Prevent data inconsistency caused by unilateral updates, and save the latest data status to persistent storage to increase data security.

[0033] like Figure 4 As shown, the specific steps are: where key is the key value; a. Modify the value of the attribute key in rawLocalStorage to the passed value; b. Modify the value of the attribute key in fakeLocalStorage to value; c. Trigger the data backup logic of iOS APP in step S2.

[0034] (3) Data removal method: Remove the specified attribute value data from the original local storage and the simulated local storage, and trigger the data backup in step S2. Ensure that the data in rawLocalStorage and fakeLocalStorage are deleted synchronously to avoid data residue. Trigger the backup when deleting the data to ensure that even if the data is deleted, there is a backup to restore.

[0035] like Figure 5 As shown, the specific steps are: a. Remove the value of the attribute key in rawLocalStorage; b. Remove the value of the attribute key in fakeLocalStorage; c. Trigger the data backup logic of iOS APP in step S2.

[0036] (4) Data clearing method: Clear all data in the original local storage and simulated local storage to ensure complete deletion of the data, and trigger the data backup in step S2 to provide protection for possible data recovery.

[0037] like Figure 6 As shown, the specific steps are: Clear all attribute values ​​in rawLocalStorage; b. Clear all attribute values ​​in fakeLocalStorage; c. Trigger the data backup logic of iOS APP in step S2.

[0038] By simulating the core methods of native local storage in simulated local storage and implementing data synchronization, anomaly detection, automatic recovery and backup mechanisms, an enhanced data storage strategy is provided. This approach not only ensures data integrity and consistency, reduces the risk of data loss due to native local storage LocalStorage anomalies, but also improves application stability and user experience by centrally managing data access and backup, while enhancing code maintainability and cross-platform compatibility.

[0039] By simulating the synchronization mechanism between the local storage and the original local storage, it is possible to ensure that the data of the two remain consistent. Data updates on either side will trigger corresponding updates on the other side, thus avoiding problems caused by unilateral data changes.

[0040] Specifically, in step S23, the proxy local storage in the present invention is proxyLocalStorage, which is a variable used to simulate the function of native local storage to obtain attribute values ​​by directly calling attribute names.

[0041] The proxyLocalStorage variable hijacks the property acquisition method and assignment method; the proxy acquisition method is the proxy get method, and the proxy assignment method is the proxy set method, which can be linked with the fakeLocalStorage variable.

[0042] like Figure 7 and Figure 8 As shown, Use the proxy algorithm, i.e. Proxy, to create proxy local storage objects; Proxy encapsulates access to LocalStorage, making the code neater and the logic clearer. Proxy allows for customized processing of access to LocalStorage.

[0043] (1) Proxy acquisition: When the key value of the proxy object attribute in the proxy local storage is read, the proxy acquisition is triggered to determine whether the key value is a predefined attribute. If the key value is a predefined attribute, the attribute value of fakeLocalStorage[key] is directly returned. If the key value is not a predefined attribute, the return value of the data acquisition method of the simulated local storage is returned.

[0044] (2) Proxy assignment: When the proxy object attribute key value of the proxy local storage is assigned, the proxy assignment is triggered to determine whether the key value is a predefined attribute. If the key value is a predefined attribute, the attribute of the simulated local storage is assigned to the corresponding value. If the key value is not a predefined attribute, the set data method of the simulated local storage is called to modify the attribute value of the simulated local storage.

[0045] Among them, the key value is key, and the predefined attributes include: get data method, set data method, remove data method, and clear data method.

[0046] Through the proxy mechanism of proxyLocalStorage, anomaly detection can be performed when accessing or modifying LocalStorage data. When data inconsistency or abnormal deletion is detected, measures can be taken immediately, such as restoring data from fakeLocalStorage to rawLocalStorage.

[0047] The proxyLocalStorage created using a proxy provides an intermediate layer so that all access to LocalStorage can be monitored and controlled. This not only enhances the modularity of the code, but also makes it easier to modify the data access logic in the future. At the same time, this approach improves the security and flexibility of data operations, allowing developers to implement more complex data processing logic without directly operating LocalStorage.

[0048] The three key variables rawLocalStorage, fakeLocalStorage, and proxyLocalStorage are created and defined; by giving them specific functions and roles, a safer and more reliable data storage mechanism is implemented. RawLocalStorage, as a backup of the original data, ensures data security; fakeLocalStorage, by simulating the LocalStorage method, provides data access flexibility and the ability to recover from exceptions, while ensuring data consistency through a synchronization mechanism; and proxyLocalStorage, by using the proxy mode, enhances control over data access, implements exception detection and instant recovery, and improves the modularity and maintainability of the code. Overall, the stability and reliability of the data are improved, and by centrally managing data access, the development process is simplified, and the user experience and cross-platform compatibility of the application are enhanced.

[0049] Specifically, Fig. 9 As shown, in step S3 and step S4, the abnormal protection process is as follows: Specifically, in step S3, when calling the properties or methods in the native local storage, it is necessary to compare the property values ​​of the simulated local storage and the original local storage to determine whether an abnormality occurs; when the simulated local storage property value exists, but the original local storage property value does not exist, it indicates that the native local storage has been abnormally deleted, and the data recovery module function is triggered to assign the property value of the simulated local storage to the original local storage.

[0050] Specifically, in step S3, the detection and determination of the abnormal protection process is entered: S31. When the native local storage LocalStorage data of iOS APP is abnormally deleted, the original local storage rawLocalStorage attribute value will be cleared; S32, when the program executes the function of reading the specified attribute of the native local storage localStorage, the proxy acquisition method of the proxy local storage proxyLocalStorage is triggered to read the attribute value in the simulated local storage fakeLocalStorage; S33, while obtaining the specified attribute value by simulating the data acquisition method of the local storage fakeLocalStorage, the attribute value with the same name in the original local storage rawLocalStorage is detected at the same time; S34. When the fakeLocalStorage attribute value of the simulated local storage exists, but the rawLocalStorage attribute value of the original local storage does not exist, it can be considered that an abnormality of the iOS APP has occurred; Specifically, in step S4, data recovery of the abnormal protection process is performed: S41, reassigning the attribute value stored in the simulated local storage fakeLocalStorage to the specified attribute of the original local storage rawLocalStorage to ensure that the values ​​of both are the same; S42. Return the specified attribute value of the local storage rawLocalStorage to allow the program to run normally.

[0051] Every time fakeLocalStorage changes, whether by calling its methods directly or through proxyLocalStorage, the logic of backing up the data to the iOS APP backend should be triggered.

[0052] When the iOS app is initialized, rawLocalStorage reads the backed-up property values ​​to restore the initial state.

[0053] When abnormal data deletion is detected, it can respond quickly, reduce the time to solve the problem, and restore data from fakeLocalStorage to rawLocalStorage to reduce data loss. Through the abnormal detection and recovery mechanism, the stability of the application in the face of LocalStorage problems is improved. Reduce application failures caused by data loss or abnormalities and improve user satisfaction.

[0054] Through steps S3 and S4, a complete set of abnormal protection processes is formed, which can quickly detect and restore data when abnormal deletion of LocalStorage data occurs, thereby protecting the application from data loss. This method not only improves the security and reliability of data, but also ensures the continuous operation of the application and user experience through instant data recovery. In addition, centralized handling of abnormal situations also simplifies the error handling process, making the application more robust and easy to maintain.

[0055] The above is based on the ideal embodiment of the present invention. Through the above description, relevant personnel can make various changes and modifications without departing from the technical concept of the present invention. The technical scope of the present invention is not limited to the content in the specification, and the technical scope must be determined according to the scope of the claims.

Claims

1. A method for preventing abnormal deletion of LocalStorage data based on iOS APP, characterized in that: The following steps are involved: S1. Obtain the attribute values ​​of the native local storage of the user's iOS APP and classify the data in the native local storage; S2, create three variable objects: original local storage, simulated local storage, and proxy local storage, and back up the classified data of the original local storage; S3: Real-time monitoring of the data status of the original local storage, comparison of the data stored in the original local storage with the data stored in the data backup module, and detection and judgment of the abnormal protection process; S4. After detecting abnormal deletion of the original local stored data, enter the data recovery of the abnormal protection process, extract the corresponding data object from the backup module, and restore it to the original local storage through the data recovery module.

2. The method for preventing abnormal deletion of LocalStorage data based on iOS APP according to claim 1, characterized in that: In step S1, the native locally stored data is classified according to the data usage, including: user-related data, application status and session data, performance and optimization data, development and operation and maintenance data; among which, user-related data includes: user preference settings, user authentication information and multi-language support; application status and session data includes: session information and application status; performance and optimization data includes: cache data and temporary data storage; development and operation and maintenance data includes: personalized content, error reporting and logging, and extended data.

3. The method for preventing abnormal deletion of LocalStorage data based on iOS APP according to claim 1 is characterized in that: In step S2, S21. Create an original local storage object and reference the native local storage object; S22. Create a simulated local storage object, simulate the method of native local storage, and store the data of native local storage; S23. Create a proxy local storage object to simulate native local storage and obtain the attribute value by directly calling the attribute name.

4. The method for preventing abnormal deletion of LocalStorage data based on iOS APP according to claim 3 is characterized in that: In step S22, the method of simulating native local storage includes: (1) Data acquisition method: compare the attribute values ​​in the original local storage and the simulated local storage, and restore the data based on the comparison results; (2) Data setting method: Store the data in the simulated local storage in the form of key-value pairs, ensure synchronization with the original local storage data, and trigger the data backup in step S2; (3) Data removal method: removes the specified attribute value data from the original local storage and simulated local storage, and triggers the data backup in step S2; (4) Data clearing method: Clear all data in the original local storage and simulated local storage to ensure complete deletion of the data and trigger the data backup in step S2.

5. The method for preventing abnormal deletion of LocalStorage data based on iOS APP according to claim 4 is characterized in that: In step S23, the proxy local storage object is linked with the simulated local storage by proxy acquisition and proxy assignment of hijacked attributes: (1) Proxy acquisition: When the key value of the proxy object attribute stored locally is read, the proxy acquisition is triggered to determine whether the key value is a predefined attribute; when the key value is a predefined attribute, the attribute value of the simulated local storage is directly returned; when the key value is not a predefined attribute, the return value of the getItem method of the simulated local storage is returned; (2) Proxy assignment: When the key value of the proxy object attribute of the proxy local storage is assigned, the proxy assignment is triggered to determine whether the key value is a predefined attribute; when the key value is a predefined attribute, the attribute of the simulated local storage is assigned to the corresponding value; when the key value is not a predefined attribute, the setItem method of the simulated local storage is called to modify the attribute value of the simulated local storage.

6. The method for preventing abnormal deletion of LocalStorage data based on iOS APP according to claim 3 is characterized in that: In step S3, the detection and determination of the abnormal protection process is as follows: S31. When the native local storage data is deleted abnormally, the original local storage attribute value is cleared; S32, when executing the function of reading the specified attribute from the native local storage, triggering the proxy acquisition method of the proxy local storage to read the attribute value in the simulated local storage; S33, obtaining a specified attribute value by simulating a method for obtaining data in local storage, and detecting an attribute value with the same name in the original local storage; S34: When the simulated local storage attribute value exists but the original local storage attribute value does not exist, it is determined that the native local storage is abnormally deleted.

7. The method for preventing abnormal deletion of LocalStorage data based on iOS APP according to claim 1 is characterized in that: In step S4, the data recovery of the abnormal protection process is as follows: S41, reassigning the attribute value stored in the simulated local storage to the specified attribute of the original local storage to ensure that the values ​​of both are the same; S42. Return the locally stored specified attribute value.

8. The method for preventing abnormal deletion of LocalStorage data based on iOS APP according to claim 1 is characterized in that: Every time a change occurs in the simulated local storage, a data backup is triggered by proxy operations on the proxy local storage.

9. The method for preventing abnormal deletion of LocalStorage data based on iOS APP according to claim 1, characterized in that: When the iOS app is initialized, the original local storage reads the backed-up attribute values ​​to restore the initial state.

10. A device, comprising an electronic device, wherein the electronic device comprises a memory, a processor, and a computer program stored in the memory and running on the processor, wherein: When the processor executes the computer program, the steps of the method for preventing abnormal deletion of LocalStorage data based on the iOS APP are implemented as described in any one of claims 1 to 9.

Citation Information

Patent Citations

  • Web front-end data local-storage and access method for based on local Storage

    CN107329910A

  • Method and device for performing data operation at client

    CN110162412A

  • Disaster recovery method and device based on kubernetes container platform

    CN111966467A