应用的文案或者运营策略更新经常需要通过发版解决,为了减少开发者频繁更新应用版本,热力引擎推出参数下发功能,通过参数下发可以随时远程调整应用中的参数值实现应用内容更新。
https://solar-sdk.oss-cn-beijing.aliyuncs.com/iOS/SolarEngine-iOS-RC-Plugin-v1.3.0.3.zip
pod 'SESDKRemoteConfig' , '~> 1.3.0.3'
由于参数下发SDK属于热力引擎SDK的一个插件,所以参数下发SDK的初始化是依赖于热力引擎SDK的。开发者可以通过热力引擎SDK的配置方法来控制是否启用参数下发SDK并使用参数下发SDK的相关功能。
方法示例:
#import <SolarEngineSDK/SolarEngineSDK.h>
#import <SESDKRemoteConfig/SESDKRemoteConfig.h>
SEConfig *config = [[SEConfig alloc] init];
SERemoteConfig *remoteConfig = [[SERemoteConfig alloc] init];
remoteConfig.enable = YES;
config.remoteConfig = remoteConfig;
[[SolarEngineSDK sharedInstance] startWithAppKey:your_appKey config:config];
SERemoteConfig参数介绍:
参数名称 | 参数含义 | 参数类型 |
enable | 是否初始化参数下发SDK,默认为false | boolean |
mergeType | 服务端跟SDK配置合并策略(具体含义参考下方解释) | enum |
customIDProperties | 自定义ID,跟用户在后台设置的使用自定义ID匹配 | NSDictionary |
customIDEventProperties | 自定义ID事件属性值,跟用户在后台设置的使用自定义ID事件属性值匹配 | NSDictionary |
customIDUserProperties | 自定义ID用户属性值,跟用户在后台设置的使用自定义ID用户属性值匹配 | NSDictionary |
mergeType(合并策略)介绍:
参数名称 | 参数含义 |
SERCMergeTypeDefault | 使用服务端配置跟用户本地已有缓存配置合并,参数下发SDK默认合并策略 |
SERCMergeTypeUser | app首次启动或版本更新时, 使用服务端配置跟用户默认配置合并,此方法可以清除本地缓存配置 |
注:开发者使用参数下发SDK需要通过API预置一份默认配置配置到App中,SDK使用该默认配置用来兜底,具体配置方法参考下方设置默认配置方法。
参数下发SDK需要开发者预置一份默认配置到用户app中,方便参数下发SDK使用此默认配置进行兜底操作。
方法示例:
- (void)setDefaultConfig:(NSArray *)defaultConfig;
参数相关:
参数名称 | 参数含义 | 参数类型 | 是否必传 |
defaultConfig | 开发者传入的默认配置 | NSArray | 是 |
调用示例code:
#import <SESDKRemoteConfig/SESDKRemoteConfig.h>
// defaultConfig 默认配置,一个参数配置为一个字典,格式如下:
// [
// {
// @"name" : @"k1", // 配置项的名称,对应fastFetchRemoteConfig接口的参数 key
// @"type" : @1, // 配置项的类型 1 string、2 integer、3 boolean、4 json
// @"value" : @"v1", // 配置项的值
// }
// ]
NSArray *defaultConfig = @[
@{
@"name":@"key1",
@"value":@"value2",
@"type":@1
},
@{
@"name":@"key2",
@"value":@"value2",
@"type":@1
}
];
[[SESDKRemoteConfig sharedInstance] setDefaultConfig:defaultConfig];
开发者可以为事件设置自定义属性,参数下发SDK在请求服务端配置时会带上该属性,用于服务端参数匹配。
方法示例:
- (void)setRemoteConfigEventProperties:(NSDictionary *)properties;
参数相关:
参数名称 | 参数含义 | 参数类型 | 是否必传 |
properties | 事件自定义属性 | NSDictionary | 是 |
调用示例code:
#import <SESDKRemoteConfig/SESDKRemoteConfig.h>
NSDictionary *properties = @{
@"event_key1":@"event_value1",
@"event_key2":@"event_value1"
};
[[SESDKRemoteConfig sharedInstance] setRemoteConfigEventProperties:properties];
注:给事件设置的自定义属性不支持开发者传入"_"下划线开头的key值,SDK会默认丢弃该条属性。
开发者可以为用户设置自定义属性,参数下发SDK在请求服务端配置时会带上该属性,用于服务端参数匹配。
方法示例:
- (void)setRemoteConfigUserProperties:(NSDictionary *)properties;
参数相关:
参数名称 | 参数含义 | 参数类型 | 是否必传 |
properties | 用户自定义属性 | NSDictionary | 是 |
调用示例code:
#import <SESDKRemoteConfig/SESDKRemoteConfig.h>
NSDictionary *properties = @{
@"event_key1":@"event_value1",
@"event_key2":@"event_value1"
};
[[SESDKRemoteConfig sharedInstance] setRemoteConfigUserProperties:properties];
注:给用户设置的自定义属性不支持开发者传入"_"下划线开头的key值,SDK会默认丢弃该条属性。
参数下发SDK获取参数下发配置分为两种情况,一种是同步获取方法,通过此方法开发者可以获取返回结果。另一种是异步获取方法,返回结果需要等待回调完成才可以获取。
注:通过同步或异步方式获取参数时,sdk 会触发上报用户命中试验的事件,所以获取参数的时机应该在用户到达试验场景时读取(获取参数代表用户到达试验场景,用户命中该参数对应的试验),请勿提前读取参数
方法示例:
- (id)fastFetchRemoteConfig:(NSString *)key;
参数相关:
参数名称 | 参数含义 | 参数类型 | 是否必传 |
key | 参数下发key,跟用户在后台配置参数key对应 | NSString | 是 |
返回值类型: id
调用示例code:
#import <SESDKRemoteConfig/SESDKRemoteConfig.h>
id data = [[SESDKRemoteConfig sharedInstance] fastFetchRemoteConfig:@"key1"];
if ([data isKindOfClass:[NSString class]]) {
NSString *dataString = (NSString *)data;
}
方法示例:
- (void)asyncFetchRemoteConfig:(NSString *)key
completionHandler:(void (^)(id data))completionHandler;
参数相关:
参数名称 | 参数含义 | 参数类型 | 是否必传 |
key | 参数下发key,跟用户在后台配置参数key对应 | NSString | 是 |
completionHandler | 参数下发异步回调 | Block | 是 |
调用示例code:
#import <SESDKRemoteConfig/SESDKRemoteConfig.h>
[[SESDKRemoteConfig sharedInstance] asyncFetchRemoteConfig:@"key1" completionHandler:^(id _Nonnull data) {
if ([data isKindOfClass:[NSString class]]) {
NSString *dataString = (NSString *)data;
}
}];
方法示例
- (NSDictionary *)fastFetchRemoteConfig ;
调用示例
#import <SESDKRemoteConfig/SESDKRemoteConfig.h>
NSDictionary *allData = [[SESDKRemoteConfig sharedInstance] fastFetchRemoteConfig];
方法示例
- (void)asyncFetchRemoteConfigWithCompletionHandler:(void (^)(NSDictionary *dict))responseHandle
调用示例
#import <SESDKRemoteConfig/SESDKRemoteConfig.h>
[[SESDKRemoteConfig sharedInstance] asyncFetchRemoteConfigWithCompletionHandler:^(NSDictionary * _Nonnull dict) {
}];
配置为JSON String的示例
当value为字典或者嵌套json string时请把json string转移成string
原始数据
{
"status": 0,
"data": {
"user_data": {
"nick_name": "哈哈哈",
"account_id": "123456",
"title": "我是谁"
}
}
}
设置给SDK的数据
"{\"status\":0,\"data\":{\"user_data\":{\"nick_name\":\"哈哈哈\",\"account_id\":\"123456\",\"title\":\"我是谁\"}}}"
设置默认数据示例
NSArray *defaultConfig = @[
@{
@"name": @"key6",
@"type": @1,
@"value": @"{\"status\":0,\"data\":{\"user_data\":{\"nick_name\":\"哈哈哈\",\"account_id\":\"123456\",\"title\":\"我是谁\"}}}",
}
];
[[SESDKRemoteConfig sharedInstance] setDefaultConfig:defaultConfig];
取值示例
NSString *value = [[SESDKRemoteConfig sharedInstance] fastFetchRemoteConfig:@"key6"];
NSLog(@"fastFetchRemoteConfig value = %@",value);
// 打印出json字符串 {"status":0,"data":{"user_data":{"nick_name":"哈哈哈","account_id":"123456","title":"我是谁"}}}
NSData *jsonData = [value dataUsingEncoding:NSUTF8StringEncoding];
NSError *error;
NSDictionary *dic = [NSJSONSerialization JSONObjectWithData:jsonData options:NSJSONReadingMutableContainers error:&error];
if (error) {
//解析出错
} else {
NSLog(@"dic = %@",dic);
// 打印出字典对象
// {
// data = {
// "user_data" = {
// "account_id" = 123456;
// "nick_name" = "哈哈哈";
// title = "我是谁";
// };
// };
// status = 0;
}
NSLog(@"nick_name = %@",dic[@"data"][@"user_data"][@"nick_name"]);
// 打印出 nick_name = 哈哈哈
}
————————————
2025-07-03 1.3.0.3
对齐SolarEngineSDK 1.3.0.3
2025-06-12 1.3.0.2
对齐SolarEngineSDK 1.3.0.2
2025-01-17 1.2.9.4
优化在线参数json配置
2024-12-10 1.2.9.3
对齐SolarEngineSDK 1.2.9.3
2024-11-21 1.2.9.2
对齐SolarEngineSDK 1.2.9.2
2024-11-06 1.2.9.1
对齐SolarEngineSDK 1.2.9.1
2024-10-22 1.2.9.0
对齐SolarEngineSDK 国内版 1.2.9.0 (国际版请继续使用1.2.8.2)
2024-09-20 1.2.8.2
对齐SolarEngineSDK 1.2.8.2
2024-09-10 1.2.8.1
对齐SolarEngineSDK 1.2.8.1
2024-08-16 1.2.8.0
对齐SolarEngineSDK 1.2.8.0
2024-07-11 1.2.7.8
对齐SolarEngineSDK 1.2.7.8
2024-07-02 1.2.7.7
对齐SolarEngineSDK 1.2.7.7
2024-05-13 1.2.7.6
对齐SolarEngineSDK 1.2.7.6
2024-04-23 1.2.7.5
对齐SolarEngineSDK 1.2.7.5
2024-04-9 1.2.7.4
对齐SolarEngineSDK 1.2.7.4
2024-04-9 1.2.7.3
对齐SolarEngineSDK 1.2.7.3
2024-04-01 1.2.7.2
对齐SolarEngineSDK 1.2.7.2
2024-03-06 1.2.7.1
对齐SolarEngineSDK 1.2.7.1
2024-02-02 1.2.7.0
请求参数配置优化
2023-12-28 1.2.6.1
对齐SolarEngineSDK 1.2.6.1
2023-12-14 1.2.6.0
对齐SolarEngineSDK 1.2.6.0
•支持同步获取所有在线参数配置
•异步获取所有在线参数配置
2023-11-21 1.2.5.3
对齐SolarEngineSDK 1.2.5.3
2023-10-30 1.2.5.1
对齐SolarEngineSDK 1.2.5.1
2023-10-12 1.2.5.0
对齐SolarEngineSDK 1.2.5.0
2023-10-08 1.2.4.0
对齐SolarEngineSDK 1.2.4.0
2023-08-25 1.1.1.1
依赖SolarEngineSDK 1.2.3.0
优化在线参数默认配置
2023-07-31 1.1.1.0
依赖SolarEngineSDK 1.2.2.0
2023-06-01 1.1.0.0
依赖SolarEngineSDK 1.2.0.0
2023-04-26 1.0.3.0
2023-03-30 1.0.2.0
2023-03-20 1.0.1.0
2023-03-10 1.0.0.1
2023-02-08 1.0.0.0