A Cordova plugin that migrates localStorage data from UIWebView to WKWebView on iOS. This plugin is useful when transitioning from UIWebView to WKWebView in Capacitor or Cordova iOS applications.
When migrating a Cordova app from UIWebView to WKWebView, localStorage data is stored in different locations, which can cause users to lose their data during the transition. This plugin handles the migration of localStorage data from the UIWebView storage location to the WKWebView storage location.
cordova plugin add cordova-plugin-migrate-ios-localstorage
Or directly from GitHub:
cordova plugin add https://github.com/Chuckv01/cordova-plugin-migrate-ios-localstorage.git
The plugin provides a simple API to migrate localStorage data. Call the migrate method early in your app initialization:
import 'cordova-plugin-migrate-ios-localstorage';
...
document.addEventListener('deviceready', function() {
(window as any).cordova.plugins.MigrateLocalStorage.migrate();
.then(success => {
console.log('Migration completed successfully: ' + success);
})
.catch(error => {
console.error('Migration failed: ' + error);
});
}, false);
migrate()
Migrates localStorage data from UIWebView to WKWebView.
Returns a Promise that resolves to a boolean indicating success or rejects with an error.
- The plugin checks if localStorage already has data in WKWebView format
- If not, it initializes localStorage with a marker
- It polls until storage is confirmed ready
- Then it copies the SQLite database records from the UIWebView location to the WKWebView location
- Capacitor OR Cordova iOS 4.0.0+
- iOS 9.0+
This project is licensed under the Apache License 2.0.