Skip to content

Add object detection, tracking, mobile notifications, and search to any security camera.

move notif settings to top

rorycleardbc092791ce8
diff --git a/ios/clearcam/DeviceStreamViewController.m b/ios/clearcam/DeviceStreamViewController.m
index eaf938c..eae1d62 100644
--- a/ios/clearcam/DeviceStreamViewController.m
+++ b/ios/clearcam/DeviceStreamViewController.m
@@ -27,8 +27,6 @@
- (void)viewDidLoad {
[super viewDidLoad];
self.view.backgroundColor = [UIColor blackColor];
-
- // Setup spinner
self.loadingSpinner = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleLarge];
self.loadingSpinner.center = self.view.center;
self.loadingSpinner.color = [UIColor whiteColor];
@@ -48,7 +46,6 @@
- (void)fetchDownloadLinkAndStartStreaming {
[self fetchDownloadLink];
- // Start timer to refresh download link every 60 seconds
self.linkRefreshTimer = [NSTimer scheduledTimerWithTimeInterval:50.0
target:self
selector:@selector(fetchDownloadLink)
@@ -87,16 +84,11 @@
NSString *downloadLink = json[@"download_link"];
if (![downloadLink isKindOfClass:[NSString class]] || downloadLink.length == 0) {
- NSLog(@"🚫 Invalid downloadLink link");
return;
} else {
self.downloadLink = downloadLink;
}
-
- NSLog(@"βœ… Got download link: %@", self.downloadLink);
-
dispatch_async(dispatch_get_main_queue(), ^{
- // Start downloading segments only if this is the first fetch
if (!self.downloadTimer) [self startDownloadTimer];
});
}];
@@ -122,34 +114,26 @@
NSURLSessionDataTask *task = [[NSURLSession sharedSession] dataTaskWithURL:remoteURL
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error || !data) {
- NSLog(@"❌ Download error: %@", error.localizedDescription);
return;
}
- // Only set lastSegmentData after successful decryption
- NSLog(@"πŸ“₯ New segment downloaded, attempting decryption");
-
[self decryptAndQueueSegment:data withCompletion:^(NSData *decryptedData) {
if (!decryptedData) {
- NSLog(@"❌ Decryption failed");
return;
}
NSUInteger hash = data.hash;
NSData *hashData = [NSData dataWithBytes:&hash length:sizeof(hash)];
if ([self.seenSegmentHashes containsObject:hashData]) {
- NSLog(@"πŸ” Duplicate decrypted segment, skipping queue");
return;
}
[self.seenSegmentHashes addObject:hashData];
self.lastSegmentData = data;
- self.decryptionFailedOnce = NO; // Only reset on success
+ self.decryptionFailedOnce = NO;
NSString *fileName = [NSString stringWithFormat:@"segment_%lu.mp4", (unsigned long)(self.segmentIndex++ % 2)];
NSString *tempPath = [NSTemporaryDirectory() stringByAppendingPathComponent:fileName];
NSURL *localURL = [NSURL fileURLWithPath:tempPath];
-
- // Delete existing file if any (from old streams)
[[NSFileManager defaultManager] removeItemAtURL:localURL error:nil];
if ([decryptedData writeToURL:localURL atomically:YES]) {
@@ -158,7 +142,7 @@
//thumbnail save
AVAsset *videoAsset = [AVAsset assetWithURL:localURL];
AVAssetImageGenerator *imageGenerator = [[AVAssetImageGenerator alloc] initWithAsset:videoAsset];
- imageGenerator.appliesPreferredTrackTransform = YES; // To avoid rotated images
+ imageGenerator.appliesPreferredTrackTransform = YES;
CMTime time = CMTimeMakeWithSeconds(0.0, 600); // Grab first frame (0s)
[imageGenerator generateCGImagesAsynchronouslyForTimes:@[[NSValue valueWithCMTime:time]]
@@ -200,7 +184,6 @@
if (self.decryptionKey) {
NSData *decryptedData = [[SecretManager sharedManager] decryptData:encryptedData withKey:self.decryptionKey];
if (decryptedData) {
- // Successful decryption, reset all failure tracking
self.consecutiveDecryptionFailures = 0;
self.lastFailedEncryptedData = nil;
self.decryptionFailedOnce = NO;
@@ -211,7 +194,6 @@
}
}
- // Handle failure
BOOL isSameData = [self.lastFailedEncryptedData isEqualToData:encryptedData];
if (!isSameData) {
self.consecutiveDecryptionFailures += 1;
@@ -252,12 +234,11 @@
completion(decryptedData);
} else {
[self showErrorAlertWithMessage:@"The provided key is incorrect. Please try again or cancel." completion:^{
- // Re-prompt for the same segment
[self promptForKeyOnSecondFailure:encryptedData withCompletion:completion];
}];
}
} else {
- completion(nil); // User cancelled
+ completion(nil);
}
}];
});
@@ -324,11 +305,6 @@
}
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *)response;
- if (httpResponse.statusCode == 200) {
- NSLog(@"βœ… Successfully deleted stream download link");
- } else {
- NSLog(@"⚠️ Delete request failed with status code: %ld", (long)httpResponse.statusCode);
- }
}];
[deleteTask resume];
}
diff --git a/ios/clearcam/SettingsViewController.m b/ios/clearcam/SettingsViewController.m
index 434b956..3fa4a5f 100644
--- a/ios/clearcam/SettingsViewController.m
+++ b/ios/clearcam/SettingsViewController.m
@@ -390,11 +390,11 @@
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
if (section == 0) {
- return NSLocalizedString(@"camera_settings", @"Header for camera settings section");
+ return NSLocalizedString(@"viewer_settings", @"Header for viewer settings section");
} else if (section == 1) {
- return NSLocalizedString(@"live_stream_settings", @"Header for live stream settings section");
+ return NSLocalizedString(@"camera_settings", @"Header for camera settings section");
} else if (section == 2) {
- return NSLocalizedString(@"viewer_settings", @"Header for viewer settings section");
+ return NSLocalizedString(@"live_stream_settings", @"Header for live stream settings section");
} else if (section == 3) {
return NSLocalizedString(@"experimental_features", @"Header for advanced settings section");
} else if (section == 4) {
@@ -433,7 +433,7 @@
BOOL isPremium = [[NSUserDefaults standardUserDefaults] boolForKey:@"isSubscribed"];
- if (indexPath.section == 0) { // Camera Settings
+ if (indexPath.section == 1) { // Camera Settings
if (indexPath.row == 0) {
cell.textLabel.text = NSLocalizedString(@"stream_via_wifi", @"Label for stream via Wi-Fi setting");
NSString *ipAddress = [[NSUserDefaults standardUserDefaults] stringForKey:@"DeviceIPAddress"];
@@ -506,7 +506,7 @@
cell.userInteractionEnabled = YES;
}
}
- } else if (indexPath.section == 1) { // Live Stream Settings
+ } else if (indexPath.section == 2) { // Live Stream Settings
if (indexPath.row == 0) {
cell.textLabel.text = NSLocalizedString(@"live_stream_network", @"Label for live stream over network setting");
cell.accessoryType = UITableViewCellAccessoryNone;
@@ -524,7 +524,7 @@
cell.textLabel.textColor = isPremium ? [UIColor labelColor] : [UIColor grayColor];
cell.userInteractionEnabled = YES;
}
- } else if (indexPath.section == 2) { // Viewer Settings
+ } else if (indexPath.section == 0) { // Viewer Settings
if (indexPath.row == 0) {
cell.textLabel.text = NSLocalizedString(@"receive_notifications", @"Label for receive notifications setting");
cell.detailTextLabel.text = NSLocalizedString(@"receive_notifications_description", @"Description for receive notifications setting");
@@ -628,16 +628,16 @@
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
- if (section == 0) { // Camera Settings
+ if (section == 1) { // Camera Settings
NSInteger baseRows = 8; // Up to "Manage Detection Schedules"
if (self.isPresetsSectionExpanded) {
NSArray *presetKeys = [[[NSUserDefaults standardUserDefaults] objectForKey:@"yolo_presets"] allKeys];
baseRows += presetKeys.count + 1; // Preset rows + "Add Preset"
}
return baseRows;
- } else if (section == 1) { // Live Stream Settings
+ } else if (section == 2) { // Live Stream Settings
return 2; // Live Stream over the internet and Device name
- } else if (section == 2) { // Viewer Settings
+ } else if (section == 0) { // Viewer Settings
return 1; // Just Receive Notifications
} else if (section == 3) { // Advanced Settings
return 2; // Use Own Notification Server, Use Own Inference Server
@@ -811,7 +811,7 @@
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
BOOL isPremium = [[NSUserDefaults standardUserDefaults] boolForKey:@"isSubscribed"];
- if (indexPath.section == 0) { // Camera Settings
+ if (indexPath.section == 1) { // Viewer Settings
if (indexPath.row == 0) {
// Stream via Wi-Fi - handled by switch
} else if (indexPath.row == 1) {
@@ -858,7 +858,7 @@
[self.navigationController pushViewController:scheduleVC animated:YES];
}
}
- } else if (indexPath.section == 1) { // Live Stream Settings
+ } else if (indexPath.section == 2) { // Live Stream Settings
if (indexPath.row == 0) {
if (!isPremium) {
[[StoreManager sharedInstance] showUpgradePopupInViewController:self];
@@ -870,7 +870,7 @@
[[StoreManager sharedInstance] showUpgradePopupInViewController:self];
}
}
- } else if (indexPath.section == 2) { // Viewer Settings
+ } else if (indexPath.section == 0) { // Viewer Settings
if (indexPath.row == 0) {
if (!isPremium) {
[[StoreManager sharedInstance] showUpgradePopupInViewController:self];
@@ -1156,7 +1156,7 @@
#pragma mark - UITableView Delegate
- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath {
- if (indexPath.section == 0 && self.isPresetsSectionExpanded) { // Only in Camera Settings
+ if (indexPath.section == 1 && self.isPresetsSectionExpanded) { // Only in Camera Settings
NSArray *presetKeys = [[[NSUserDefaults standardUserDefaults] objectForKey:@"yolo_presets"] allKeys];
if (indexPath.row >= 4 && indexPath.row < 4 + presetKeys.count) {
NSString *presetKey = presetKeys[indexPath.row - 4];
@@ -1169,7 +1169,7 @@
}
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
- if (editingStyle == UITableViewCellEditingStyleDelete && indexPath.section == 0 && self.isPresetsSectionExpanded) {
+ if (editingStyle == UITableViewCellEditingStyleDelete && indexPath.section == 1 && self.isPresetsSectionExpanded) {
NSArray *presetKeys = [[[NSUserDefaults standardUserDefaults] objectForKey:@"yolo_presets"] allKeys];
if (indexPath.row >= 4 && indexPath.row < 4 + presetKeys.count) {
NSString *presetKey = presetKeys[indexPath.row - 4];