RCNConfigFetch.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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 <FirebaseAnalyticsInterop/FIRAnalyticsInterop.h>
  18. #import <FirebaseRemoteConfig/FIRRemoteConfig.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. /// Test block used for global NSSessionFetcher.
  28. typedef void (^RCNConfigFetcherTestBlock)(RCNConfigFetcherCompletion completion);
  29. @interface RCNConfigFetch : NSObject
  30. - (instancetype)init NS_UNAVAILABLE;
  31. /// Designated initializer
  32. - (instancetype)initWithContent:(RCNConfigContent *)content
  33. DBManager:(RCNConfigDBManager *)DBManager
  34. settings:(RCNConfigSettings *)settings
  35. analytics:(nullable id<FIRAnalyticsInterop>)analytics
  36. experiment:(nullable RCNConfigExperiment *)experiment
  37. queue:(dispatch_queue_t)queue
  38. namespace:(NSString *)firebaseNamespace
  39. options:(FIROptions *)firebaseOptions NS_DESIGNATED_INITIALIZER;
  40. /// Fetches all config data keyed by namespace. Completion block will be called on the main queue.
  41. /// @param expirationDuration Expiration duration, in seconds.
  42. /// @param completionHandler Callback handler.
  43. - (void)fetchAllConfigsWithExpirationDuration:(NSTimeInterval)expirationDuration
  44. completionHandler:(FIRRemoteConfigFetchCompletion)completionHandler;
  45. /// Add the ability to update NSURLSession's timeout after a session has already been created.
  46. - (void)recreateNetworkSession;
  47. /// Sets the test block to mock the fetch response instead of performing the fetch task from server.
  48. + (void)setGlobalTestBlock:(RCNConfigFetcherTestBlock)block;
  49. NS_ASSUME_NONNULL_END
  50. @end