Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

clear app state when app is terminated

ammarahm-edc8d5411245ff
diff --git a/apps/mobile/ios/Notesnook/AppDelegate.m b/apps/mobile/ios/Notesnook/AppDelegate.m
index 6e45f029a..801168cea 100644
--- a/apps/mobile/ios/Notesnook/AppDelegate.m
+++ b/apps/mobile/ios/Notesnook/AppDelegate.m
@@ -6,7 +6,7 @@
#import "RNSplashScreen.h"
#import <React/RCTLinkingManager.h>
#import "ReceiveSharingIntent-Bridging-Header.h"
-
+#import <MMKV.h>
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
@@ -30,6 +30,15 @@
return YES;
}
+- (void)applicationWillTerminate:(UIApplication *)application {
+ NSArray *paths = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES);
+ NSString *libraryPath = (NSString *) [paths firstObject];
+ NSString *rootDir = [libraryPath stringByAppendingPathComponent:@"mmkv"];
+ [MMKV initializeMMKV:rootDir];
+ MMKV *kv = [MMKV mmkvWithID:@"default" mode:MMKVSingleProcess];
+ [kv removeValueForKey:@"appState"];
+ return YES;
+}
- (NSURL *)sourceURLForBridge:(RCTBridge *)bridge
diff --git a/apps/mobile/ios/Podfile b/apps/mobile/ios/Podfile
index a29976a07..55c169c72 100644
--- a/apps/mobile/ios/Podfile
+++ b/apps/mobile/ios/Podfile
@@ -7,11 +7,13 @@ permissions_path = '../node_modules/react-native-permissions/ios'
pod 'Base64'
pod 'Permission-PhotoLibrary', :path => "#{permissions_path}/PhotoLibrary.podspec"
+pod 'MMKV'
target 'Notesnook' do
config = use_native_modules!
use_react_native!(:path => config["reactNativePath"])
+
target 'NotesnookTests' do
inherit! :complete
# Pods for testing
diff --git a/apps/mobile/ios/Podfile.lock b/apps/mobile/ios/Podfile.lock
index 14e30bae8..79f1c98c9 100644
--- a/apps/mobile/ios/Podfile.lock
+++ b/apps/mobile/ios/Podfile.lock
@@ -284,6 +284,8 @@ PODS:
- React
- RNDeviceInfo (6.0.2):
- React
+ - RNExitApp (1.1.0):
+ - React
- RNFileViewer (2.1.1):
- React
- RNGestureHandler (1.7.0):
@@ -327,6 +329,7 @@ DEPENDENCIES:
- FBReactNativeSpec (from `../node_modules/react-native/Libraries/FBReactNativeSpec`)
- Folly (from `../node_modules/react-native/third-party-podspecs/Folly.podspec`)
- glog (from `../node_modules/react-native/third-party-podspecs/glog.podspec`)
+ - MMKV
- Permission-PhotoLibrary (from `../node_modules/react-native-permissions/ios/PhotoLibrary.podspec`)
- RCTRequired (from `../node_modules/react-native/Libraries/RCTRequired`)
- RCTTypeSafety (from `../node_modules/react-native/Libraries/TypeSafety`)
@@ -366,6 +369,7 @@ DEPENDENCIES:
- "RNCCheckbox (from `../node_modules/@react-native-community/checkbox`)"
- "RNCMaskedView (from `../node_modules/@react-native-community/masked-view`)"
- RNDeviceInfo (from `../node_modules/react-native-device-info`)
+ - RNExitApp (from `../node_modules/react-native-exit-app`)
- RNFileViewer (from `../node_modules/react-native-file-viewer`)
- RNGestureHandler (from `../node_modules/react-native-gesture-handler`)
- RNIap (from `../node_modules/react-native-iap`)
@@ -476,6 +480,8 @@ EXTERNAL SOURCES:
:path: "../node_modules/@react-native-community/masked-view"
RNDeviceInfo:
:path: "../node_modules/react-native-device-info"
+ RNExitApp:
+ :path: "../node_modules/react-native-exit-app"
RNFileViewer:
:path: "../node_modules/react-native-file-viewer"
RNGestureHandler:
@@ -556,6 +562,7 @@ SPEC CHECKSUMS:
RNCCheckbox: 47d045535fbb16796df628022a7cd631c78a4d9b
RNCMaskedView: 5a8ec07677aa885546a0d98da336457e2bea557f
RNDeviceInfo: bdd61e8b070d13a1dd9d022091981075ed4cde16
+ RNExitApp: c4e052df2568b43bec8a37c7cd61194d4cfee2c3
RNFileViewer: db62d60dd19007c54b2c959b5e675a46d59f8a43
RNGestureHandler: b6b359bb800ae399a9c8b27032bdbf7c18f08a08
RNIap: f7595967b8467dacb95f94a9eb4bbdb59f3afc67
@@ -574,6 +581,6 @@ SPEC CHECKSUMS:
toolbar-android: 85f3ef4d691469f2d304e7dee4bca013aa1ba1ff
Yoga: 7d13633d129fd179e01b8953d38d47be90db185a
-PODFILE CHECKSUM: c2e35739864f9098643aa5946bd50a10391afc1d
+PODFILE CHECKSUM: 75e5fdf731f5fbebed2725159f7ea172ed1c0356
COCOAPODS: 1.9.3