Commit 13763cf2823b63b9795832793a41c6769a55aa6a
1 parent
dab39b19
no message
Showing
4 changed files
with
84 additions
and
11 deletions
CNLiveEnvironment.podspec
| @@ -8,7 +8,7 @@ | @@ -8,7 +8,7 @@ | ||
| 8 | 8 | ||
| 9 | Pod::Spec.new do |s| | 9 | Pod::Spec.new do |s| |
| 10 | s.name = 'CNLiveEnvironment' | 10 | s.name = 'CNLiveEnvironment' |
| 11 | - s.version = '0.1.3' | 11 | + s.version = '0.1.4' |
| 12 | s.summary = 'CNLiveEnvironment' | 12 | s.summary = 'CNLiveEnvironment' |
| 13 | 13 | ||
| 14 | # This description is used to generate tags and improve search results. | 14 | # This description is used to generate tags and improve search results. |
CNLiveEnvironment/Classes/CNLiveEnvironment.h
| @@ -11,9 +11,14 @@ | @@ -11,9 +11,14 @@ | ||
| 11 | 11 | ||
| 12 | // 接口 | 12 | // 接口 |
| 13 | #import "CNLiveInterface.h" | 13 | #import "CNLiveInterface.h" |
| 14 | +// app类型 | ||
| 15 | +#define AppType [CNLiveEnvironmentManager manager].appType | ||
| 16 | + | ||
| 17 | +// 是否是企业端 | ||
| 18 | +#define Business [CNLiveEnvironmentManager manager].isBusiness | ||
| 14 | 19 | ||
| 15 | // 详细环境 | 20 | // 详细环境 |
| 16 | -#define EnvironmentType [CNLiveEnvironmentManager manager].isEnvironment | 21 | +#define EnvironmentType [CNLiveEnvironmentManager manager].environmentType |
| 17 | 22 | ||
| 18 | // 是否是测试环境 | 23 | // 是否是测试环境 |
| 19 | #define TestEnvironment [CNLiveEnvironmentManager manager].isTestEnvironment | 24 | #define TestEnvironment [CNLiveEnvironmentManager manager].isTestEnvironment |
CNLiveEnvironment/Classes/CNLiveEnvironmentManager.h
| @@ -16,12 +16,18 @@ typedef NS_ENUM(NSInteger, CNLiveEnvironmentType) { | @@ -16,12 +16,18 @@ typedef NS_ENUM(NSInteger, CNLiveEnvironmentType) { | ||
| 16 | CNLiveDebugAppStore = 2, //测试商店环境 | 16 | CNLiveDebugAppStore = 2, //测试商店环境 |
| 17 | CNLiveProductionAppStore = 3, //正式商店环境 | 17 | CNLiveProductionAppStore = 3, //正式商店环境 |
| 18 | CNLiveTestFlight = 4 //TestFlight环境 | 18 | CNLiveTestFlight = 4 //TestFlight环境 |
| 19 | +}; | ||
| 19 | 20 | ||
| 21 | +typedef NS_ENUM(NSInteger, CNLiveAppType) { | ||
| 22 | + CNLiveAppTypeUser = 0, //用户端 | ||
| 23 | + CNLiveAppTypeBusiness = 1, //企业端 | ||
| 20 | }; | 24 | }; |
| 21 | 25 | ||
| 22 | @interface CNLiveEnvironmentManager : NSObject | 26 | @interface CNLiveEnvironmentManager : NSObject |
| 27 | +@property (nonatomic, assign, readonly) CNLiveAppType appType; //app类型 | ||
| 28 | +@property (nonatomic, assign, readonly) BOOL isBusiness; // 企业端 | ||
| 23 | 29 | ||
| 24 | -@property (nonatomic, assign, readonly) CNLiveEnvironmentType isEnvironment; // 详细环境 | 30 | +@property (nonatomic, assign, readonly) CNLiveEnvironmentType environmentType; // 详细环境 |
| 25 | @property (nonatomic, assign, readonly) BOOL isTestEnvironment; // 是否是测试环境 | 31 | @property (nonatomic, assign, readonly) BOOL isTestEnvironment; // 是否是测试环境 |
| 26 | 32 | ||
| 27 | @property (nonatomic, copy, readonly) NSString *kAppDownloadUrl;// 下载地址 | 33 | @property (nonatomic, copy, readonly) NSString *kAppDownloadUrl;// 下载地址 |
| @@ -105,13 +111,31 @@ typedef NS_ENUM(NSInteger, CNLiveEnvironmentType) { | @@ -105,13 +111,31 @@ typedef NS_ENUM(NSInteger, CNLiveEnvironmentType) { | ||
| 105 | 111 | ||
| 106 | /** | 112 | /** |
| 107 | * @abstract 初始化配置 | 113 | * @abstract 初始化配置 |
| 108 | - * @param isEnvironment 环境 | 114 | + * @param appType app类型 |
| 115 | + * @param environmentType 环境 | ||
| 116 | + * @warning 必传参数 | ||
| 117 | + * 在默认DEBUG环境下为测试商店版,建议使用如下方法初始化. | ||
| 118 | + * 在 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions; 方法中调用 | ||
| 119 | + */ | ||
| 120 | ++ (void)setAppTye:(CNLiveAppType)appType environmentType:(CNLiveEnvironmentType)environmentType; | ||
| 121 | + | ||
| 122 | +/** | ||
| 123 | + * @abstract 初始化配置 | ||
| 124 | + * @param appType app类型 | ||
| 109 | * @warning 必传参数 | 125 | * @warning 必传参数 |
| 110 | * 在默认DEBUG环境下为测试商店版,建议使用如下方法初始化. | 126 | * 在默认DEBUG环境下为测试商店版,建议使用如下方法初始化. |
| 111 | * 在 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions; 方法中调用 | 127 | * 在 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions; 方法中调用 |
| 112 | */ | 128 | */ |
| 113 | -+ (void)setEnvironment:(CNLiveEnvironmentType)isEnvironment; | 129 | ++ (void)setAppTye:(CNLiveAppType)appType; |
| 114 | 130 | ||
| 131 | +/** | ||
| 132 | + * @abstract 初始化配置 | ||
| 133 | + * @param environmentType 环境 | ||
| 134 | + * @warning 必传参数 | ||
| 135 | + * 在默认DEBUG环境下为测试商店版,建议使用如下方法初始化. | ||
| 136 | + * 在 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions; 方法中调用 | ||
| 137 | + */ | ||
| 138 | ++ (void)setEnvironment:(CNLiveEnvironmentType)environmentType; | ||
| 115 | 139 | ||
| 116 | @end | 140 | @end |
| 117 | 141 |
CNLiveEnvironment/Classes/CNLiveEnvironmentManager.m
| @@ -9,7 +9,10 @@ | @@ -9,7 +9,10 @@ | ||
| 9 | #import "CNLiveEnvironmentManager.h" | 9 | #import "CNLiveEnvironmentManager.h" |
| 10 | 10 | ||
| 11 | @interface CNLiveEnvironmentManager() | 11 | @interface CNLiveEnvironmentManager() |
| 12 | -@property (nonatomic, assign, readwrite) CNLiveEnvironmentType isEnvironment; //详细环境 | 12 | +@property (nonatomic, assign, readwrite) CNLiveAppType appType; //app类型 |
| 13 | +@property (nonatomic, assign, readwrite) BOOL isBusiness; // 企业端 | ||
| 14 | + | ||
| 15 | +@property (nonatomic, assign, readwrite) CNLiveEnvironmentType environmentType; //详细环境 | ||
| 13 | @property (nonatomic, assign, readwrite) BOOL isTestEnvironment; // 是否是测试环境 | 16 | @property (nonatomic, assign, readwrite) BOOL isTestEnvironment; // 是否是测试环境 |
| 14 | 17 | ||
| 15 | @property (nonatomic, copy, readwrite) NSString *kAppDownloadUrl; | 18 | @property (nonatomic, copy, readwrite) NSString *kAppDownloadUrl; |
| @@ -133,18 +136,18 @@ static CNLiveEnvironmentManager *_instance = nil; | @@ -133,18 +136,18 @@ static CNLiveEnvironmentManager *_instance = nil; | ||
| 133 | 136 | ||
| 134 | /** | 137 | /** |
| 135 | * @abstract 初始化配置 | 138 | * @abstract 初始化配置 |
| 136 | - * @param isEnvironment 环境 | 139 | + * @param environmentType 环境 |
| 137 | * @warning 必传参数 | 140 | * @warning 必传参数 |
| 138 | * 此方法环境默认为测试商店版,建议使用如下方法初始化. | 141 | * 此方法环境默认为测试商店版,建议使用如下方法初始化. |
| 139 | * 在 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions; 方法中调用 | 142 | * 在 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions; 方法中调用 |
| 140 | */ | 143 | */ |
| 141 | -+ (void)setEnvironment:(CNLiveEnvironmentType)isEnvironment{ | 144 | ++ (void)setEnvironment:(CNLiveEnvironmentType)environmentType{ |
| 142 | CNLiveEnvironmentManager *manager = [CNLiveEnvironmentManager manager]; | 145 | CNLiveEnvironmentManager *manager = [CNLiveEnvironmentManager manager]; |
| 143 | - if(manager.isEnvironment == isEnvironment){ | 146 | + if(manager.environmentType == environmentType){ |
| 144 | return; | 147 | return; |
| 145 | } | 148 | } |
| 146 | - manager.isEnvironment = isEnvironment; | ||
| 147 | - switch (isEnvironment) { | 149 | + manager.environmentType = environmentType; |
| 150 | + switch (environmentType) { | ||
| 148 | #pragma mark - 测试企业环境 | 151 | #pragma mark - 测试企业环境 |
| 149 | case CNLiveDebugInHouse://测试企业环境 | 152 | case CNLiveDebugInHouse://测试企业环境 |
| 150 | { | 153 | { |
| @@ -520,4 +523,45 @@ static CNLiveEnvironmentManager *_instance = nil; | @@ -520,4 +523,45 @@ static CNLiveEnvironmentManager *_instance = nil; | ||
| 520 | 523 | ||
| 521 | } | 524 | } |
| 522 | 525 | ||
| 526 | +/** | ||
| 527 | + * @abstract 初始化配置 | ||
| 528 | + * @param appType app类型 | ||
| 529 | + * @warning 必传参数 | ||
| 530 | + * 在默认DEBUG环境下为测试商店版,建议使用如下方法初始化. | ||
| 531 | + * 在 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions; 方法中调用 | ||
| 532 | + */ | ||
| 533 | ++ (void)setAppTye:(CNLiveAppType)appType { | ||
| 534 | + CNLiveEnvironmentManager *manager = [CNLiveEnvironmentManager manager]; | ||
| 535 | + manager.appType = appType; | ||
| 536 | + switch (appType) { | ||
| 537 | + // 用户端 | ||
| 538 | + case CNLiveAppTypeUser: | ||
| 539 | + { | ||
| 540 | + manager.isBusiness = NO; | ||
| 541 | + } | ||
| 542 | + break; | ||
| 543 | + // 企业端 | ||
| 544 | + case CNLiveAppTypeBusiness: | ||
| 545 | + { | ||
| 546 | + manager.isBusiness = YES; | ||
| 547 | + | ||
| 548 | + } | ||
| 549 | + break; | ||
| 550 | + } | ||
| 551 | +} | ||
| 552 | + | ||
| 553 | +/** | ||
| 554 | + * @abstract 初始化配置 | ||
| 555 | + * @param appType app类型 | ||
| 556 | + * @param environmentType 环境 | ||
| 557 | + * @warning 必传参数 | ||
| 558 | + * 在默认DEBUG环境下为测试商店版,建议使用如下方法初始化. | ||
| 559 | + * 在 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions; 方法中调用 | ||
| 560 | + */ | ||
| 561 | ++ (void)setAppTye:(CNLiveAppType)appType environmentType:(CNLiveEnvironmentType)environmentType { | ||
| 562 | + // 顺序不能颠倒 | ||
| 563 | + [self setEnvironment:environmentType]; | ||
| 564 | + [self setAppTye:appType]; | ||
| 565 | +} | ||
| 566 | + | ||
| 523 | @end | 567 | @end |