Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iOS: clear Keychain data on uninstall (1/2) #1397

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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