RCNUserDefaultsManager.h 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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 <Foundation/Foundation.h>
  17. NS_ASSUME_NONNULL_BEGIN
  18. @interface RCNUserDefaultsManager : NSObject
  19. /// The last eTag received from the backend.
  20. @property(nonatomic, assign) NSString *lastETag;
  21. /// The time of the last eTag update.
  22. @property(nonatomic, assign) NSTimeInterval lastETagUpdateTime;
  23. /// The time of the last successful fetch.
  24. @property(nonatomic, assign) NSTimeInterval lastFetchTime;
  25. /// The time of the last successful fetch.
  26. @property(nonatomic, assign) NSString *lastFetchStatus;
  27. /// Boolean indicating if the last (one or more) fetch(es) was/were unsuccessful, in which case we
  28. /// are in an exponential backoff mode.
  29. @property(nonatomic, assign) BOOL isClientThrottledWithExponentialBackoff;
  30. /// Time when the next request can be made while being throttled.
  31. @property(nonatomic, assign) NSTimeInterval throttleEndTime;
  32. /// The retry interval increases exponentially for cumulative fetch failures. Refer to
  33. /// go/rc-client-throttling for details.
  34. @property(nonatomic, assign) NSTimeInterval currentThrottlingRetryIntervalSeconds;
  35. /// Time when the next request can be made while being throttled.
  36. @property(nonatomic, assign) NSTimeInterval realtimeThrottleEndTime;
  37. /// The retry interval increases exponentially for cumulative Realtime failures. Refer to
  38. /// go/rc-client-throttling for details.
  39. @property(nonatomic, assign) NSTimeInterval currentRealtimeThrottlingRetryIntervalSeconds;
  40. /// Realtime retry count.
  41. @property(nonatomic, assign) int realtimeRetryCount;
  42. /// Last fetched template version.
  43. @property(nonatomic, assign) NSString *lastFetchedTemplateVersion;
  44. /// Last active template version.
  45. @property(nonatomic, assign) NSString *lastActiveTemplateVersion;
  46. /// A dictionary to hold the latest custom signals set by the developer.
  47. @property(nonatomic, readwrite, strong) NSDictionary<NSString *, NSString *> *customSignals;
  48. /// Designated initializer.
  49. - (instancetype)initWithAppName:(NSString *)appName
  50. bundleID:(NSString *)bundleIdentifier
  51. namespace:(NSString *)firebaseNamespace NS_DESIGNATED_INITIALIZER;
  52. // NOLINTBEGIN
  53. /// Use `initWithAppName:bundleID:namespace:` instead.
  54. - (instancetype)init
  55. __attribute__((unavailable("Use `initWithAppName:bundleID:namespace:` instead.")));
  56. // NOLINTEND
  57. /// Delete all saved userdefaults for this instance.
  58. - (void)resetUserDefaults;
  59. @end
  60. NS_ASSUME_NONNULL_END