Skip to content

Commit

Permalink
iOS: clear Keychain data on uninstall (1/2)
Browse files Browse the repository at this point in the history
  • Loading branch information
kaloudis committed Mar 26, 2023
1 parent 735d777 commit dbadc7c
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions ios/zeus/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,32 @@ static void InitializeFlipper(UIApplication *application) {
}
#endif

/**
Deletes all Keychain items accessible by this app if this is the first time the user launches the app
*/
static void ClearKeychainIfNecessary() {
// Checks whether or not this is the first time the app is run
if ([[NSUserDefaults standardUserDefaults] boolForKey:@"HAS_RUN_BEFORE"] == NO) {
// Set the appropriate value so we don't clear next time the app is launched
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"HAS_RUN_BEFORE"];

// TODO for now leave delete process disabled and enable for v0.7.5
// NSArray *secItemClasses = @[
// (__bridge id)kSecClassGenericPassword,
// (__bridge id)kSecClassInternetPassword,
// (__bridge id)kSecClassCertificate,
// (__bridge id)kSecClassKey,
// (__bridge id)kSecClassIdentity
// ];

// // Maps through all Keychain classes and deletes all items that match
// for (id secItemClass in secItemClasses) {
// NSDictionary *spec = @{(__bridge id)kSecClass: secItemClass};
// SecItemDelete((__bridge CFDictionaryRef)spec);
// }
}
}

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application
Expand All @@ -39,6 +65,9 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
InitializeFlipper(application);
#endif

// Add this line to call the above function
ClearKeychainIfNecessary();

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

0 comments on commit dbadc7c

Please sign in to comment.