Proyectos de Subversion Iphone Microlearning

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 1
// Copyright 2020 Google LLC
2
//
3
// Licensed under the Apache License, Version 2.0 (the "License");
4
// you may not use this file except in compliance with the License.
5
// You may obtain a copy of the License at
6
//
7
//      http://www.apache.org/licenses/LICENSE-2.0
8
//
9
// Unless required by applicable law or agreed to in writing, software
10
// distributed under the License is distributed on an "AS IS" BASIS,
11
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
// See the License for the specific language governing permissions and
13
// limitations under the License.
14
 
15
#import "FirebasePerformance/Sources/Configurations/FPRRemoteConfigFlags.h"
16
 
17
#import "FirebaseRemoteConfig/Sources/Private/FIRRemoteConfig_Private.h"
18
 
19
NS_ASSUME_NONNULL_BEGIN
20
 
21
static NSString *const kFPRConfigPrefix = @"com.fireperf";
22
 
23
/** Interval at which the configurations can be fetched. Specified in seconds. */
24
static NSInteger const kFPRConfigFetchIntervalInSeconds = 12 * 60 * 60;
25
 
26
/** Interval after which the configurations can be fetched. Specified in seconds. */
27
static NSInteger const kFPRMinAppStartConfigFetchDelayInSeconds = 5;
28
 
29
/** This extension should only be used for testing. */
30
@interface FPRRemoteConfigFlags ()
31
 
32
/** @brief Instance of remote config used for firebase performance namespace. */
33
@property(nonatomic) FIRRemoteConfig *fprRemoteConfig;
34
 
35
/** @brief Last activated time of the configurations. */
36
@property(atomic, nullable) NSDate *lastFetchedTime;
37
 
38
/** @brief User defaults used for caching. */
39
@property(nonatomic) NSUserDefaults *userDefaults;
40
 
41
/** @brief Last activated time of the configurations. */
42
@property(nonatomic) NSDate *applicationStartTime;
43
 
44
/** @brief Number of seconds delayed until the first config is made during app start. */
45
@property(nonatomic) NSTimeInterval appStartConfigFetchDelayInSeconds;
46
 
47
/** @brief Status of the last remote config fetch. */
48
@property(nonatomic) FIRRemoteConfigFetchStatus lastFetchStatus;
49
 
50
/**
51
 * Creates an instance of FPRRemoteConfigFlags.
52
 *
53
 * @param config RemoteConfig object to be used for configuration management.
54
 * @return Instance of remote config.
55
 */
56
- (instancetype)initWithRemoteConfig:(FIRRemoteConfig *)config NS_DESIGNATED_INITIALIZER;
57
 
58
#pragma mark - Config fetch methods
59
 
60
/**
61
 * Gets and returns the string value for the provided remote config flag. If there are no values
62
 * returned from remote config, default value will be returned.
63
 * @param flagName Name of the flag for which the value needs to be fetched from RC.
64
 * @param defaultValue Default value that will be returned if no value is fetched from RC.
65
 *
66
 * @return string value for the flag from RC if available. Default value, otherwise.
67
 */
68
- (NSString *)getStringValueForFlag:(NSString *)flagName defaultValue:(NSString *)defaultValue;
69
 
70
/**
71
 * Gets and returns the int value for the provided remote config flag. If there are no values
72
 * returned from remote config, default value will be returned.
73
 * @param flagName Name of the flag for which the value needs to be fetched from RC.
74
 * @param defaultValue Default value that will be returned if no value is fetched from RC.
75
 *
76
 * @return Int value for the flag from RC if available. Default value, otherwise.
77
 */
78
- (int)getIntValueForFlag:(NSString *)flagName defaultValue:(int)defaultValue;
79
 
80
/**
81
 * Gets and returns the float value for the provided remote config flag. If there are no values
82
 * returned from remote config, default value will be returned.
83
 * @param flagName Name of the flag for which the value needs to be fetched from RC.
84
 * @param defaultValue Default value that will be returned if no value is fetched from RC.
85
 *
86
 * @return Float value for the flag from RC if available. Default value, otherwise.
87
 */
88
- (float)getFloatValueForFlag:(NSString *)flagName defaultValue:(float)defaultValue;
89
 
90
/**
91
 * Gets and returns the boolean value for the provided remote config flag. If there are no values
92
 * returned from remote config, default value will be returned.
93
 * @param flagName Name of the flag for which the value needs to be fetched from RC.
94
 * @param defaultValue Default value that will be returned if no value is fetched from RC.
95
 *
96
 * @return Bool value for the flag from RC if available. Default value, otherwise.
97
 */
98
- (BOOL)getBoolValueForFlag:(NSString *)flagName defaultValue:(BOOL)defaultValue;
99
 
100
/**
101
 * Caches the remote config values.
102
 */
103
- (void)cacheConfigValues;
104
 
105
/**
106
 * Reset (Clears) all the remote config keys and values that were cached.
107
 */
108
- (void)resetCache;
109
 
110
@end
111
 
112
NS_ASSUME_NONNULL_END