A method for preventing abnormal deletion of LocalStorage data based on iOS APP
By performing classified backup and real-time monitoring of LocalStorage data on the iOS APP, and using simulation and proxy storage mechanisms to achieve data recovery, it solves the problem of the iOS system automatically clearing LocalStorage data and improves data security and user experience.
Patent Information
- Application Number
- CN202410993803.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-24
- Publication Date
- 2024-10-11
- Estimated Expiration
- 2044-07-24
AI Technical Summary
The iOS system may automatically clear LocalStorage data after an update, resulting in abnormal deletion of data. Existing technologies require changing the storage method or increasing external costs to solve this problem.
By obtaining the native local storage attribute value of the user's 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.
It achieves instant backup and recovery of LocalStorage data, improves user experience and application reliability, reduces data loss and application failures, and reduces development costs.
Smart Images

Figure CN118535389B_ABST
Abstract
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 the processed data, specifically a method for protecting LocalStorage data from abnormal deletion 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 formatting, and can be read and written via JavaScript. In mobile app development, LocalStorage is often used for client-side data storage. Furthermore, in offline apps, LocalStorage allows users to continue using app functionality even without an internet connection.
[0003] In some recent versions of iOS, LocalStorage data may be unexpectedly cleared under certain circumstances. This typically occurs after an iOS operating system update, especially when the device's storage space is nearly exhausted. iOS may automatically clear LocalStorage data to reclaim storage space. While this automatic optimization is intended to improve device performance, it can negatively impact application stability and the user experience.
[0004] For the abnormal deletion of LocalStorage data on the iOS app side, the existing technology uses IndexedDB to replace or serve as the backup storage of LocalStorage. The disadvantage is that it requires changing the existing storage method and a comprehensive and thorough transformation of the original project, which is also more likely to cause transformation omissions or new problems. The disadvantage of using data synchronization and cloud storage is that it requires adding additional interface request connections with the server, and requires additional deployment of servers, databases, cloud storage and other storage media, which increases development and maintenance costs.
[0005] Therefore, it is necessary to improve the existing method for preventing abnormal deletion of LocalStorage data based on iOS APP to solve the above problems. Summary of the Invention
[0006] The present invention overcomes the shortcomings of the existing technology and provides a method for protecting LocalStorage data from abnormal deletion based on the iOS APP side, aiming to solve the problem in the existing technology that it is necessary to change the original storage method or increase external costs to achieve abnormal deletion protection of LocalStorage data on the iOS APP side.
[0007] To achieve the above objectives, the present invention adopts a technical solution: a method for preventing abnormal deletion of LocalStorage data based on the iOS APP, comprising the following steps:
[0008] 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;
[0009] S2. Create three variable objects: original local storage, simulated local storage, and proxy local storage, and back up the classified data in the original local storage.
[0010] S3: Real-time monitoring of the data status of the original local storage, comparison of the original local storage data with the data stored in the data backup module, and the detection and judgment of the abnormal protection process;
[0011] S4: After detecting abnormal deletion of the original local stored data, enter the data recovery process 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.
[0012] 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; among which, 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: cached data and temporary data storage; development and operation and maintenance data includes: personalized content, error reporting and logging, and extended data.
[0013] In a preferred embodiment of the present invention, in step S2,
[0014] S21. Create an original local storage object and reference the native local storage object;
[0015] S22. Create a simulated local storage object, simulate the native local storage method, and store the native local storage data;
[0016] S23. Create a proxy local storage object to simulate native local storage and obtain the attribute value by directly calling the attribute name.
[0017] In a preferred embodiment of the present invention, in step S22, the method of simulating native local storage includes:
[0018] (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;
[0019] (2) Data setup 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 data backup in step S2;
[0020] (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;
[0021] (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.
[0022] 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:
[0023] (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; if the key value is a predefined attribute, the attribute value of the simulated local storage is directly returned; if the key value is not a predefined attribute, the return value of the getItem method of the simulated local storage is returned;
[0024] (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.
[0025] In a preferred embodiment of the present invention, in step S3, the detection and determination of the abnormal protection process are as follows:
[0026] S31. When native local storage data is abnormally deleted, the original local storage attribute value is cleared;
[0027] S32. When executing the function of reading the specified attribute from the native local storage, trigger the proxy acquisition method of the proxy local storage to read the attribute value in the simulated local storage;
[0028] S33. Acquire a specified attribute value by simulating a local storage data acquisition method, and detect attribute values with the same name in the original local storage;
[0029] 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.
[0030] In a preferred embodiment of the present invention, in step S4, data recovery of the abnormal protection process is as follows:
[0031] S41. Reassign 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;
[0032] S42. Return the locally stored specified attribute value.
[0033] In a preferred embodiment of the present invention, each time a change occurs in the simulated local storage, a data backup is triggered by a proxy operation that acts as a proxy for the local storage.
[0034] 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.
[0035] 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, it implements the steps of any one of the above-mentioned methods for protecting LocalStorage data from abnormal deletion based on the iOS APP side.
[0036] The present invention solves the defects existing in the background technology and has the following beneficial effects:
[0037] (1) The present invention provides a method for protecting LocalStorage data from abnormal deletion based on the iOS APP. By classifying the data in LocalStorage and optimizing the storage structure, the present invention combines a data backup module, a data detection module, and a data recovery module to perform real-time data monitoring and data recovery, thereby avoiding data loss and application failure caused by abnormal deletion of LocalStorage data, and further improving user experience and application reliability.
[0038] (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 to remain unchanged 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.
[0039] (3) The present invention utilizes the combination of real-time monitoring and proxy mechanism. The data monitoring module compares the original and simulated storage data in real time and automatically recovers in abnormal situations, which enables rapid detection and response to data anomalies, ensures data integrity, and reduces business interruption time caused by data anomalies.
[0040] (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, 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
[0041] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are only some embodiments described in the present invention. Those skilled in the art can also derive other drawings based on these drawings without inventive efforts.
[0042] Figure 1 It is a modular design of a preferred embodiment of the present invention;
[0043] Figure 2 This is a diagram of the architecture of the abnormality protection design method according to the preferred embodiment of the present invention;
[0044] Figure 3 It is a method for obtaining data according to a preferred embodiment of the present invention;
[0045] Figure 4 It is a method for setting data according to a preferred embodiment of the present invention;
[0046] Figure 5 It is a method for removing data according to a preferred embodiment of the present invention;
[0047] Figure 6 It is a method for clearing data according to a preferred embodiment of the present invention;
[0048] Figure 7 It is an implementation of the proxy acquisition method of the preferred embodiment of the present invention;
[0049] Figure 8 It is the implementation of the proxy assignment method of the preferred embodiment of the present invention;
[0050] Figure 9This is the abnormal protection process of the preferred embodiment of the present invention. DETAILED DESCRIPTION
[0051] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. 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 making creative efforts are within the scope of protection of the present invention.
[0052] In the following description, many specific details are set forth to facilitate a full understanding of the present invention. However, the present invention may also be implemented in other ways different from those described herein. Therefore, the scope of protection of the present invention is not limited to the specific embodiments disclosed below.
[0053] A method for preventing abnormal deletion of LocalStorage data based on an iOS app includes the following steps:
[0054] 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;
[0055] S2. Create three variable objects: original local storage, simulated local storage, and proxy local storage, and back up the classified data in the original local storage.
[0056] S3: Real-time monitoring of the data status of the original local storage, comparison of the original local storage data with the data stored in the data backup module, and the detection and judgment of the abnormal protection process;
[0057] 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.
[0058] 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.
[0059] Specifically, in step S1, the data in native local storage (LocalStorage) is categorized according to data usage, including: user-related data, application state and session data, performance and optimization data, and development and operation data. User-related data includes user preferences, user authentication information, and multi-language support; application state and session data includes session information and application state; performance and optimization data includes cached data and temporary data storage; and development and operation data includes personalized content, error reporting and logging, and extended data.
[0060] Table 1 Local Storage data classification
[0061]
[0062] 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 locally stored data. During the data backup and recovery process, classification can help ensure that only relevant data is operated, reducing the risk of data loss or errors.
[0063] Specifically, in step S2:
[0064] S21. Create an original local storage object and reference the native local storage object;
[0065] S22. Create a simulated local storage object, simulate the native local storage method, and store the native local storage data;
[0066] S23. Create a proxy local storage object to simulate native local storage and obtain the attribute value by directly calling the attribute name.
[0067] 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;
[0068] 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;
[0069] 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 are also saved in fakeLocalStorage to prevent abnormal deletion of data in native local storage, i.e., LocalStorage.
[0070] In fakeLocalStorage, the methods that need to be defined include: getItem for getting data, setItem for setting data, removeItem for removing data, and clear method for clearing data, and the functions of these methods should be enhanced.
[0071] (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 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.
[0072] like Figure 3 As shown, the specific steps are: where value refers to the specific information or data stored;
[0073] a. Read the attribute value value1 in rawLocalStorage and the attribute value value2 in fakeLocalStorage and compare them;
[0074] b. If value1 does not exist but value2 does, it means that the LocalStorage data in rawLocalStorage has been abnormally deleted. The data needs to be refilled and the attribute values in fakeLocalStorage are assigned to the corresponding attributes in rawLocalStorage.
[0075] c. If value1 exists, but value1 and value2 are not equal, it indicates that there is an anomaly in the value in fakeLocalStorage. You need to update the fakeLocalStorage data, assign the attribute value in rawLocalStorage to the corresponding attribute in fakeLocalStorage, and trigger the data backup logic in step S2.
[0076] d. Return the current attribute value in rawLocalStorage as the return result.
[0077] (2) Data setup method: Store data in the simulated local storage as key-value pairs, ensure synchronization with the original local storage data, and trigger the data backup in step S2. This prevents data inconsistencies caused by unilateral updates and saves the latest data status to persistent storage to increase data security.
[0078] like Figure 4 As shown, the specific steps are: where key is the key value;
[0079] a. Modify the value of the attribute key in rawLocalStorage to the passed value;
[0080] b. Modify the value of the attribute key in fakeLocalStorage to value;
[0081] c. Trigger the iOS app data backup logic in step S2.
[0082] (3) Data removal method: Removes the specified attribute value data from the original local storage and the simulated local storage, and triggers the data backup in step S2. Ensure that the data in rawLocalStorage and fakeLocalStorage are deleted synchronously to avoid data residue. Triggering a backup when deleting data ensures that even if the data is deleted, there is a backup to restore it.
[0083] like Figure 5 As shown, the specific steps are:
[0084] a. Remove the value of the attribute key in rawLocalStorage;
[0085] b. Remove the value of the attribute key in fakeLocalStorage;
[0086] c. Trigger the iOS app data backup logic in step S2.
[0087] (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.
[0088] like Figure 6 As shown, the specific steps are:
[0089] Clear all attribute values in rawLocalStorage;
[0090] b. Clear all attribute values in fakeLocalStorage;
[0091] c. Trigger the iOS app data backup logic in step S2.
[0092] By emulating the core methods of native local storage and implementing data synchronization, anomaly detection, automatic recovery, and backup mechanisms within simulated local storage, an enhanced data storage strategy is provided. This approach not only ensures data integrity and consistency, reducing the risk of data loss due to native 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.
[0093] By simulating the synchronization mechanism between local storage and original local storage, the data of the two can be kept consistent. Data updates on either side will trigger corresponding updates on the other side, thus avoiding problems caused by unilateral data changes.
[0094] 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.
[0095] The proxyLocalStorage variable hijacks the property's getter and assigner methods; the proxy getter is the proxy get method, and the proxy assigner is the proxy set method, which can interact with the fakeLocalStorage variable.
[0096] like Figure 7 and Figure 8 As shown,
[0097] Use the proxy algorithm, Proxy, to create a proxy local storage object. Proxy encapsulates access to LocalStorage, making the code neater and the logic clearer. Proxy allows for custom processing of access to LocalStorage.
[0098] (1) Proxy acquisition: When the key value of the proxy object attribute in the proxy local storage is read, the proxy acquisition is triggered and the key value is judged to be 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.
[0099] (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 value 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.
[0100] Among them, the key value is key, and the predefined properties include: get data method, set data method, remove data method, and clear data method.
[0101] The proxy mechanism of proxyLocalStorage allows for anomaly detection when accessing or modifying LocalStorage data. When data inconsistency or abnormal deletion is detected, immediate action can be taken, such as restoring data from fakeLocalStorage to rawLocalStorage.
[0102] ProxyLocalStorage created using a proxy provides an intermediary layer that allows all access to LocalStorage to be monitored and controlled. This not only enhances code modularity but also makes future modifications to data access logic easier. This approach also improves the security and flexibility of data operations, allowing developers to implement more complex data processing logic without directly manipulating LocalStorage.
[0103] Three key variables—rawLocalStorage, fakeLocalStorage, and proxyLocalStorage—are created and defined. By assigning them specific functions and roles, a more secure and reliable data storage mechanism is implemented. RawLocalStorage acts as a backup for original data, ensuring data security. FakeLocalStorage emulates LocalStorage methods, providing data access flexibility and exception recovery capabilities while ensuring data consistency through synchronization. ProxyLocalStorage utilizes a proxy model to enhance data access control, enabling exception detection and instant recovery, and improving code modularity and maintainability. Overall, this improves data stability and reliability. Centralized data access management simplifies the development process, enhancing the app's user experience and cross-platform compatibility.
[0104] Specifically, such as Figure 9 As shown, in step S3 and step S4, the abnormal protection process is as follows:
[0105] 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.
[0106] Specifically, in step S3, the detection and determination of the abnormal protection process is entered:
[0107] S31. When the native local storage LocalStorage data of iOS APP is abnormally deleted, the original local storage rawLocalStorage attribute value will be cleared;
[0108] S32. When executing the function of reading the specified attribute of the native local storage localStorage, the program triggers the proxy acquisition method of the proxy local storage proxyLocalStorage to read the attribute value in the simulated local storage fakeLocalStorage;
[0109] S33. While obtaining the specified attribute value by simulating the local storage fakeLocalStorage's data acquisition method, the attribute value with the same name in the original local storage rawLocalStorage is also detected;
[0110] 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 has occurred in the iOS APP;
[0111] Specifically, in step S4, data recovery of the abnormal protection process is performed:
[0112] S41. Reassign 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;
[0113] S42. Return the specified attribute value of the local storage rawLocalStorage to allow the program to run normally.
[0114] 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.
[0115] When the iOS app is initialized, rawLocalStorage reads the backed-up property values to restore the initial state.
[0116] When abnormal data deletion is detected, the system responds quickly, reducing problem resolution time and restoring data from fakeLocalStorage to rawLocalStorage, minimizing data loss. This anomaly detection and recovery mechanism improves application stability when facing LocalStorage issues, reducing application failures caused by data loss or anomalies and improving user satisfaction.
[0117] Steps S3 and S4 form a complete exception protection process that quickly detects and restores data when abnormal LocalStorage data is deleted, protecting applications from data loss. This approach not only improves data security and reliability but also ensures continuous application operation and user experience through immediate data recovery. Furthermore, centralized exception handling simplifies error handling, making applications more robust and easier to maintain.
[0118] The above description is based on the ideal embodiment of the present invention. Based on the above description, relevant personnel can make various changes and modifications without departing from the technical scope of this invention. The technical scope of this invention is not limited to the content of the specification and 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; 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; 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.
2. According to claim 1, a method for preventing abnormal deletion of LocalStorage data based on an iOS APP, 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. According to claim 1, a method for preventing abnormal deletion of LocalStorage data based on iOS APP, 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 recover 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.
4. According to claim 3, a method for preventing abnormal deletion of LocalStorage data based on an iOS APP, 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; if the key value is a predefined attribute, the attribute value of the simulated local storage is directly returned; if 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.
5. According to claim 1, a method for preventing abnormal deletion of LocalStorage data based on iOS APP, 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.
6. According to claim 1, a method for preventing abnormal deletion of LocalStorage data based on iOS APP, 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.
7. According to claim 1, a method for preventing abnormal deletion of LocalStorage data based on iOS APP, characterized in that: When the iOS app is initialized, the original local storage reads the backed-up attribute values to restore the initial state.
8. A device for protecting against abnormal deletion of LocalStorage data based on an iOS APP, the device comprising an electronic device, the electronic device comprising a memory, a processor, and a computer program stored in the memory and running on the processor, characterized in that: When the processor executes the computer program, the steps of the method for preventing abnormal deletion of LocalStorage data based on the iOS APP end are implemented as described in any one of claims 1 to 7.
