Skip to content

Commit 85b7050

Browse files
authored
[App Distribution] Add isExpired to FIRAppDistributionRelease (#6282)
1 parent 130d76a commit 85b7050

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

FirebaseAppDistribution/Sources/FIRAppDistributionRelease.m

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,13 @@ @interface FIRAppDistributionRelease ()
1919
@property(nonatomic, copy) NSString *buildVersion;
2020
@property(nonatomic, copy) NSString *releaseNotes;
2121
@property(nonatomic, strong) NSURL *downloadURL;
22+
@property(nonatomic) NSDate *expirationTime;
2223
@end
2324

2425
@implementation FIRAppDistributionRelease
26+
27+
static const NSTimeInterval kDownloadUrlTimeToLive = 59 * 60; // 59 minutes
28+
2529
- (instancetype)initWithDictionary:(NSDictionary *)dict {
2630
self = [super init];
2731
if (self) {
@@ -30,7 +34,12 @@ - (instancetype)initWithDictionary:(NSDictionary *)dict {
3034

3135
self.downloadURL = [[NSURL alloc] initWithString:[dict objectForKey:@"downloadUrl"]];
3236
self.releaseNotes = [dict objectForKey:@"releaseNotes"];
37+
self.expirationTime = [NSDate dateWithTimeIntervalSinceNow:kDownloadUrlTimeToLive];
3338
}
3439
return self;
3540
}
41+
42+
- (BOOL)isExpired {
43+
return [[NSDate date] compare:_expirationTime] == NSOrderedDescending;
44+
}
3645
@end

FirebaseAppDistribution/Sources/Public/FIRAppDistributionRelease.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ NS_SWIFT_NAME(AppDistributionRelease)
3535
// The URL for the build
3636
@property(nonatomic, strong, readonly) NSURL *downloadURL;
3737

38+
// Whether the download URL for this release is expired
39+
@property(nonatomic, readonly) BOOL isExpired;
40+
3841
/** :nodoc: */
3942
- (instancetype)init NS_UNAVAILABLE;
4043

0 commit comments

Comments
 (0)