宽窄优行-由【嘉易行】项目成品而来
younger_times
2023-07-05 0d8f5fc8a516bfd07e425909e4a4432600572ee7
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
//
//  UMRemoteConfig.h
//  myFireBase
//
//  Created by 张军华 on 2019/12/30.
//  Copyright © 2019年 张军华. All rights reserved.
//
 
#import <Foundation/Foundation.h>
#import "UMRemoteConfigEnum.h"
 
NS_ASSUME_NONNULL_BEGIN
 
typedef void (^UMRemoteConfigFetchCompletion)(UMRemoteConfigFetchStatus status,
                                               NSError *_Nullable error);
 
typedef void (^UMRemoteConfigActivateCompletion)(NSError *_Nullable error);
 
@protocol UMRemoteConfigDelegate<NSObject>
 
@optional
/**
 *  @brief 获取服务器的网络请求的回调
 *  @param status see UMRemoteConfigFetchStatus
 *  @param error 错误信息
 *  @param userInfo  该回调的扩展信息
 *  @note  调用函数触发此回调
 *         fetchWithCompletionHandler
 *         fetchAndActivateWithCompletionHandler
 */
-(void)remoteConfigFetched:(UMRemoteConfigFetchStatus)status
                           error:(nullable NSError*)error
                        userInfo:(nullable id)userInfo;
 
 
/**
 *  @brief 远程配置被激活的回调
 *  @param status see UMRemoteConfigActiveStatus
 *  @param error 错误信息
 *  @param userInfo  该回调的扩展信息
 *  @note  调用函数触发此回调
 *         fetchAndActivateWithCompletionHandler
 *         activateWithCompletionHandler
 */
-(void)remoteConfigActivated:(UMRemoteConfigActiveStatus)status
                       error:(nullable NSError*)error
                    userInfo:(nullable id)userInfo;
 
 
/**
 *  @brief 配置已经准备就绪
 *  @param status see UMRemoteConfigActiveStatus
 *  @param error 错误信息
 *  @param userInfo  该回调的扩展信息
 *  @note  调用函数触发此回调
 *         fetchWithCompletionHandler
 */
-(void)remoteConfigReady:(UMRemoteConfigActiveStatus)status
                   error:(nullable NSError*)error
                userInfo:(nullable id)userInfo;
 
@end
 
@class UMRemoteConfigSettings;
@interface UMRemoteConfig : NSObject
 
@property(nonatomic,assign)id<UMRemoteConfigDelegate> remoteConfigDelegate;
@property(nonatomic, readwrite, strong) UMRemoteConfigSettings *configSettings;
 
 
#pragma mark - init
/**
 *  @brief 远程配置单例
 *  @param delegate  see UMRemoteConfigDelegate
 *  @note 用户初始化时候,
    先调用 remoteConfigWithDelegate:(id<UMRemoteConfigDelegate>)delegate,可以保证上次ready的数据可以回调给用户。
 */
+ (UMRemoteConfig *)remoteConfigWithDelegate:(nullable id<UMRemoteConfigDelegate>)delegate
                          withConfigSettings:(nullable UMRemoteConfigSettings*)configSettings;
+ (UMRemoteConfig *)remoteConfig;
#pragma mark - activate
/**
 *  @brief 激活本地配置
 *  @param completionHandler 回调
 */
+ (void)activateWithCompletionHandler:(nullable UMRemoteConfigActivateCompletion)completionHandler;
 
#pragma mark - Get Config
/**
 *  @brief 获取配置信息
 *  @param key 对应的key
 *  @note 获取配置的有限顺利,远程配置->Defaults
 */
+ (nullable id)configValueForKey:(nullable NSString *)key;
 
#pragma mark - Defaults
/**
 *  @brief 设置本地默认配置
 *  @param defaults 对应的本地配置
 */
+ (void)setDefaults:(nullable NSDictionary<NSString *, NSObject *> *)defaults;
 
/**
 *  @brief 设置本地默认配置
 *  @param fileName 包含本地配置的plist文件
 */
+ (void)setDefaultsFromPlistFileName:(nullable NSString *)fileName;
 
 
@end
 
NS_ASSUME_NONNULL_END