RCNConfigFetch.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. @interface RCNConfigFetch : NSObject
  28. - (instancetype)init NS_UNAVAILABLE;
  29. /// Designated initializer
  30. - (instancetype)initWithContent:(RCNConfigContent *)content
  31. DBManager:(RCNConfigDBManager *)DBManager
  32. settings:(RCNConfigSettings *)settings
  33. analytics:(nullable id<FIRAnalyticsInterop>)analytics
  34. experiment:(nullable RCNConfigExperiment *)experiment
  35. queue:(dispatch_queue_t)queue
  36. namespace:(NSString *)firebaseNamespace
  37. options:(FIROptions *)firebaseOptions NS_DESIGNATED_INITIALIZER;
  38. /// Fetches config data keyed by namespace. Completion block will be called on the main queue.
  39. /// @param expirationDuration Expiration duration, in seconds.
  40. /// @param completionHandler Callback handler.
  41. - (void)fetchConfigWithExpirationDuration:(NSTimeInterval)expirationDuration
  42. completionHandler:(FIRRemoteConfigFetchCompletion)completionHandler;
  43. /// Add the ability to update NSURLSession's timeout after a session has already been created.
  44. - (void)recreateNetworkSession;
  45. /// Provide fetchSession for tests to override.
  46. @property(nonatomic, readwrite, strong, nonnull) NSURLSession *fetchSession;
  47. NS_ASSUME_NONNULL_END
  48. @end