Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2018
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -(void)loginComplete:(NSMutableDictionary *)logInfo
  2. {
  3.     appDelegate= (AppDelegate *) [[UIApplication sharedApplication]delegate];
  4.     [SVProgressHUD showWithMaskType:SVProgressHUDMaskTypeGradient];
  5.     //NSUserDefaults *prefs =[NSUserDefaults standardUserDefaults];
  6.    
  7.     NSString *loginUrl = [NSString stringWithFormat:@"%@user/log_in_mobile/", BaseURLString_development];
  8.     NSLog(@"url %@",loginUrl);
  9.    
  10.     AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
  11. //    manager.requestSerializer = [AFJSONRequestSerializer serializer];
  12. //    [manager.requestSerializer setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
  13. //    [manager.requestSerializer setValue:@"iOS" forHTTPHeaderField:@"platform"];
  14. //    [manager.requestSerializer setValue:@"1.0.0" forHTTPHeaderField:@"version"];
  15.    
  16.     [manager POST:loginUrl parameters:@{
  17.                                         @"phone_no": [logInfo valueForKey:@"userID"],
  18.                                         @"pin": [logInfo valueForKey:@"pin"],
  19.                                         @"ip_address": [logInfo valueForKey:@"Ip"],
  20.                                         @"login_lat": [logInfo valueForKey:@"latitude"],
  21.                                         @"login_lng": [logInfo valueForKey:@"longitude"],
  22.                                         @"login_type": @"mobile"
  23.                                         } success:^(AFHTTPRequestOperation *operation, id responseObject)
  24.      {
  25.          NSDictionary *jsondict=responseObject;
  26.          
  27. //         [SVProgressHUD dismiss];
  28. //         if (![jsondict isKindOfClass:[NSNull class]])
  29. //         {
  30. //             NSLog(@"userinfo %@",jsondict);
  31. //             if ([[jsondict valueForKey:@"statusCode"]integerValue]==200)
  32. //             {
  33. //
  34. //             }
  35. //             else
  36. //             {
  37. //                 NSLog(@"Message: %@",[jsondict valueForKey:@"Message"]);
  38. //                 UIAlertController *alert = [UIAlertController
  39. //                                             alertControllerWithTitle:@"Alert"
  40. //                                             message:[jsondict valueForKey:@"Message"]
  41. //                                             preferredStyle:UIAlertControllerStyleAlert];
  42. //
  43. //                 UIAlertAction* DismissButton = [UIAlertAction
  44. //                                                 actionWithTitle:@"OK"
  45. //                                                 style:UIAlertActionStyleDefault
  46. //                                                 handler:^(UIAlertAction * action) {
  47. //                                                     [alert dismissViewControllerAnimated:YES completion:nil];
  48. //                                                 }];
  49. //
  50. //                 [alert addAction:DismissButton];
  51. //
  52. //                 [[[[[UIApplication sharedApplication] delegate] window] rootViewController] presentViewController:alert animated:YES completion:nil];
  53. //             }
  54. //         }
  55. //         else
  56. //         {
  57. //             UIAlertController *alert = [UIAlertController
  58. //                                         alertControllerWithTitle:@"Alert"
  59. //                                         message:@"Data Not Found."
  60. //                                         preferredStyle:UIAlertControllerStyleAlert];
  61. //
  62. //             UIAlertAction* DismissButton = [UIAlertAction
  63. //                                             actionWithTitle:@"OK"
  64. //                                             style:UIAlertActionStyleDefault
  65. //                                             handler:^(UIAlertAction * action) {
  66. //                                                 [alert dismissViewControllerAnimated:YES completion:nil];
  67. //                                             }];
  68. //
  69. //             [alert addAction:DismissButton];
  70. //             [[[[[UIApplication sharedApplication] delegate] window] rootViewController] presentViewController:alert animated:YES completion:nil];
  71. //         }
  72.          
  73.          
  74.      } failure:^(AFHTTPRequestOperation *operation, NSError *error)
  75.      {
  76.          [SVProgressHUD dismiss];
  77.          UIAlertController *alert = [UIAlertController
  78.                                      alertControllerWithTitle:@"Alert"
  79.                                      message:@"Connecting Error"
  80.                                      preferredStyle:UIAlertControllerStyleAlert];
  81.          
  82.          UIAlertAction* DismissButton = [UIAlertAction
  83.                                          actionWithTitle:@"OK"
  84.                                          style:UIAlertActionStyleDefault
  85.                                          handler:^(UIAlertAction * action) {
  86.                                              [alert dismissViewControllerAnimated:YES completion:nil];
  87.                                          }];
  88.          
  89.          [alert addAction:DismissButton];
  90.          [[[[[UIApplication sharedApplication] delegate] window] rootViewController] presentViewController:alert animated:YES completion:nil];
  91.      }];
  92. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement