Skip to content

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

login if no internet

roryclear67f4ac48bb8f
diff --git a/ios/clearcam/SceneDelegate.m b/ios/clearcam/SceneDelegate.m
index a4a240f..77fc86a 100644
--- a/ios/clearcam/SceneDelegate.m
+++ b/ios/clearcam/SceneDelegate.m
@@ -31,31 +31,60 @@ willConnectToSession:(UISceneSession *)session
}
- (void)verifyAuthentication {
- [[StoreManager sharedInstance] verifySubscriptionWithCompletionIfSubbed:^(BOOL isActive, NSDate *expiryDate) {
- dispatch_async(dispatch_get_main_queue(), ^{
- UIViewController *rootVC;
-
- if (isActive) {
- rootVC = [[GalleryViewController alloc] init];
- } else {
- rootVC = [[LoginViewController alloc] init];
- // Clear any invalid token
- [[StoreManager sharedInstance] clearSessionTokenFromKeychain];
- }
-
- UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:rootVC];
-
- // Animate the transition
- [UIView transitionWithView:self.window
- duration:0.3
- options:UIViewAnimationOptionTransitionCrossDissolve
- animations:^{
- self.window.rootViewController = navigationController;
- } completion:nil];
-
- [self.activityIndicator stopAnimating];
- });
+ [self checkInternetWithCompletion:^(BOOL hasInternet) {
+ if (!hasInternet) {
+ dispatch_async(dispatch_get_main_queue(), ^{
+ [self switchToRootViewController:[[GalleryViewController alloc] init]];
+ });
+ return;
+ }
+ [[StoreManager sharedInstance] verifySubscriptionWithCompletionIfSubbed:^(BOOL isActive, NSDate *expiryDate) {
+ dispatch_async(dispatch_get_main_queue(), ^{
+ UIViewController *rootVC;
+
+ if (isActive) {
+ rootVC = [[GalleryViewController alloc] init];
+ } else {
+ rootVC = [[LoginViewController alloc] init];
+ [[StoreManager sharedInstance] clearSessionTokenFromKeychain];
+ }
+ [self switchToRootViewController:rootVC];
+ });
+ }];
}];
}
+- (void)checkInternetWithCompletion:(void (^)(BOOL hasInternet))completion {
+ NSURL *url = [NSURL URLWithString:@"https://rors.ai/ping"];
+ NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url
+ cachePolicy:NSURLRequestReloadIgnoringLocalCacheData
+ timeoutInterval:3.0];
+ request.HTTPMethod = @"HEAD";
+ NSURLSessionDataTask *task = [[NSURLSession sharedSession]
+ dataTaskWithRequest:request
+ completionHandler:^(NSData * _Nullable data,
+ NSURLResponse * _Nullable response,
+ NSError * _Nullable error) {
+ if (error) {
+ completion(NO);
+ return;
+ }
+ completion(response != nil);
+ }];
+ [task resume];
+}
+
+- (void)switchToRootViewController:(UIViewController *)rootVC {
+ UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:rootVC];
+ [UIView transitionWithView:self.window
+ duration:0.3
+ options:UIViewAnimationOptionTransitionCrossDissolve
+ animations:^{
+ self.window.rootViewController = navigationController;
+ } completion:nil];
+
+ [self.activityIndicator stopAnimating];
+}
+
@end
+