Add object detection, tracking, mobile notifications, and search to any security camera.
fix sign out
rorycleare889b986580c
diff --git a/ios/clearcam/SceneDelegate.m b/ios/clearcam/SceneDelegate.mindex 77fc86a..ee51f70 100644--- a/ios/clearcam/SceneDelegate.m+++ b/ios/clearcam/SceneDelegate.m@@ -38,7 +38,7 @@ willConnectToSession:(UISceneSession *)session});return;}- [[StoreManager sharedInstance] verifySubscriptionWithCompletionIfSubbed:^(BOOL isActive, NSDate *expiryDate) {+ [[StoreManager sharedInstance] verifySessionOnlyWithCompletion:^(BOOL isActive, NSDate *expiryDate) {dispatch_async(dispatch_get_main_queue(), ^{UIViewController *rootVC;diff --git a/ios/clearcam/SettingsViewController.m b/ios/clearcam/SettingsViewController.mindex e34b557..434b956 100644--- a/ios/clearcam/SettingsViewController.m+++ b/ios/clearcam/SettingsViewController.m@@ -2,6 +2,7 @@#import "SettingsManager.h"#import "SecretManager.h"#import "StoreManager.h"+#import "LoginViewController.h"#import "NumberSelectionViewController.h"#import "notification.h"#import "FileServer.h"@@ -597,27 +598,32 @@}}} else if (indexPath.section == 5) { // Terms and Privacy- if (indexPath.row == 0) {+ if (indexPath.row == 0) { // Terms of Usecell.textLabel.text = NSLocalizedString(@"terms_of_use", @"Label for terms of use link");cell.textLabel.textColor = [UIColor systemBlueColor];cell.textLabel.textAlignment = NSTextAlignmentCenter;cell.accessoryType = UITableViewCellAccessoryNone;cell.userInteractionEnabled = YES;- } else if (indexPath.row == 1) {+ } else if (indexPath.row == 1) { // Privacy Policycell.textLabel.text = NSLocalizedString(@"privacy_policy", @"Label for privacy policy link");cell.textLabel.textColor = [UIColor systemBlueColor];cell.textLabel.textAlignment = NSTextAlignmentCenter;cell.accessoryType = UITableViewCellAccessoryNone;cell.userInteractionEnabled = YES;- } else if (indexPath.row == 2) {+ } else if (indexPath.row == 2) { // Delete Encryption Keyscell.textLabel.text = NSLocalizedString(@"delete_encryption_keys", @"Label for delete encryption keys button");cell.textLabel.textColor = [UIColor systemRedColor];cell.textLabel.textAlignment = NSTextAlignmentCenter;cell.accessoryType = UITableViewCellAccessoryNone;cell.userInteractionEnabled = YES;+ } else if (indexPath.row == 3) { // Sign Out+ cell.textLabel.text = NSLocalizedString(@"sign_out", @"Label for sign out button");+ cell.textLabel.textColor = [UIColor systemRedColor];+ cell.textLabel.textAlignment = NSTextAlignmentCenter;+ cell.accessoryType = UITableViewCellAccessoryNone;+ cell.userInteractionEnabled = YES;}}-return cell;}@@ -638,7 +644,7 @@} else if (section == 4) { // Upgrade to Premium / Subscriptionreturn 2; // 1 row for "Restore Purchases" if subscribed, 2 rows ("Upgrade" + "Restore") if not} else if (section == 5) { // Terms and Privacy- return 3; // Terms of Use, Privacy Policy, Delete Encryption Keys+ return 4; // Terms of Use, Privacy Policy, Delete Encryption Keys, Sign out}return 0;}@@ -899,11 +905,55 @@[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"https://www.rors.ai/privacy"] options:@{} completionHandler:nil];} else if (indexPath.row == 2) { // Delete Encryption Keys[self showDeleteEncryptionKeysPrompt];+ } else if (indexPath.row == 3) { // Delete Encryption Keys+ [self showSignOutConfirmation];}}[tableView deselectRowAtIndexPath:indexPath animated:YES];}+- (void)showSignOutConfirmation {+ UIAlertController *alert = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"sign_out_title", @"Title for sign out confirmation")+ message:NSLocalizedString(@"sign_out_message", @"Message for sign out confirmation")+ preferredStyle:UIAlertControllerStyleAlert];++ UIAlertAction *signOutAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"sign_out", @"Sign Out button")+ style:UIAlertActionStyleDestructive+ handler:^(UIAlertAction * _Nonnull action) {+ [self performSignOut];+ }];++ UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"cancel", @"Cancel button")+ style:UIAlertActionStyleCancel+ handler:nil];++ [alert addAction:signOutAction];+ [alert addAction:cancelAction];++ [self presentViewController:alert animated:YES completion:nil];+}++- (void)performSignOut {+ [[StoreManager sharedInstance] clearSessionTokenFromKeychain];+ NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];+ [defaults removeObjectForKey:@"isSubscribed"];+ [defaults removeObjectForKey:@"device_token"];+ [defaults removeObjectForKey:@"hasRequestedNotificationPermission"];+ [defaults removeObjectForKey:@"subscriptionReceipt"];+ [defaults synchronize];+ [self deleteDeviceTokenFromServer];+ LoginViewController *loginVC = [[LoginViewController alloc] init];+ UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:loginVC];+ UIWindow *window = [[[UIApplication sharedApplication] windows] firstObject];+ [UIView transitionWithView:window+ duration:0.3+ options:UIViewAnimationOptionTransitionCrossDissolve+ animations:^{+ window.rootViewController = navController;+ }+ completion:nil];+}+- (void)authenticateToRevealUserID {LAContext *context = [[LAContext alloc] init];NSError *authError = nil;diff --git a/ios/clearcam/StoreManager.h b/ios/clearcam/StoreManager.hindex c2c0c1e..0b711e1 100644--- a/ios/clearcam/StoreManager.h+++ b/ios/clearcam/StoreManager.h@@ -13,6 +13,7 @@ extern NSString *const StoreManagerSubscriptionStatusDidChangeNotification;+ (instancetype)sharedInstance;- (void)verifySubscriptionWithCompletion:(void (^)(BOOL isActive, NSDate * _Nullable expiryDate))completion;- (void)verifySubscriptionWithCompletionIfSubbed:(void (^)(BOOL isActive, NSDate * _Nullable expiryDate))completion;+- (void)verifySessionOnlyWithCompletion:(void (^)(BOOL isActive, NSDate *expiryDate))completion;- (void)showUpgradePopupInViewController:(UIViewController *)presentingVCdarkMode:(BOOL)isDarkModecompletion:(void (^)(BOOL success))completion;diff --git a/ios/clearcam/StoreManager.m b/ios/clearcam/StoreManager.mindex bbe9cf7..56f774e 100644--- a/ios/clearcam/StoreManager.m+++ b/ios/clearcam/StoreManager.m@@ -475,6 +475,35 @@ NSString *const StoreManagerSubscriptionStatusDidChangeNotification = @"StoreMan}}++- (void)verifySessionOnlyWithCompletion:(void (^)(BOOL isActive, NSDate *expiryDate))completion {+ NSString *sessionToken = [self retrieveSessionTokenFromKeychain];++ if (!sessionToken || sessionToken.length == 0) {+ completion(NO, nil);+ return;+ }++ NSString *urlString = [NSString stringWithFormat:@"https://rors.ai/validate_user?session_token=%@", sessionToken];+ NSURL *url = [NSURL URLWithString:urlString];++ NSURLSessionDataTask *task = [[NSURLSession sharedSession] dataTaskWithURL:url completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {+ NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *)response;++ if (!error && httpResponse.statusCode >= 200 && httpResponse.statusCode < 300) {+ dispatch_async(dispatch_get_main_queue(), ^{+ completion(YES, [[NSUserDefaults standardUserDefaults] objectForKey:@"expiry"]);+ });+ } else {+ dispatch_async(dispatch_get_main_queue(), ^{+ completion(NO, nil);+ });+ }+ }];++ [task resume];+}+- (void)verifySubscriptionWithCompletion:(void (^)(BOOL isActive, NSDate *expiryDate))completion {self.last_check_time = [[NSDate date] timeIntervalSince1970];static BOOL isRequestInProgress = NO;@@ -506,6 +535,7 @@ NSString *const StoreManagerSubscriptionStatusDidChangeNotification = @"StoreMan[self performReceiptVerificationWithCompletion:completion requestFlag:&isRequestInProgress];}+- (void)performReceiptVerificationWithCompletion:(void (^)(BOOL isActive, NSDate *expiryDate))completionrequestFlag:(BOOL *)flagPtr {NSString *storedReceipt = [[NSUserDefaults standardUserDefaults] stringForKey:@"subscriptionReceipt"];