RQConfigureManager.m 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. //
  2. // RQConfigureManager.m
  3. // RQCommon
  4. //
  5. // Created by 张嵘 on 2018/11/23.
  6. // Copyright © 2018 张嵘. All rights reserved.
  7. //
  8. #import "RQConfigureManager.h"
  9. ///
  10. static NSString *is_formal_setting = nil;
  11. static NSString *is_use_https = nil;
  12. static NSString *is_appStore_formal_setting = nil;
  13. /// (AppStore环境的key)
  14. static NSString * const RQApplicationAppStoreFormalSettingKey = @"RQApplicationAppStoreFormalSettingKey";
  15. /// 正式环境key
  16. static NSString * const RQApplicationFormalSettingKey = @"RQApplicationFormalSettingKey";
  17. /// 使用Httpskey
  18. static NSString * const RQApplicationUseHttpsKey = @"RQApplicationUseHttpsKey";
  19. @implementation RQConfigureManager
  20. /// 公共配置
  21. + (void)configure{
  22. /// 初始化一些公共配置...
  23. }
  24. + (void)setApplicationFormalSetting:(BOOL)formalSetting{
  25. is_formal_setting = formalSetting? @"1" : @"0";
  26. [[NSUserDefaults standardUserDefaults] setObject:is_formal_setting forKey:RQApplicationFormalSettingKey];
  27. [[NSUserDefaults standardUserDefaults] synchronize];
  28. }
  29. + (BOOL)applicationFormalSetting {
  30. #if DEBUG
  31. if (!is_formal_setting) {
  32. is_formal_setting = [[NSUserDefaults standardUserDefaults] objectForKey:RQApplicationFormalSettingKey];
  33. is_formal_setting = [is_formal_setting rq_stringValueExtension];
  34. if (RQObjectIsNil(is_formal_setting)) {
  35. return YES;
  36. } else {
  37. return is_formal_setting.boolValue;
  38. }
  39. }
  40. return is_formal_setting.boolValue;
  41. #else
  42. /// Release 模式下默认
  43. return YES;
  44. #endif
  45. }
  46. + (void)setApplicationAppStoreFormalSetting:(BOOL)formalSetting{
  47. is_appStore_formal_setting = formalSetting?@"1":@"0";
  48. [[NSUserDefaults standardUserDefaults] setObject:is_appStore_formal_setting forKey:RQApplicationAppStoreFormalSettingKey];
  49. [[NSUserDefaults standardUserDefaults] synchronize];
  50. }
  51. + (BOOL)applicationAppStoreFormalSetting{
  52. #if DEBUG
  53. if (!is_appStore_formal_setting) {
  54. is_appStore_formal_setting = [[NSUserDefaults standardUserDefaults] objectForKey:RQApplicationAppStoreFormalSettingKey];
  55. is_appStore_formal_setting = [is_appStore_formal_setting rq_stringValueExtension];
  56. }
  57. return (is_appStore_formal_setting.integerValue == 1);
  58. #else
  59. /// Release 默认是AppStore环境
  60. return YES;
  61. #endif
  62. }
  63. + (void)setApplicationUseHttps:(BOOL)useHttps{
  64. is_use_https = useHttps?@"1":@"0";
  65. [[NSUserDefaults standardUserDefaults] setObject:is_use_https forKey:RQApplicationUseHttpsKey];
  66. [[NSUserDefaults standardUserDefaults] synchronize];
  67. }
  68. +(BOOL)applicationUseHttps{
  69. #if DEBUG
  70. if (!is_use_https) {
  71. is_use_https = [[NSUserDefaults standardUserDefaults] objectForKey:RQApplicationUseHttpsKey];
  72. /// 正式环境
  73. if ([self applicationFormalSetting]) {
  74. /// 默认如果是nil 则加载Http
  75. if (is_use_https == nil) {
  76. is_use_https = @"1";
  77. }
  78. }
  79. is_use_https = [is_use_https rq_stringValueExtension];
  80. }
  81. return (is_use_https.integerValue == 1);
  82. #else
  83. /// Release 默认是AppStore环境
  84. return YES;
  85. #endif
  86. }
  87. /// 请求的baseUrl
  88. + (NSString *)requestBaseUrl {
  89. if ([self applicationFormalSetting]) {
  90. /// 注意:这里针对你项目中请求baseUrl来处理....
  91. if ([self applicationAppStoreFormalSetting]) {
  92. /// AppStore正式环境
  93. NSLog(@"¥¥¥¥¥¥¥¥ AppStore正式环境 ¥¥¥¥¥¥¥¥");
  94. return [self applicationUseHttps] ? @"https://sdjk.zzxcx.net/prod-api/" : @"https://sdjk.zzxcx.net/prod-api/";
  95. }else{
  96. /// 正式环境
  97. NSLog(@"¥¥¥¥¥¥¥¥ 正式环境 ¥¥¥¥¥¥¥¥");
  98. return [self applicationUseHttps] ? @"https://sdjk.zzxcx.net/prod-api/" : @"https://sdjk.zzxcx.net/prod-api/";
  99. }
  100. } else {
  101. /// 测试环境
  102. NSLog(@"¥¥¥¥¥¥¥¥ 测试环境 ¥¥¥¥¥¥¥¥");
  103. return [self applicationUseHttps] ? @"https://sdjk1.zzxcx.net/stage-api/" : @"https://sdjk1.zzxcx.net/stage-api/";
  104. }
  105. }
  106. // 请求的baseUrl
  107. + (NSString *)wechatRequestBaseUrl {
  108. return @"https://api.weixin.qq.com/";
  109. }
  110. @end