RCNConfigContent.h 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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. typedef NS_ENUM(NSInteger, RCNDBSource) {
  19. RCNDBSourceActive,
  20. RCNDBSourceDefault,
  21. RCNDBSourceFetched,
  22. };
  23. @class RCNConfigDBManager;
  24. /// This class handles all the config content that is fetched from the server, cached in local
  25. /// config or persisted in database.
  26. @interface RCNConfigContent : NSObject
  27. /// Shared Singleton Instance
  28. + (instancetype)sharedInstance;
  29. /// Fetched config (aka pending config) data that is latest data from server that might or might
  30. /// not be applied.
  31. @property(nonatomic, readonly, copy) NSDictionary *fetchedConfig;
  32. /// Active config that is available to external users;
  33. @property(nonatomic, readonly, copy) NSDictionary *activeConfig;
  34. /// Local default config that is provided by external users;
  35. @property(nonatomic, readonly, copy) NSDictionary *defaultConfig;
  36. - (instancetype)init NS_UNAVAILABLE;
  37. /// Designated initializer;
  38. - (instancetype)initWithDBManager:(RCNConfigDBManager *)DBManager NS_DESIGNATED_INITIALIZER;
  39. /// Returns true if initialization succeeded.
  40. - (BOOL)initializationSuccessful;
  41. /// Update config content from fetch response in JSON format.
  42. - (void)updateConfigContentWithResponse:(NSDictionary *)response
  43. forNamespace:(NSString *)FIRNamespace;
  44. /// Copy from a given dictionary to one of the data source.
  45. /// @param fromDictionary The data to copy from.
  46. /// @param source The data source to copy to(pending/active/default).
  47. - (void)copyFromDictionary:(NSDictionary *)fromDictionary
  48. toSource:(RCNDBSource)source
  49. forNamespace:(NSString *)FIRNamespace;
  50. /// Sets the fetched Personalization metadata to active.
  51. - (void)activatePersonalization;
  52. /// Gets the active config and Personalization metadata.
  53. - (NSDictionary *)getConfigAndMetadataForNamespace:(NSString *)FIRNamespace;
  54. /// Returns the updated parameters between fetched and active config.
  55. - (FIRRemoteConfigUpdate *)getConfigUpdateForNamespace:(NSString *)FIRNamespace
  56. withExperimentChanges:
  57. (NSMutableSet<NSString *> *)changedExperimentKeys;
  58. @end