Skip to content

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

auto login

roryclear77d3ddf89f92
diff --git a/ios/clearcam/LoginViewController.m b/ios/clearcam/LoginViewController.m
index 3512e6e..812fbdf 100644
--- a/ios/clearcam/LoginViewController.m
+++ b/ios/clearcam/LoginViewController.m
@@ -41,6 +41,7 @@
[signUpButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
signUpButton.layer.cornerRadius = 8;
signUpButton.translatesAutoresizingMaskIntoConstraints = NO;
+ [signUpButton addTarget:self action:@selector(signUpButtonTapped) forControlEvents:UIControlEventTouchUpInside]; // Add this line
[container addSubview:signUpButton];
UILabel *alreadyHaveLabel = [[UILabel alloc] initWithFrame:CGRectZero];
@@ -113,6 +114,23 @@
[continueWithoutButton.bottomAnchor constraintEqualToAnchor:container.bottomAnchor]
]];
[continueWithoutButton addTarget:self action:@selector(continueWithoutAccountTapped) forControlEvents:UIControlEventTouchUpInside];
+ [[NSNotificationCenter defaultCenter] addObserver:self
+ selector:@selector(subscriptionStatusDidChange:)
+ name:StoreManagerSubscriptionStatusDidChangeNotification
+ object:nil];
+}
+
+- (void)subscriptionStatusDidChange:(NSNotification *)notification {
+ // Check if user is now subscribed
+ [[StoreManager sharedInstance] verifySubscriptionWithCompletionIfSubbed:^(BOOL isActive, NSDate *expiryDate) {
+ if (isActive) {
+ dispatch_async(dispatch_get_main_queue(), ^{
+ // Transition to GalleryViewController
+ GalleryViewController *mainVC = [[GalleryViewController alloc] init];
+ [self.navigationController pushViewController:mainVC animated:YES];
+ });
+ }
+ }];
}
- (void)continueWithoutAccountTapped {
@@ -120,6 +138,50 @@
[self.navigationController pushViewController:mainVC animated:YES];
}
+- (void)signUpButtonTapped {
+ __weak typeof(self) weakSelf = self;
+
+ // Use the correct method name with completion handler
+ [[StoreManager sharedInstance] showUpgradePopupInViewController:self completion:^(BOOL success) {
+ if (success) {
+ // Subscription was successful, verify and log in
+ [weakSelf handleSuccessfulSubscription];
+ }
+ }];
+}
+
+- (void)handleSuccessfulSubscription {
+ // Show loading indicator
+ UIActivityIndicatorView *spinner = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleLarge];
+ spinner.center = self.view.center;
+ [self.view addSubview:spinner];
+ [spinner startAnimating];
+
+ // Verify subscription
+ [[StoreManager sharedInstance] verifySubscriptionWithCompletionIfSubbed:^(BOOL isActive, NSDate *expiryDate) {
+ dispatch_async(dispatch_get_main_queue(), ^{
+ [spinner stopAnimating];
+ [spinner removeFromSuperview];
+
+ if (isActive) {
+ // Generate a new session token (or use the one from verification)
+ NSString *sessionToken = [[StoreManager sharedInstance] retrieveSessionTokenFromKeychain];
+ if (!sessionToken) {
+ sessionToken = [[NSUUID UUID] UUIDString];
+ [[StoreManager sharedInstance] storeSessionTokenInKeychain:sessionToken];
+ }
+
+ // Transition to GalleryViewController
+ GalleryViewController *mainVC = [[GalleryViewController alloc] init];
+ [self.navigationController pushViewController:mainVC animated:YES];
+ } else {
+ // Show error if verification failed
+ [self showAlertWithTitle:@"Error" message:@"Subscription verification failed. Please try again."];
+ }
+ });
+ }];
+}
+
- (void)loginButtonTapped {
NSString *enteredToken = [self.usernameTextField.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
diff --git a/ios/clearcam/StoreManager.h b/ios/clearcam/StoreManager.h
index 9a14310..efc3280 100644
--- a/ios/clearcam/StoreManager.h
+++ b/ios/clearcam/StoreManager.h
@@ -24,6 +24,8 @@ extern NSString *const StoreManagerSubscriptionStatusDidChangeNotification;
- (void)storeSessionTokenInKeychain:(NSString *)sessionToken;
- (void)clearSessionTokenFromKeychain;
- (void)showUpgradePopupInViewController:(UIViewController *)presentingVC;
+- (void)showUpgradePopupInViewController:(UIViewController *)presentingVC
+ completion:(void (^)(BOOL success))completion;
@end
diff --git a/ios/clearcam/StoreManager.m b/ios/clearcam/StoreManager.m
index b2aa757..b4aede2 100644
--- a/ios/clearcam/StoreManager.m
+++ b/ios/clearcam/StoreManager.m
@@ -188,11 +188,11 @@ NSString *const StoreManagerSubscriptionStatusDidChangeNotification = @"StoreMan
}];
}
-- (void)showUpgradePopupInViewController:(UIViewController *)presentingVC {
+- (void)showUpgradePopupInViewController:(UIViewController *)presentingVC
+ completion:(void (^)(BOOL success))completion {
[self showUpgradePopupInViewController:presentingVC
darkMode:(presentingVC.traitCollection.userInterfaceStyle == UIUserInterfaceStyleDark)
- completion:^(BOOL success) {
- }];
+ completion:completion];
}
- (void)handleUpgradeTap:(UIButton *)sender {