Add object detection, tracking, mobile notifications, and search to any security camera.
try download in bg?
rorycleard16d04bd837d
diff --git a/clearcam/AppDelegate.m b/clearcam/AppDelegate.mindex 26335c6..9a2c95b 100644--- a/clearcam/AppDelegate.m+++ b/clearcam/AppDelegate.m@@ -9,7 +9,7 @@@implementation AppDelegate- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {- // Notification setup+ NSLog(@"App launched with options: %@", launchOptions);UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];center.delegate = self;@@ -19,18 +19,27 @@dispatch_async(dispatch_get_main_queue(), ^{[application registerForRemoteNotifications];});+ } else {+ NSLog(@"Notification permission denied: %@", error);}}];- // Check for notification launch+ // Handle launch from notificationif (launchOptions[UIApplicationLaunchOptionsRemoteNotificationKey]) {- self.pendingNotification = launchOptions[UIApplicationLaunchOptionsRemoteNotificationKey];+ NSDictionary *userInfo = launchOptions[UIApplicationLaunchOptionsRemoteNotificationKey];+ self.pendingNotification = userInfo;+ NSLog(@"Launched from notification: %@", userInfo);+ // Only run background code if content-available is present (receipt, not tap)+ if (userInfo[@"aps"][@"content-available"]) {+ [self handleNotificationReceived:userInfo];+ }}return YES;}- (void)applicationDidBecomeActive:(UIApplication *)application {+ NSLog(@"Application became active");if (self.pendingNotification) {[self handleNotificationNavigation];self.pendingNotification = nil;@@ -41,41 +50,43 @@- (void)handleNotificationNavigation {dispatch_async(dispatch_get_main_queue(), ^{- // Get the key window's root view controller+ NSLog(@"Handling notification navigation (user tapped)");UIWindow *window = [UIApplication sharedApplication].keyWindow;UIViewController *rootVC = window.rootViewController;- // Find the topmost presented view controllerUIViewController *topVC = rootVC;while (topVC.presentedViewController) {topVC = topVC.presentedViewController;}- // Check if we already have a GalleryViewController visibleif ([topVC isKindOfClass:[UINavigationController class]]) {UINavigationController *nav = (UINavigationController *)topVC;if ([nav.topViewController isKindOfClass:[GalleryViewController class]]) {- return; // Already showing gallery+ NSLog(@"GalleryViewController already visible");+ return;}}- // Create and show the GalleryViewControllerGalleryViewController *galleryVC = [[GalleryViewController alloc] init];if ([topVC isKindOfClass:[UINavigationController class]]) {- // Push onto existing nav stack[(UINavigationController *)topVC pushViewController:galleryVC animated:YES];} else if (topVC.navigationController) {- // Push onto existing nav controller[topVC.navigationController pushViewController:galleryVC animated:YES];} else {- // Present modally with new nav controllerUINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:galleryVC];[topVC presentViewController:navController animated:YES completion:nil];}});}+- (void)handleNotificationReceived:(NSDictionary *)userInfo {+ NSLog(@"Notification received (user did NOT tap): %@", userInfo);+ GalleryViewController *gallery = [[GalleryViewController alloc] init];+ sleep(15);+ [gallery getEvents];+}+#pragma mark - Remote Notification Methods- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {@@ -91,14 +102,20 @@- (void)userNotificationCenter:(UNUserNotificationCenter *)centerwillPresentNotification:(UNNotification *)notificationwithCompletionHandler:(void (^)(UNNotificationPresentationOptions))completionHandler {- // Show notification when app is in foreground+ NSDictionary *userInfo = notification.request.content.userInfo;+ NSLog(@"Will present notification: %@", userInfo);+ if (userInfo[@"aps"][@"content-available"]) {+ [self handleNotificationReceived:userInfo];+ }completionHandler(UNNotificationPresentationOptionAlert | UNNotificationPresentationOptionSound);}- (void)userNotificationCenter:(UNUserNotificationCenter *)centerdidReceiveNotificationResponse:(UNNotificationResponse *)responsewithCompletionHandler:(void (^)(void))completionHandler {- // Handle notification tap (foreground or background)+ NSDictionary *userInfo = response.notification.request.content.userInfo;+ NSLog(@"User tapped notification: %@", userInfo);+ // Only handle navigation, no custom code here[self handleNotificationNavigation];completionHandler();}@@ -106,16 +123,26 @@ didReceiveNotificationResponse:(UNNotificationResponse *)response- (void)application:(UIApplication *)applicationdidReceiveRemoteNotification:(NSDictionary *)userInfofetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler {+ NSLog(@"Received remote notification: %@", userInfo);- if (application.applicationState == UIApplicationStateInactive) {- // App was in background and user tapped notification- [self handleNotificationNavigation];- } else if (application.applicationState == UIApplicationStateBackground) {- // App was in background - store notification for when app becomes active- self.pendingNotification = userInfo;+ if (userInfo[@"aps"][@"content-available"]) {+ NSLog(@"Background notification detected");+ dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{+ [self handleNotificationReceived:userInfo];+ completionHandler(UIBackgroundFetchResultNewData);+ });+ } else {+ if (application.applicationState == UIApplicationStateInactive) {+ NSLog(@"App inactive - handling navigation");+ self.pendingNotification = userInfo;+ } else if (application.applicationState == UIApplicationStateBackground) {+ NSLog(@"App in background - storing notification");+ self.pendingNotification = userInfo;+ } else {+ NSLog(@"App in foreground - regular notification received");+ }+ completionHandler(UIBackgroundFetchResultNoData);}-- completionHandler(UIBackgroundFetchResultNewData);}#pragma mark - Core Data Stackdiff --git a/clearcam/GalleryViewController.h b/clearcam/GalleryViewController.hindex c8b86dc..1f26169 100644--- a/clearcam/GalleryViewController.h+++ b/clearcam/GalleryViewController.h@@ -1,5 +1,6 @@#import <UIKit/UIKit.h>@interface GalleryViewController : UIViewController+- (void)getEvents;@enddiff --git a/clearcam/Info.plist b/clearcam/Info.plistindex 551815b..112c2bb 100644--- a/clearcam/Info.plist+++ b/clearcam/Info.plist@@ -40,6 +40,7 @@</dict><key>UIBackgroundModes</key><array>+ <string>fetch</string><string>remote-notification</string></array><key>UIFileSharingEnabled</key>