APIPOPOPO.m 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. //
  2. // APIPOPOPO.m
  3. // smartRhino
  4. //
  5. // Created by tederen on 2019/11/13.
  6. // Copyright © 2019 tederen. All rights reserved.
  7. //
  8. #import "APIPOPOPO.h"
  9. @implementation APIPOPOPO
  10. + (void)ApiPOPOPO{
  11. [[HttpManager sharedHttpManager] POSTUrl:Host(@"/api/app/app-version/get-version") parameters: @{@"versionType":@1}success:^(id _Nonnull responseObject) {
  12. REMOVESHOW
  13. } failure:^(NSError * _Nonnull error) {
  14. REMOVESHOW
  15. }];
  16. [self startRequestWithUrl:Host(@"/api/app/app-version/get-version") method:@"POST" params: @{@"versionType":@1}];
  17. }
  18. + (void)startRequestWithUrl:(NSString *)url method:(NSString *)method params:(NSDictionary *)params{
  19. NSError *error;
  20. NSData *jsonData = [NSJSONSerialization dataWithJSONObject:params options:0 error:&error];
  21. NSString *jsonString = [[NSString alloc]initWithData:jsonData encoding:NSUTF8StringEncoding];
  22. AFURLSessionManager *manager = [[AFURLSessionManager alloc]initWithSessionConfiguration:[NSURLSessionConfiguration defaultSessionConfiguration]];
  23. NSMutableURLRequest *request = [[AFJSONRequestSerializer serializer] requestWithMethod:method URLString:url parameters:nil error:nil];
  24. request.timeoutInterval = 30;
  25. [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
  26. [request setValue:@"application/json" forHTTPHeaderField:@"Accept"];
  27. // manager.responseSerializer.acceptableContentTypes = [manager.responseSerializer.acceptableContentTypes setByAddingObject:@"text/plain"];
  28. [request setHTTPBody:[jsonString dataUsingEncoding:NSUTF8StringEncoding]];
  29. [[manager dataTaskWithRequest:request uploadProgress:^(NSProgress * _Nonnull uploadProgress) {
  30. } downloadProgress:^(NSProgress * _Nonnull downloadProgress) {
  31. } completionHandler:^(NSURLResponse * _Nonnull response, id _Nullable responseObject, NSError * _Nullable error) {
  32. if (!error) {
  33. NSLog(@"Reply JOSN:%@",responseObject);
  34. }else{
  35. NSLog(@"ERROR:%@,%@,%@",error,response,responseObject);
  36. }
  37. }] resume] ;
  38. }
  39. @end