KMRecommondManager.m 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. ////
  2. //// KMRecommondManager.m
  3. //// PDF Reader Pro Edition
  4. ////
  5. //// Created by Niehaoyu on 2023/4/11.
  6. ////
  7. //
  8. //#import "KMRecommondManager.h"
  9. //
  10. //@interface KMRecommondManager ()
  11. //
  12. //@property (nonatomic, strong, readwrite) KMRecommond *pdfProRecommond;
  13. //
  14. //@property (nonatomic, strong, readwrite) KMRecommond *othersRecommond;
  15. //
  16. //@property (nonatomic, strong, readwrite) KMRecommond *advertisimentRecommond;
  17. //
  18. //@property (nonatomic, assign) BOOL isLoading;
  19. //
  20. //@end
  21. //
  22. //
  23. //@implementation KMRecommondManager
  24. //
  25. //+ (KMRecommondManager *)manager {
  26. // static KMRecommondManager *__manager = nil;
  27. // if (!__manager) {
  28. // __manager = [[KMRecommondManager alloc] init];
  29. // }
  30. // return __manager;
  31. //}
  32. //
  33. //- (id)init {
  34. // self = [super init];
  35. // if (self) {
  36. //
  37. // }
  38. // return self;
  39. //}
  40. //
  41. //- (NSString *)appNameFromType:(KMRecommondAPP)appType {
  42. // if (appType == KMRecommondAPP_PDFReaderProMacLite) {
  43. // return @"PDFReaderProMac";
  44. // } else if (appType == KMRecommondAPP_PDFReaderProMacDMG) {
  45. // return @"PDFReaderProMacDMG";
  46. // } else if (appType == KMRecommondAPP_PDFReaderProMacPro) {
  47. // return @"PDFReaderProMacPro";
  48. // } else if (appType == KMRecommondAPP_RecordIt) {
  49. // return @"RecordIt";
  50. // } else if (appType == KMRecommondAPP_RecordItPro) {
  51. // return @"RecordItPro";
  52. // } else if (appType == KMRecommondAPP_RecordItDMG) {
  53. // return @"RecordItDMG";
  54. // } else if (appType == KMRecommondAPP_FilmageScreen) {
  55. // return @"FilmageScreen";
  56. // } else if (appType == KMRecommondAPP_FilmageScreenPro) {
  57. // return @"FilmageScreenPro";
  58. // } else if (appType == KMRecommondAPP_FilmageScreenDMG) {
  59. // return @"FilmageScreenDMG";
  60. // } else if (appType == KMRecommondAPP_FilmageEditorMac) {
  61. // return @"FilmageEditorMac";
  62. // } else if (appType == KMRecommondAPP_FilmageEditorMacDMG) {
  63. // return @"FilmageEditorMacDMG";
  64. // } else if (appType == KMRecommondAPP_FilmageConverterMac) {
  65. // return @"FilmageConverterMac";
  66. // } else if (appType == KMRecommondAPP_FilmageConverterMacPro) {
  67. // return @"FilmageConverterMacPro";
  68. // } else if (appType == KMRecommondAPP_FilmageConverterMacDMG) {
  69. // return @"FilmageConverterMacDMG";
  70. // } else if (appType == KMRecommondAPP_FilmagePlayerMac) {
  71. // return @"FilmagePlayerMac";
  72. // } else if (appType == KMRecommondAPP_FilmagePlayerMacPro) {
  73. // return @"FilmagePlayerMacPro";
  74. // } else if (appType == KMRecommondAPP_FilmagePlayerMacDMG) {
  75. // return @"FilmagePlayerMacDMG";
  76. // } else if (appType == KMRecommondAPP_PDFReaderProIOS) {
  77. // return @"PDFReaderProIOS";
  78. // } else if (appType == KMRecommondAPP_PDFReaderProIOSPro) {
  79. // return @"PDFReaderProIOSPro";
  80. // } else if (appType == KMRecommondAPP_PDFReaderProAndroid) {
  81. // return @"PDFReaderProAndroid";
  82. // } else if (appType == KMRecommondAPP_PDFMasterMac) {
  83. // return @"PDFMasterMac";
  84. // } else if (appType == KMRecommondAPP_PDFMasterMacPro) {
  85. // return @"PDFMasterMacPro";
  86. // } else if (appType == KMRecommondAPP_PDFMasterMacDMG) {
  87. // return @"PDFMasterMacDMG";
  88. // }
  89. // return @"";
  90. //}
  91. //
  92. //
  93. //
  94. //- (void)loadDataWithAppType:(KMRecommondAPP)appType completionHandler:(void (^)(NSError * _Nonnull))handler {
  95. // if ([self appNameFromType:appType].length > 0) {
  96. // [self loadDataWithAppName:[self appNameFromType:appType] completionHandler:handler];
  97. // }
  98. //}
  99. //
  100. //- (void)loadDataWithAppName:(NSString *)appName completionHandler:(void (^)(NSError *error))handler {
  101. // if (self.isLoading) {
  102. // return;
  103. // }
  104. //
  105. // if (self.pdfProRecommond ||
  106. // self.othersRecommond ||
  107. // self.advertisimentRecommond) {
  108. // if (handler) {
  109. // handler(nil);
  110. // }
  111. // [[NSNotificationCenter defaultCenter] postNotificationName:KMRecommondDatasUpdateNoti object:nil];
  112. // return;
  113. // }
  114. //
  115. // __weak typeof(self) weakSelf = self;
  116. // self.isLoading = YES;
  117. // //Send Request
  118. // NSString *urlString = [kRecommondInfoURL stringByAppendingString:[NSString stringWithFormat:@"/api/advertise-new?app_name=%@",appName?:@""]];
  119. //
  120. // NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfiguration];
  121. // configuration.requestCachePolicy = NSURLRequestReloadIgnoringLocalCacheData;
  122. // [configuration setURLCache:[NSURLCache sharedURLCache]];
  123. //
  124. // NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:urlString]];
  125. // [request setHTTPMethod:@"GET"];
  126. //
  127. // [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
  128. //
  129. // NSURLSession *session = [NSURLSession sessionWithConfiguration:configuration];
  130. // NSURLSessionDataTask *task = [session dataTaskWithRequest:request
  131. // completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
  132. // self.isLoading = NO;
  133. // if (!error) {
  134. // NSDictionary *datas = [NSJSONSerialization JSONObjectWithData:data
  135. // options:NSJSONReadingMutableContainers error:nil];
  136. // if ([datas isKindOfClass:[NSDictionary class]] && datas[@"list"]) {
  137. // NSArray *listArray = datas[@"list"];
  138. //
  139. // for (NSDictionary *listDict in listArray) {
  140. //
  141. // if ([listDict[@"status"] intValue] == 1) {
  142. // NSString *detailString = listDict[@"detail"];
  143. // NSData *jsonData = [detailString dataUsingEncoding:NSUTF8StringEncoding];
  144. // NSDictionary *detailDic = [NSJSONSerialization JSONObjectWithData:jsonData
  145. // options:NSJSONReadingMutableContainers
  146. // error:nil];
  147. //
  148. // if (detailDic[@"recommondContent"]) {
  149. // if (detailDic[@"recommondContent"][@"recommondContentPDFPro"]) {
  150. // weakSelf.pdfProRecommond = [[KMRecommond alloc] initWithDict:detailDic[@"recommondContent"][@"recommondContentPDFPro"]];
  151. // }
  152. // if (detailDic[@"recommondContent"][@"recommondContentOther"]) {
  153. // weakSelf.othersRecommond = [[KMRecommond alloc] initWithDict:detailDic[@"recommondContent"][@"recommondContentOther"]];
  154. // }
  155. // }
  156. //
  157. // if (detailDic[@"advertisement"]) {
  158. // for (NSDictionary *adverDict in detailDic[@"advertisement"]) {
  159. // weakSelf.advertisimentRecommond = [[KMRecommond alloc] initWithDict:detailDic[@"advertisement"]];
  160. // }
  161. // }
  162. // }
  163. // }
  164. // }
  165. // }
  166. // if (handler) {
  167. // handler(error);
  168. // }
  169. // [[NSNotificationCenter defaultCenter] postNotificationName:KMRecommondDatasUpdateNoti object:nil];
  170. // }];
  171. //
  172. // [task resume];
  173. //}
  174. //
  175. //@end