Skip to content
This repository has been archived by the owner on Jun 15, 2022. It is now read-only.

Commit

Permalink
Disable NSURLCache
Browse files Browse the repository at this point in the history
  • Loading branch information
moughxyz committed Nov 1, 2019
1 parent a9163a4 commit 1b07bdc
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion ios/StandardNotes/AppDelegate.m
Expand Up @@ -9,6 +9,11 @@ @implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Disable NSURLCache for general network requests. Caches are not protected by NSFileProtectionComplete.
// Disabling, or implementing a custom subclass are only two solutions. https://stackoverflow.com/questions/27933387/nsurlcache-and-data-protection
NSURLCache *sharedCache = [[NSURLCache alloc] initWithMemoryCapacity:0 diskCapacity:0 diskPath:nil];
[NSURLCache setSharedURLCache:sharedCache];

[BugsnagReactNative start];

// Clear web editor cache after every app update
Expand All @@ -18,13 +23,15 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
if(![currentVersion isEqualToString:lastVersionClear]) {
// UIWebView
[[NSURLCache sharedURLCache] removeAllCachedResponses];
[[NSUserDefaults standardUserDefaults] setObject:currentVersion forKey:lastVersionClearKey];

// WebKit
NSSet *websiteDataTypes = [WKWebsiteDataStore allWebsiteDataTypes];
NSDate *dateFrom = [NSDate dateWithTimeIntervalSince1970:0];
[[WKWebsiteDataStore defaultDataStore] removeDataOfTypes:websiteDataTypes modifiedSince:dateFrom completionHandler:^{}];

[[NSUserDefaults standardUserDefaults] setObject:currentVersion forKey:lastVersionClearKey];
}


RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions];
RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge moduleName:@"StandardNotes" initialProperties:nil];
Expand Down

0 comments on commit 1b07bdc

Please sign in to comment.