daily pastebin goal
21%
SHARE
TWEET

Untitled

a guest Sep 20th, 2016 62 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #import "AppDelegate.h"
  2. #import "AWSConstants.h"
  3. #import "PeepVC.h"
  4. #import "WelcomeViewController.h"
  5. //#import <GoogleMaps/GoogleMaps.h>
  6. @import GoogleMapsBase;
  7. @import GooglePlaces;
  8.  
  9. @interface AppDelegate ()
  10.  
  11. @property (nonatomic,strong) AWSTaskCompletionSource<NSNumber *>* rememberDeviceCompletionSource;
  12.  
  13. @end
  14.  
  15. @implementation AppDelegate
  16. {
  17.     GMSPlacesClient *_placesClient;
  18.     UIBackgroundTaskIdentifier bgTask;
  19. }
  20. @synthesize cognitoId,locationManager,awsUser,awsPW;
  21.  
  22. - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
  23.     // Override point for customization after application launch.
  24.     [[UIApplication sharedApplication] setApplicationIconBadgeNumber:0];
  25.  
  26.  
  27.     // new pool info for users
  28.     //setup service config
  29.     AWSServiceConfiguration *serviceConfiguration = [[AWSServiceConfiguration alloc] initWithRegion:AWSRegionUSEast1 credentialsProvider:nil];
  30.  
  31.     AWSCognitoIdentityUserPoolConfiguration *configuration = [[AWSCognitoIdentityUserPoolConfiguration alloc] initWithClientId:@"--omitted--"
  32.                                                                                                                   clientSecret:@"--omitted--"
  33.                                                                                                                         poolId:@"--omitted--"];
  34.  
  35.  
  36.     [AWSCognitoIdentityUserPool registerCognitoIdentityUserPoolWithConfiguration:serviceConfiguration userPoolConfiguration:configuration forKey:@"UserPool"];
  37.     AWSCognitoIdentityUserPool *pool = [AWSCognitoIdentityUserPool CognitoIdentityUserPoolForKey:@"UserPool"];
  38.     pool.delegate = self;
  39.     NSLog(@"Pool:%@",pool);
  40.  
  41.     NSLog(@"AWS configuration:%@",configuration);
  42.     NSLog(@"AWS service configuration:%@",serviceConfiguration);
  43.     NSLog(@"AWS Cognito Identity Pool:%@",pool.userPoolConfiguration);
  44.  
  45.     NSString *deviceInfo = [NSString stringWithFormat:@"Name:%@ Model:%@ (%@:%@)", [UIDevice currentDevice].name, [UIDevice currentDevice].model, [UIDevice currentDevice].systemName, [UIDevice currentDevice].systemVersion];
  46.  
  47.     NSLog(@"Device Info:%@",deviceInfo);
  48.  
  49.     [GMSPlacesClient provideAPIKey:@"--omitted--"];
  50.  
  51.     if ([application respondsToSelector:@selector(registerUserNotificationSettings:)]) {
  52.         [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(setupMainView) name:@"registerForNotifications" object:nil];
  53.     }
  54.  
  55.     if (nil == locationManager)
  56.         locationManager = [[CLLocationManager alloc] init];
  57.  
  58.     locationManager.delegate = self;
  59.  
  60.     self.venueDataModel = [[NSMutableDictionary alloc] init];
  61.     self.venueDataModelIndices = [[NSMutableDictionary alloc] init];
  62.     self.venueUserDict = [[NSMutableDictionary alloc] init];
  63.  
  64.     //Set signedUp to Yes or something else in order to skip the tutorial
  65.     if (![[NSUserDefaults standardUserDefaults] objectForKey:@"accountStatus"]) {
  66.         [self initializeTutorial];
  67.     } else {
  68.         [self setupMainView];
  69.     }
  70.  
  71.  
  72.     self.storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
  73.  
  74.     return YES;
  75. }
  76.    
  77. #import "SignInViewController.h"
  78.  
  79. @interface SignInViewController ()
  80. @property (weak, nonatomic) IBOutlet UITextField *password;
  81. @property (weak, nonatomic) IBOutlet UITextField *username;
  82. @property (nonatomic, strong) AWSTaskCompletionSource<AWSCognitoIdentityPasswordAuthenticationDetails*>* passwordAuthenticationCompletion;
  83.  
  84. @property (nonatomic,strong) AWSCognitoIdentityUserGetDetailsResponse * response;
  85. @property (nonatomic, strong) AWSCognitoIdentityUser * user;
  86. @property (nonatomic, strong) AWSCognitoIdentityUserPool * pool;
  87. @end
  88.  
  89. @implementation SignInViewController
  90.  
  91. - (void) viewWillAppear:(BOOL)animated {
  92.     self.password.text = nil;
  93.     self.username.text = self.usernameText;
  94.     [self.navigationController setNavigationBarHidden:YES];
  95.     self.pool = [AWSCognitoIdentityUserPool CognitoIdentityUserPoolForKey:@"UserPool"];
  96.     NSLog(@"Pool:%@",self.pool);
  97.     if(!self.user)
  98.         NSLog(@"//SignInViewController:!self.user");
  99.         self.user = [self.pool currentUser];
  100.     [self refresh];
  101. }
  102. -(void) refresh {
  103.     NSLog(@"//SignInViewController:refresh");
  104.  
  105.     [[self.user getDetails] continueWithSuccessBlock:^id _Nullable(AWSTask<AWSCognitoIdentityUserGetDetailsResponse *> * _Nonnull task) {
  106.         dispatch_async(dispatch_get_main_queue(), ^{
  107.             self.response = task.result;
  108.             self.title = self.user.username;
  109.             NSLog(@"//UserDetailTableViewController:reloadData");
  110.             //[self.tableView reloadData];
  111.         });
  112.         return nil;
  113.     }];
  114. }
  115.  
  116. - (IBAction)signInPressed:(id)sender {
  117.     NSLog(@"SignInPressed:%@",self.username.text);
  118.     self.passwordAuthenticationCompletion.result = [[AWSCognitoIdentityPasswordAuthenticationDetails alloc] initWithUsername:self.username.text password:self.password.text];
  119. }
  120.  
  121.  
  122. -(void) getPasswordAuthenticationDetails: (AWSCognitoIdentityPasswordAuthenticationInput *) authenticationInput  passwordAuthenticationCompletionSource: (AWSTaskCompletionSource<AWSCognitoIdentityPasswordAuthenticationDetails *> *) passwordAuthenticationCompletionSource {
  123.     NSLog(@"getPasswordAuthenticationDetails:");
  124.  
  125.     self.passwordAuthenticationCompletion = passwordAuthenticationCompletionSource;
  126.     NSLog(@"self.passwordAuthenticationCompletion:%@",passwordAuthenticationCompletionSource);
  127.  
  128.     dispatch_async(dispatch_get_main_queue(), ^{
  129.         if(!self.usernameText)
  130.             self.usernameText = authenticationInput.lastKnownUsername;
  131.             NSLog(@"self.usernameText:%@",self.usernameText);
  132.     });
  133.  
  134. }
  135.  
  136. -(void) didCompletePasswordAuthenticationStepWithError:(NSError*) error {
  137.     NSLog(@"didCompletePasswordAuthenticationStepWithError:");
  138.  
  139.     dispatch_async(dispatch_get_main_queue(), ^{
  140.         if(error){
  141.             [[[UIAlertView alloc] initWithTitle:error.userInfo[@"__type"]
  142.                                         message:error.userInfo[@"message"]
  143.                                        delegate:nil
  144.                               cancelButtonTitle:nil
  145.                               otherButtonTitles:@"Retry", nil] show];
  146.         }else{
  147.             self.usernameText = nil;
  148.             [self dismissViewControllerAnimated:YES completion:nil];
  149.         }
  150.     });
  151. }
  152.  
  153. @end
  154.    
  155. 2016-09-01 22:20:48.323 PS[84018:4547153] Pool:<AWSCognitoIdentityUserPool: 0x7fda09c2f0d0>
  156. 2016-09-01 22:20:48.324 PS[84018:4547153] AWS configuration:<AWSCognitoIdentityUserPoolConfiguration: 0x7fda09c3b2a0>
  157. 2016-09-01 22:20:48.324 PS[84018:4547153] AWS service configuration:<AWSServiceConfiguration: 0x7fda09c3b520>
  158. 2016-09-01 22:20:48.324 PS[84018:4547153] AWS Cognito Identity Pool:<AWSCognitoIdentityUserPoolConfiguration: 0x7fda09c3b2a0>
  159. 2016-09-01 22:20:48.324 PS[84018:4547153] Device Info:Name:iPhone Simulator Model:iPhone (iPhone OS:9.3)
  160. 2016-09-01 22:20:48.330 PS[84018:4547153] appDidBecomeActive
  161. 2016-09-01 22:20:50.315 PS[84018:4547153] Pool:<AWSCognitoIdentityUserPool: 0x7fda09c2f0d0>
  162. 2016-09-01 22:20:50.315 PS[84018:4547153] //SignInViewController:!self.user
  163. 2016-09-01 22:20:50.317 PS[84018:4547153] //SignInViewController:refresh
  164. 2016-09-01 22:20:50.317 PS[84018:4547153] startPasswordAuthentication
  165. 2016-09-01 22:20:50.318 PS[84018:4547153] //startPasswordAuthentication:self.signInViewController:<SignInViewController: 0x7fda09f1e920>
  166. 2016-09-01 22:20:50.319 PS[84018:4547153] getPasswordAuthenticationDetails:
  167. 2016-09-01 22:20:50.319 PS[84018:4547153] self.passwordAuthenticationCompletion:<AWSTaskCompletionSource: 0x7fda09c5b800>
  168. 2016-09-01 22:20:50.327 PS[84018:4547153] self.usernameText:(null)
  169. 2016-09-01 22:21:04.557 PS[84018:4547153] SignInPressed:testsamp
  170.    
  171. 2016-09-01 14:27:31.848 CognitoYourUserPoolsSample[77236:4278261] AWSiOSSDK v2.4.7 [Debug] AWSURLSessionManager.m line:526 | -[AWSURLSessionManager printHTTPHeadersAndBodyForRequest:] | Request headers:
  172. {
  173.     "Content-Type" = "application/x-amz-json-1.1";
  174.     Host = "cognito-idp.us-east-1.amazonaws.com";
  175.     "User-Agent" = "aws-sdk-iOS/2.4.7 iPhone-OS/9.3 en_US";
  176.     "X-Amz-Date" = 20160901T182731Z;
  177.     "X-Amz-Target" = "AWSCognitoIdentityProviderService.InitiateAuth";
  178. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top