FIRAppDistributionRelease.m 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. // Copyright 2020 Google LLC
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. #import "FirebaseAppDistribution/Sources/Private/FIRAppDistributionRelease.h"
  15. @interface FIRAppDistributionRelease ()
  16. @property(nonatomic, copy) NSString *displayVersion;
  17. @property(nonatomic, copy) NSString *buildVersion;
  18. @property(nonatomic, copy) NSString *releaseNotes;
  19. @property(nonatomic, strong) NSURL *downloadURL;
  20. @property(nonatomic) NSDate *expirationTime;
  21. @end
  22. @implementation FIRAppDistributionRelease
  23. static const NSTimeInterval kDownloadUrlTimeToLive = 59 * 60; // 59 minutes
  24. - (instancetype)initWithDictionary:(NSDictionary *)dict {
  25. self = [super init];
  26. if (self) {
  27. self.buildVersion = [dict objectForKey:@"buildVersion"];
  28. self.displayVersion = [dict objectForKey:@"displayVersion"];
  29. self.downloadURL = [[NSURL alloc] initWithString:[dict objectForKey:@"downloadUrl"]];
  30. self.releaseNotes = [dict objectForKey:@"releaseNotes"];
  31. self.expirationTime = [NSDate dateWithTimeIntervalSinceNow:kDownloadUrlTimeToLive];
  32. }
  33. return self;
  34. }
  35. - (BOOL)isExpired {
  36. return [[NSDate date] compare:_expirationTime] == NSOrderedDescending;
  37. }
  38. @end