Skip to content

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

check subscription on other reqs

roryclearbed9f7cbd1ff
diff --git a/clearcam/GalleryViewController.m b/clearcam/GalleryViewController.m
index 6d47c30..f67de94 100644
--- a/clearcam/GalleryViewController.m
+++ b/clearcam/GalleryViewController.m
@@ -124,7 +124,9 @@
self.loadedFilenames = [NSMutableSet set];
[self setupDownloadDirectory];
[self loadExistingVideos];
- [self getEvents];
+ [[StoreManager sharedInstance] verifySubscriptionWithCompletionIfSubbed:^(BOOL isActive, NSDate *expiryDate) {
+ [self getEvents];
+ }];
[self updateTableViewBackground];
}
diff --git a/clearcam/LiveViewController.m b/clearcam/LiveViewController.m
index 0f4a21b..0c5cb1d 100644
--- a/clearcam/LiveViewController.m
+++ b/clearcam/LiveViewController.m
@@ -18,7 +18,9 @@
self.session = [NSURLSession sessionWithConfiguration:[NSURLSessionConfiguration defaultSessionConfiguration]];
[self setupTableView];
+ [[StoreManager sharedInstance] verifySubscriptionWithCompletionIfSubbed:^(BOOL isActive, NSDate *expiryDate) {
[self fetchLiveDevices];
+ }];
}
- (void)setupTableView {
diff --git a/clearcam/StoreManager.m b/clearcam/StoreManager.m
index fefcf07..3977610 100644
--- a/clearcam/StoreManager.m
+++ b/clearcam/StoreManager.m
@@ -34,7 +34,6 @@ NSString *const StoreManagerSubscriptionStatusDidChangeNotification = @"StoreMan
self = [super init];
if (self) {
[[SKPaymentQueue defaultQueue] addTransactionObserver:self];
- self.last_check_time = [[NSDate date] timeIntervalSince1970];
}
return self;
}
@@ -231,7 +230,7 @@ NSString *const StoreManagerSubscriptionStatusDidChangeNotification = @"StoreMan
NSDate *expiry = [[NSUserDefaults standardUserDefaults] objectForKey:@"expiry"];
BOOL isSubscribed = [[NSUserDefaults standardUserDefaults] boolForKey:@"isSubscribed"];
BOOL sessionExpiredOrNow = !expiry || [expiry compare:[NSDate date]] != NSOrderedDescending;
- if (isSubscribed || [[NSDate date] timeIntervalSince1970] - [StoreManager sharedInstance].last_check_time > 120.0) {
+ if (isSubscribed || [StoreManager sharedInstance].last_check_time || [[NSDate date] timeIntervalSince1970] - [StoreManager sharedInstance].last_check_time > 120.0) {
if (sessionExpiredOrNow) {
[self verifySubscriptionWithCompletion:^(BOOL isActive, NSDate *expiryDate) {
if (completion) {
@@ -343,7 +342,8 @@ NSString *const StoreManagerSubscriptionStatusDidChangeNotification = @"StoreMan
(__bridge id)kSecAttrService: @"com.clearcam.session",
(__bridge id)kSecAttrAccount: @"sessionToken"
};
- SecItemDelete((__bridge CFDictionaryRef)query);}
+ SecItemDelete((__bridge CFDictionaryRef)query);
+}
// Optional: Retrieve the session token if needed later
- (NSString *)retrieveSessionTokenFromKeychain {