RCNConfigSettings.m 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483
  1. /*
  2. * Copyright 2019 Google
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #import "FirebaseRemoteConfig/Sources/Private/RCNConfigSettings.h"
  17. #import "FirebaseRemoteConfig/Sources/RCNConfigConstants.h"
  18. #import "FirebaseRemoteConfig/Sources/RCNConfigDBManager.h"
  19. #import "FirebaseRemoteConfig/Sources/RCNConfigValue_Internal.h"
  20. #import "FirebaseRemoteConfig/Sources/RCNDevice.h"
  21. #import "FirebaseRemoteConfig/Sources/RCNUserDefaultsManager.h"
  22. #import <GoogleUtilities/GULAppEnvironmentUtil.h>
  23. #import "FirebaseCore/Extension/FirebaseCoreInternal.h"
  24. static NSString *const kRCNGroupPrefix = @"frc.group.";
  25. static NSString *const kRCNUserDefaultsKeyNamelastETag = @"lastETag";
  26. static NSString *const kRCNUserDefaultsKeyNameLastSuccessfulFetchTime = @"lastSuccessfulFetchTime";
  27. static NSString *const kRCNAnalyticsFirstOpenTimePropertyName = @"_fot";
  28. static const int kRCNExponentialBackoffMinimumInterval = 60 * 2; // 2 mins.
  29. static const int kRCNExponentialBackoffMaximumInterval = 60 * 60 * 4; // 4 hours.
  30. @interface RCNConfigSettings () {
  31. /// A list of successful fetch timestamps in seconds.
  32. NSMutableArray *_successFetchTimes;
  33. /// A list of failed fetch timestamps in seconds.
  34. NSMutableArray *_failureFetchTimes;
  35. /// Device conditions since last successful fetch from the backend. Device conditions including
  36. /// app
  37. /// version, iOS version, device localte, language, GMP project ID and Game project ID. Used for
  38. /// determing whether to throttle.
  39. NSMutableDictionary *_deviceContext;
  40. /// Custom variables (aka App context digest). This is the pending custom variables request before
  41. /// fetching.
  42. NSMutableDictionary *_customVariables;
  43. /// Cached internal metadata from internal metadata table. It contains customized information such
  44. /// as HTTP connection timeout, HTTP read timeout, success/failure throttling rate and time
  45. /// interval. Client has the default value of each parameters, they are only saved in
  46. /// internalMetadata if they have been customize by developers.
  47. NSMutableDictionary *_internalMetadata;
  48. /// Last fetch status.
  49. FIRRemoteConfigFetchStatus _lastFetchStatus;
  50. /// Last fetch Error.
  51. FIRRemoteConfigError _lastFetchError;
  52. /// The time of last apply timestamp.
  53. NSTimeInterval _lastApplyTimeInterval;
  54. /// The time of last setDefaults timestamp.
  55. NSTimeInterval _lastSetDefaultsTimeInterval;
  56. /// The database manager.
  57. RCNConfigDBManager *_DBManager;
  58. // The namespace for this instance.
  59. NSString *_FIRNamespace;
  60. // The Google App ID of the configured FIRApp.
  61. NSString *_googleAppID;
  62. /// The user defaults manager scoped to this RC instance of FIRApp and namespace.
  63. RCNUserDefaultsManager *_userDefaultsManager;
  64. /// The timestamp of last eTag update.
  65. NSTimeInterval _lastETagUpdateTime;
  66. }
  67. @end
  68. @implementation RCNConfigSettings
  69. - (instancetype)initWithDatabaseManager:(RCNConfigDBManager *)manager
  70. namespace:(NSString *)FIRNamespace
  71. firebaseAppName:(NSString *)appName
  72. googleAppID:(NSString *)googleAppID {
  73. self = [super init];
  74. if (self) {
  75. _FIRNamespace = FIRNamespace;
  76. _googleAppID = googleAppID;
  77. _bundleIdentifier = [[NSBundle mainBundle] bundleIdentifier];
  78. if (!_bundleIdentifier) {
  79. FIRLogNotice(kFIRLoggerRemoteConfig, @"I-RCN000038",
  80. @"Main bundle identifier is missing. Remote Config might not work properly.");
  81. _bundleIdentifier = @"";
  82. }
  83. _minimumFetchInterval = RCNDefaultMinimumFetchInterval;
  84. _deviceContext = [[NSMutableDictionary alloc] init];
  85. _customVariables = [[NSMutableDictionary alloc] init];
  86. _successFetchTimes = [[NSMutableArray alloc] init];
  87. _failureFetchTimes = [[NSMutableArray alloc] init];
  88. _DBManager = manager;
  89. _internalMetadata = [[_DBManager loadInternalMetadataTable] mutableCopy];
  90. if (!_internalMetadata) {
  91. _internalMetadata = [[NSMutableDictionary alloc] init];
  92. }
  93. _userDefaultsManager = [[RCNUserDefaultsManager alloc] initWithAppName:appName
  94. bundleID:_bundleIdentifier
  95. namespace:_FIRNamespace];
  96. // Check if the config database is new. If so, clear the configs saved in userDefaults.
  97. if ([_DBManager isNewDatabase]) {
  98. FIRLogNotice(kFIRLoggerRemoteConfig, @"I-RCN000072",
  99. @"New config database created. Resetting user defaults.");
  100. [_userDefaultsManager resetUserDefaults];
  101. }
  102. _isFetchInProgress = NO;
  103. _lastTemplateVersion = [_userDefaultsManager lastTemplateVersion];
  104. }
  105. return self;
  106. }
  107. #pragma mark - read from / update userDefaults
  108. - (NSString *)lastETag {
  109. return [_userDefaultsManager lastETag];
  110. }
  111. - (void)setLastETag:(NSString *)lastETag {
  112. [self setLastETagUpdateTime:[[NSDate date] timeIntervalSince1970]];
  113. [_userDefaultsManager setLastETag:lastETag];
  114. }
  115. - (void)setLastETagUpdateTime:(NSTimeInterval)lastETagUpdateTime {
  116. [_userDefaultsManager setLastETagUpdateTime:lastETagUpdateTime];
  117. }
  118. - (NSTimeInterval)lastFetchTimeInterval {
  119. return _userDefaultsManager.lastFetchTime;
  120. }
  121. - (NSTimeInterval)lastETagUpdateTime {
  122. return _userDefaultsManager.lastETagUpdateTime;
  123. }
  124. // TODO: Update logic for app extensions as required.
  125. - (void)updateLastFetchTimeInterval:(NSTimeInterval)lastFetchTimeInterval {
  126. _userDefaultsManager.lastFetchTime = lastFetchTimeInterval;
  127. }
  128. #pragma mark - load from DB
  129. - (NSDictionary *)loadConfigFromMetadataTable {
  130. NSDictionary *metadata = [[_DBManager loadMetadataWithBundleIdentifier:_bundleIdentifier
  131. namespace:_FIRNamespace] copy];
  132. if (metadata) {
  133. // TODO: Remove (all metadata in general) once ready to
  134. // migrate to user defaults completely.
  135. if (metadata[RCNKeyDeviceContext]) {
  136. self->_deviceContext = [metadata[RCNKeyDeviceContext] mutableCopy];
  137. }
  138. if (metadata[RCNKeyAppContext]) {
  139. self->_customVariables = [metadata[RCNKeyAppContext] mutableCopy];
  140. }
  141. if (metadata[RCNKeySuccessFetchTime]) {
  142. self->_successFetchTimes = [metadata[RCNKeySuccessFetchTime] mutableCopy];
  143. }
  144. if (metadata[RCNKeyFailureFetchTime]) {
  145. self->_failureFetchTimes = [metadata[RCNKeyFailureFetchTime] mutableCopy];
  146. }
  147. if (metadata[RCNKeyLastFetchStatus]) {
  148. self->_lastFetchStatus =
  149. (FIRRemoteConfigFetchStatus)[metadata[RCNKeyLastFetchStatus] intValue];
  150. }
  151. if (metadata[RCNKeyLastFetchError]) {
  152. self->_lastFetchError = (FIRRemoteConfigError)[metadata[RCNKeyLastFetchError] intValue];
  153. }
  154. if (metadata[RCNKeyLastApplyTime]) {
  155. self->_lastApplyTimeInterval = [metadata[RCNKeyLastApplyTime] doubleValue];
  156. }
  157. if (metadata[RCNKeyLastFetchStatus]) {
  158. self->_lastSetDefaultsTimeInterval = [metadata[RCNKeyLastSetDefaultsTime] doubleValue];
  159. }
  160. }
  161. return metadata;
  162. }
  163. #pragma mark - update DB/cached
  164. // Update internal metadata content to cache and DB.
  165. - (void)updateInternalContentWithResponse:(NSDictionary *)response {
  166. // Remove all the keys with current pakcage name.
  167. [_DBManager deleteRecordWithBundleIdentifier:_bundleIdentifier
  168. namespace:_FIRNamespace
  169. isInternalDB:YES];
  170. for (NSString *key in _internalMetadata.allKeys) {
  171. if ([key hasPrefix:_bundleIdentifier]) {
  172. [_internalMetadata removeObjectForKey:key];
  173. }
  174. }
  175. for (NSString *entry in response) {
  176. NSData *val = [response[entry] dataUsingEncoding:NSUTF8StringEncoding];
  177. NSArray *values = @[ entry, val ];
  178. _internalMetadata[entry] = response[entry];
  179. [self updateInternalMetadataTableWithValues:values];
  180. }
  181. }
  182. - (void)updateInternalMetadataTableWithValues:(NSArray *)values {
  183. [_DBManager insertInternalMetadataTableWithValues:values completionHandler:nil];
  184. }
  185. /// If the last fetch was not successful, update the (exponential backoff) period that we wait until
  186. /// fetching again. Any subsequent fetch requests will be checked and allowed only if past this
  187. /// throttle end time.
  188. - (void)updateExponentialBackoffTime {
  189. // If not in exponential backoff mode, reset the retry interval.
  190. if (_lastFetchStatus == FIRRemoteConfigFetchStatusSuccess) {
  191. FIRLogDebug(kFIRLoggerRemoteConfig, @"I-RCN000057",
  192. @"Throttling: Entering exponential backoff mode.");
  193. _exponentialBackoffRetryInterval = kRCNExponentialBackoffMinimumInterval;
  194. } else {
  195. FIRLogDebug(kFIRLoggerRemoteConfig, @"I-RCN000057",
  196. @"Throttling: Updating throttling interval.");
  197. // Double the retry interval until we hit the truncated exponential backoff. More info here:
  198. // https://cloud.google.com/storage/docs/exponential-backoff
  199. _exponentialBackoffRetryInterval =
  200. ((_exponentialBackoffRetryInterval * 2) < kRCNExponentialBackoffMaximumInterval)
  201. ? _exponentialBackoffRetryInterval * 2
  202. : _exponentialBackoffRetryInterval;
  203. }
  204. // Randomize the next retry interval.
  205. int randomPlusMinusInterval = ((arc4random() % 2) == 0) ? -1 : 1;
  206. NSTimeInterval randomizedRetryInterval =
  207. _exponentialBackoffRetryInterval +
  208. (0.5 * _exponentialBackoffRetryInterval * randomPlusMinusInterval);
  209. _exponentialBackoffThrottleEndTime =
  210. [[NSDate date] timeIntervalSince1970] + randomizedRetryInterval;
  211. }
  212. - (void)updateMetadataWithFetchSuccessStatus:(BOOL)fetchSuccess
  213. templateVersion:(NSString *)templateVersion {
  214. FIRLogDebug(kFIRLoggerRemoteConfig, @"I-RCN000056", @"Updating metadata with fetch result.");
  215. [self updateFetchTimeWithSuccessFetch:fetchSuccess];
  216. _lastFetchStatus =
  217. fetchSuccess ? FIRRemoteConfigFetchStatusSuccess : FIRRemoteConfigFetchStatusFailure;
  218. _lastFetchError = fetchSuccess ? FIRRemoteConfigErrorUnknown : FIRRemoteConfigErrorInternalError;
  219. if (fetchSuccess) {
  220. [self updateLastFetchTimeInterval:[[NSDate date] timeIntervalSince1970]];
  221. // Note: We expect the googleAppID to always be available.
  222. _deviceContext = FIRRemoteConfigDeviceContextWithProjectIdentifier(_googleAppID);
  223. [_userDefaultsManager setLastTemplateVersion:templateVersion];
  224. }
  225. [self updateMetadataTable];
  226. }
  227. - (void)updateFetchTimeWithSuccessFetch:(BOOL)isSuccessfulFetch {
  228. NSTimeInterval epochTimeInterval = [[NSDate date] timeIntervalSince1970];
  229. if (isSuccessfulFetch) {
  230. [_successFetchTimes addObject:@(epochTimeInterval)];
  231. } else {
  232. [_failureFetchTimes addObject:@(epochTimeInterval)];
  233. }
  234. }
  235. - (void)updateMetadataTable {
  236. [_DBManager deleteRecordWithBundleIdentifier:_bundleIdentifier
  237. namespace:_FIRNamespace
  238. isInternalDB:NO];
  239. NSError *error;
  240. // Objects to be serialized cannot be invalid.
  241. if (!_bundleIdentifier) {
  242. return;
  243. }
  244. if (![NSJSONSerialization isValidJSONObject:_customVariables]) {
  245. FIRLogError(kFIRLoggerRemoteConfig, @"I-RCN000028",
  246. @"Invalid custom variables to be serialized.");
  247. return;
  248. }
  249. if (![NSJSONSerialization isValidJSONObject:_deviceContext]) {
  250. FIRLogError(kFIRLoggerRemoteConfig, @"I-RCN000029",
  251. @"Invalid device context to be serialized.");
  252. return;
  253. }
  254. if (![NSJSONSerialization isValidJSONObject:_successFetchTimes]) {
  255. FIRLogError(kFIRLoggerRemoteConfig, @"I-RCN000031",
  256. @"Invalid success fetch times to be serialized.");
  257. return;
  258. }
  259. if (![NSJSONSerialization isValidJSONObject:_failureFetchTimes]) {
  260. FIRLogError(kFIRLoggerRemoteConfig, @"I-RCN000032",
  261. @"Invalid failure fetch times to be serialized.");
  262. return;
  263. }
  264. NSData *serializedAppContext = [NSJSONSerialization dataWithJSONObject:_customVariables
  265. options:NSJSONWritingPrettyPrinted
  266. error:&error];
  267. NSData *serializedDeviceContext =
  268. [NSJSONSerialization dataWithJSONObject:_deviceContext
  269. options:NSJSONWritingPrettyPrinted
  270. error:&error];
  271. // The digestPerNamespace is not used and only meant for backwards DB compatibility.
  272. NSData *serializedDigestPerNamespace =
  273. [NSJSONSerialization dataWithJSONObject:@{} options:NSJSONWritingPrettyPrinted error:&error];
  274. NSData *serializedSuccessTime = [NSJSONSerialization dataWithJSONObject:_successFetchTimes
  275. options:NSJSONWritingPrettyPrinted
  276. error:&error];
  277. NSData *serializedFailureTime = [NSJSONSerialization dataWithJSONObject:_failureFetchTimes
  278. options:NSJSONWritingPrettyPrinted
  279. error:&error];
  280. if (!serializedDigestPerNamespace || !serializedDeviceContext || !serializedAppContext ||
  281. !serializedSuccessTime || !serializedFailureTime) {
  282. return;
  283. }
  284. NSDictionary *columnNameToValue = @{
  285. RCNKeyBundleIdentifier : _bundleIdentifier,
  286. RCNKeyNamespace : _FIRNamespace,
  287. RCNKeyFetchTime : @(self.lastFetchTimeInterval),
  288. RCNKeyDigestPerNamespace : serializedDigestPerNamespace,
  289. RCNKeyDeviceContext : serializedDeviceContext,
  290. RCNKeyAppContext : serializedAppContext,
  291. RCNKeySuccessFetchTime : serializedSuccessTime,
  292. RCNKeyFailureFetchTime : serializedFailureTime,
  293. RCNKeyLastFetchStatus : [NSString stringWithFormat:@"%ld", (long)_lastFetchStatus],
  294. RCNKeyLastFetchError : [NSString stringWithFormat:@"%ld", (long)_lastFetchError],
  295. RCNKeyLastApplyTime : @(_lastApplyTimeInterval),
  296. RCNKeyLastSetDefaultsTime : @(_lastSetDefaultsTimeInterval)
  297. };
  298. [_DBManager insertMetadataTableWithValues:columnNameToValue completionHandler:nil];
  299. }
  300. #pragma mark - fetch request
  301. /// Returns a fetch request with the latest device and config change.
  302. /// Whenever user issues a fetch api call, collect the latest request.
  303. - (NSString *)nextRequestWithUserProperties:(NSDictionary *)userProperties {
  304. // Note: We only set user properties as mentioned in the new REST API Design doc
  305. NSString *ret = [NSString stringWithFormat:@"{"];
  306. ret = [ret stringByAppendingString:[NSString stringWithFormat:@"app_instance_id:'%@'",
  307. _configInstallationsIdentifier]];
  308. ret = [ret stringByAppendingString:[NSString stringWithFormat:@", app_instance_id_token:'%@'",
  309. _configInstallationsToken]];
  310. ret = [ret stringByAppendingString:[NSString stringWithFormat:@", app_id:'%@'", _googleAppID]];
  311. ret = [ret stringByAppendingString:[NSString stringWithFormat:@", country_code:'%@'",
  312. FIRRemoteConfigDeviceCountry()]];
  313. ret = [ret stringByAppendingString:[NSString stringWithFormat:@", language_code:'%@'",
  314. FIRRemoteConfigDeviceLocale()]];
  315. ret = [ret
  316. stringByAppendingString:[NSString stringWithFormat:@", platform_version:'%@'",
  317. [GULAppEnvironmentUtil systemVersion]]];
  318. ret = [ret stringByAppendingString:[NSString stringWithFormat:@", time_zone:'%@'",
  319. FIRRemoteConfigTimezone()]];
  320. ret = [ret stringByAppendingString:[NSString stringWithFormat:@", package_name:'%@'",
  321. _bundleIdentifier]];
  322. ret = [ret stringByAppendingString:[NSString stringWithFormat:@", app_version:'%@'",
  323. FIRRemoteConfigAppVersion()]];
  324. ret = [ret stringByAppendingString:[NSString stringWithFormat:@", app_build:'%@'",
  325. FIRRemoteConfigAppBuildVersion()]];
  326. ret = [ret stringByAppendingString:[NSString stringWithFormat:@", sdk_version:'%@'",
  327. FIRRemoteConfigPodVersion()]];
  328. if (userProperties && userProperties.count > 0) {
  329. NSError *error;
  330. // Extract first open time from user properties and send as a separate field
  331. NSNumber *firstOpenTime = userProperties[kRCNAnalyticsFirstOpenTimePropertyName];
  332. NSMutableDictionary *remainingUserProperties = [userProperties mutableCopy];
  333. if (firstOpenTime != nil) {
  334. NSDate *date = [NSDate dateWithTimeIntervalSince1970:([firstOpenTime longValue] / 1000)];
  335. NSISO8601DateFormatter *formatter = [[NSISO8601DateFormatter alloc] init];
  336. NSString *firstOpenTimeISOString = [formatter stringFromDate:date];
  337. ret = [ret stringByAppendingString:[NSString stringWithFormat:@", first_open_time:'%@'",
  338. firstOpenTimeISOString]];
  339. [remainingUserProperties removeObjectForKey:kRCNAnalyticsFirstOpenTimePropertyName];
  340. }
  341. if (remainingUserProperties.count > 0) {
  342. NSData *jsonData = [NSJSONSerialization dataWithJSONObject:remainingUserProperties
  343. options:0
  344. error:&error];
  345. if (!error) {
  346. ret = [ret
  347. stringByAppendingString:[NSString
  348. stringWithFormat:@", analytics_user_properties:%@",
  349. [[NSString alloc]
  350. initWithData:jsonData
  351. encoding:NSUTF8StringEncoding]]];
  352. }
  353. }
  354. }
  355. ret = [ret stringByAppendingString:@"}"];
  356. return ret;
  357. }
  358. #pragma mark - getter/setter
  359. - (void)setLastFetchError:(FIRRemoteConfigError)lastFetchError {
  360. if (_lastFetchError != lastFetchError) {
  361. _lastFetchError = lastFetchError;
  362. [_DBManager updateMetadataWithOption:RCNUpdateOptionFetchStatus
  363. namespace:_FIRNamespace
  364. values:@[ @(_lastFetchStatus), @(_lastFetchError) ]
  365. completionHandler:nil];
  366. }
  367. }
  368. - (NSArray *)successFetchTimes {
  369. return [_successFetchTimes copy];
  370. }
  371. - (NSArray *)failureFetchTimes {
  372. return [_failureFetchTimes copy];
  373. }
  374. - (NSDictionary *)customVariables {
  375. return [_customVariables copy];
  376. }
  377. - (NSDictionary *)internalMetadata {
  378. return [_internalMetadata copy];
  379. }
  380. - (NSDictionary *)deviceContext {
  381. return [_deviceContext copy];
  382. }
  383. - (void)setCustomVariables:(NSDictionary *)customVariables {
  384. _customVariables = [[NSMutableDictionary alloc] initWithDictionary:customVariables];
  385. [self updateMetadataTable];
  386. }
  387. - (void)setMinimumFetchInterval:(NSTimeInterval)minimumFetchInterval {
  388. if (minimumFetchInterval < 0) {
  389. _minimumFetchInterval = 0;
  390. } else {
  391. _minimumFetchInterval = minimumFetchInterval;
  392. }
  393. }
  394. - (void)setFetchTimeout:(NSTimeInterval)fetchTimeout {
  395. if (fetchTimeout <= 0) {
  396. _fetchTimeout = RCNHTTPDefaultConnectionTimeout;
  397. } else {
  398. _fetchTimeout = fetchTimeout;
  399. }
  400. }
  401. - (void)setLastApplyTimeInterval:(NSTimeInterval)lastApplyTimestamp {
  402. _lastApplyTimeInterval = lastApplyTimestamp;
  403. [_DBManager updateMetadataWithOption:RCNUpdateOptionApplyTime
  404. namespace:_FIRNamespace
  405. values:@[ @(lastApplyTimestamp) ]
  406. completionHandler:nil];
  407. }
  408. - (void)setLastSetDefaultsTimeInterval:(NSTimeInterval)lastSetDefaultsTimestamp {
  409. _lastSetDefaultsTimeInterval = lastSetDefaultsTimestamp;
  410. [_DBManager updateMetadataWithOption:RCNUpdateOptionDefaultTime
  411. namespace:_FIRNamespace
  412. values:@[ @(lastSetDefaultsTimestamp) ]
  413. completionHandler:nil];
  414. }
  415. #pragma mark Throttling
  416. - (BOOL)hasMinimumFetchIntervalElapsed:(NSTimeInterval)minimumFetchInterval {
  417. if (self.lastFetchTimeInterval == 0) return YES;
  418. // Check if last config fetch is within minimum fetch interval in seconds.
  419. NSTimeInterval diffInSeconds = [[NSDate date] timeIntervalSince1970] - self.lastFetchTimeInterval;
  420. return diffInSeconds > minimumFetchInterval;
  421. }
  422. - (BOOL)shouldThrottle {
  423. NSTimeInterval now = [[NSDate date] timeIntervalSince1970];
  424. return ((self.lastFetchTimeInterval > 0) &&
  425. (_lastFetchStatus != FIRRemoteConfigFetchStatusSuccess) &&
  426. (_exponentialBackoffThrottleEndTime - now > 0));
  427. }
  428. @end