RCNConfigFetch.h 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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. #import "FirebaseRemoteConfig/Sources/Public/FirebaseRemoteConfig/FIRRemoteConfig.h"
  18. #import "Interop/Analytics/Public/FIRAnalyticsInterop.h"
  19. @class FIROptions;
  20. @class RCNConfigContent;
  21. @class RCNConfigSettings;
  22. @class RCNConfigExperiment;
  23. @class RCNConfigDBManager;
  24. NS_ASSUME_NONNULL_BEGIN
  25. /// Completion handler invoked by NSSessionFetcher.
  26. typedef void (^RCNConfigFetcherCompletion)(NSData *data, NSURLResponse *response, NSError *error);
  27. /// Completion handler invoked after a fetch that contains the updated keys
  28. typedef void (^RCNConfigFetchCompletion)(FIRRemoteConfigFetchStatus status,
  29. FIRRemoteConfigUpdate *update,
  30. NSError *error);
  31. @interface RCNConfigFetch : NSObject
  32. - (instancetype)init NS_UNAVAILABLE;
  33. /// Designated initializer
  34. - (instancetype)initWithContent:(RCNConfigContent *)content
  35. DBManager:(RCNConfigDBManager *)DBManager
  36. settings:(RCNConfigSettings *)settings
  37. analytics:(nullable id<FIRAnalyticsInterop>)analytics
  38. experiment:(nullable RCNConfigExperiment *)experiment
  39. queue:(dispatch_queue_t)queue
  40. namespace:(NSString *)firebaseNamespace
  41. options:(FIROptions *)firebaseOptions NS_DESIGNATED_INITIALIZER;
  42. /// Fetches config data keyed by namespace. Completion block will be called on the main queue.
  43. /// @param expirationDuration Expiration duration, in seconds.
  44. /// @param completionHandler Callback handler.
  45. - (void)fetchConfigWithExpirationDuration:(NSTimeInterval)expirationDuration
  46. completionHandler:(FIRRemoteConfigFetchCompletion)completionHandler;
  47. /// Fetches config data immediately, keyed by namespace. Completion block will be called on the main
  48. /// queue.
  49. /// @param fetchAttemptNumber The number of the fetch attempt.
  50. /// @param completionHandler Callback handler.
  51. - (void)realtimeFetchConfigWithNoExpirationDuration:(NSInteger)fetchAttemptNumber
  52. completionHandler:(RCNConfigFetchCompletion)completionHandler;
  53. /// Add the ability to update NSURLSession's timeout after a session has already been created.
  54. - (void)recreateNetworkSession;
  55. /// Provide fetchSession for tests to override.
  56. @property(nonatomic, readwrite, strong, nonnull) NSURLSession *fetchSession;
  57. /// Provide config template version number for Realtime config client.
  58. @property(nonatomic, copy, nonnull) NSString *templateVersionNumber;
  59. NS_ASSUME_NONNULL_END
  60. @end