Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #import "AppDelegate.h"
- #import "AWSConstants.h"
- #import "PeepVC.h"
- #import "WelcomeViewController.h"
- //#import <GoogleMaps/GoogleMaps.h>
- @import GoogleMapsBase;
- @import GooglePlaces;
- @interface AppDelegate ()
- @property (nonatomic,strong) AWSTaskCompletionSource<NSNumber *>* rememberDeviceCompletionSource;
- @end
- @implementation AppDelegate
- {
- GMSPlacesClient *_placesClient;
- UIBackgroundTaskIdentifier bgTask;
- }
- @synthesize cognitoId,locationManager,awsUser,awsPW;
- - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
- // Override point for customization after application launch.
- [[UIApplication sharedApplication] setApplicationIconBadgeNumber:0];
- // new pool info for users
- //setup service config
- AWSServiceConfiguration *serviceConfiguration = [[AWSServiceConfiguration alloc] initWithRegion:AWSRegionUSEast1 credentialsProvider:nil];
- AWSCognitoIdentityUserPoolConfiguration *configuration = [[AWSCognitoIdentityUserPoolConfiguration alloc] initWithClientId:@"--omitted--"
- clientSecret:@"--omitted--"
- poolId:@"--omitted--"];
- [AWSCognitoIdentityUserPool registerCognitoIdentityUserPoolWithConfiguration:serviceConfiguration userPoolConfiguration:configuration forKey:@"UserPool"];
- AWSCognitoIdentityUserPool *pool = [AWSCognitoIdentityUserPool CognitoIdentityUserPoolForKey:@"UserPool"];
- pool.delegate = self;
- NSLog(@"Pool:%@",pool);
- NSLog(@"AWS configuration:%@",configuration);
- NSLog(@"AWS service configuration:%@",serviceConfiguration);
- NSLog(@"AWS Cognito Identity Pool:%@",pool.userPoolConfiguration);
- NSString *deviceInfo = [NSString stringWithFormat:@"Name:%@ Model:%@ (%@:%@)", [UIDevice currentDevice].name, [UIDevice currentDevice].model, [UIDevice currentDevice].systemName, [UIDevice currentDevice].systemVersion];
- NSLog(@"Device Info:%@",deviceInfo);
- [GMSPlacesClient provideAPIKey:@"--omitted--"];
- if ([application respondsToSelector:@selector(registerUserNotificationSettings:)]) {
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(setupMainView) name:@"registerForNotifications" object:nil];
- }
- if (nil == locationManager)
- locationManager = [[CLLocationManager alloc] init];
- locationManager.delegate = self;
- self.venueDataModel = [[NSMutableDictionary alloc] init];
- self.venueDataModelIndices = [[NSMutableDictionary alloc] init];
- self.venueUserDict = [[NSMutableDictionary alloc] init];
- //Set signedUp to Yes or something else in order to skip the tutorial
- if (![[NSUserDefaults standardUserDefaults] objectForKey:@"accountStatus"]) {
- [self initializeTutorial];
- } else {
- [self setupMainView];
- }
- self.storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
- return YES;
- }
- #import "SignInViewController.h"
- @interface SignInViewController ()
- @property (weak, nonatomic) IBOutlet UITextField *password;
- @property (weak, nonatomic) IBOutlet UITextField *username;
- @property (nonatomic, strong) AWSTaskCompletionSource<AWSCognitoIdentityPasswordAuthenticationDetails*>* passwordAuthenticationCompletion;
- @property (nonatomic,strong) AWSCognitoIdentityUserGetDetailsResponse * response;
- @property (nonatomic, strong) AWSCognitoIdentityUser * user;
- @property (nonatomic, strong) AWSCognitoIdentityUserPool * pool;
- @end
- @implementation SignInViewController
- - (void) viewWillAppear:(BOOL)animated {
- self.password.text = nil;
- self.username.text = self.usernameText;
- [self.navigationController setNavigationBarHidden:YES];
- self.pool = [AWSCognitoIdentityUserPool CognitoIdentityUserPoolForKey:@"UserPool"];
- NSLog(@"Pool:%@",self.pool);
- if(!self.user)
- NSLog(@"//SignInViewController:!self.user");
- self.user = [self.pool currentUser];
- [self refresh];
- }
- -(void) refresh {
- NSLog(@"//SignInViewController:refresh");
- [[self.user getDetails] continueWithSuccessBlock:^id _Nullable(AWSTask<AWSCognitoIdentityUserGetDetailsResponse *> * _Nonnull task) {
- dispatch_async(dispatch_get_main_queue(), ^{
- self.response = task.result;
- self.title = self.user.username;
- NSLog(@"//UserDetailTableViewController:reloadData");
- //[self.tableView reloadData];
- });
- return nil;
- }];
- }
- - (IBAction)signInPressed:(id)sender {
- NSLog(@"SignInPressed:%@",self.username.text);
- self.passwordAuthenticationCompletion.result = [[AWSCognitoIdentityPasswordAuthenticationDetails alloc] initWithUsername:self.username.text password:self.password.text];
- }
- -(void) getPasswordAuthenticationDetails: (AWSCognitoIdentityPasswordAuthenticationInput *) authenticationInput passwordAuthenticationCompletionSource: (AWSTaskCompletionSource<AWSCognitoIdentityPasswordAuthenticationDetails *> *) passwordAuthenticationCompletionSource {
- NSLog(@"getPasswordAuthenticationDetails:");
- self.passwordAuthenticationCompletion = passwordAuthenticationCompletionSource;
- NSLog(@"self.passwordAuthenticationCompletion:%@",passwordAuthenticationCompletionSource);
- dispatch_async(dispatch_get_main_queue(), ^{
- if(!self.usernameText)
- self.usernameText = authenticationInput.lastKnownUsername;
- NSLog(@"self.usernameText:%@",self.usernameText);
- });
- }
- -(void) didCompletePasswordAuthenticationStepWithError:(NSError*) error {
- NSLog(@"didCompletePasswordAuthenticationStepWithError:");
- dispatch_async(dispatch_get_main_queue(), ^{
- if(error){
- [[[UIAlertView alloc] initWithTitle:error.userInfo[@"__type"]
- message:error.userInfo[@"message"]
- delegate:nil
- cancelButtonTitle:nil
- otherButtonTitles:@"Retry", nil] show];
- }else{
- self.usernameText = nil;
- [self dismissViewControllerAnimated:YES completion:nil];
- }
- });
- }
- @end
- 2016-09-01 22:20:48.323 PS[84018:4547153] Pool:<AWSCognitoIdentityUserPool: 0x7fda09c2f0d0>
- 2016-09-01 22:20:48.324 PS[84018:4547153] AWS configuration:<AWSCognitoIdentityUserPoolConfiguration: 0x7fda09c3b2a0>
- 2016-09-01 22:20:48.324 PS[84018:4547153] AWS service configuration:<AWSServiceConfiguration: 0x7fda09c3b520>
- 2016-09-01 22:20:48.324 PS[84018:4547153] AWS Cognito Identity Pool:<AWSCognitoIdentityUserPoolConfiguration: 0x7fda09c3b2a0>
- 2016-09-01 22:20:48.324 PS[84018:4547153] Device Info:Name:iPhone Simulator Model:iPhone (iPhone OS:9.3)
- 2016-09-01 22:20:48.330 PS[84018:4547153] appDidBecomeActive
- 2016-09-01 22:20:50.315 PS[84018:4547153] Pool:<AWSCognitoIdentityUserPool: 0x7fda09c2f0d0>
- 2016-09-01 22:20:50.315 PS[84018:4547153] //SignInViewController:!self.user
- 2016-09-01 22:20:50.317 PS[84018:4547153] //SignInViewController:refresh
- 2016-09-01 22:20:50.317 PS[84018:4547153] startPasswordAuthentication
- 2016-09-01 22:20:50.318 PS[84018:4547153] //startPasswordAuthentication:self.signInViewController:<SignInViewController: 0x7fda09f1e920>
- 2016-09-01 22:20:50.319 PS[84018:4547153] getPasswordAuthenticationDetails:
- 2016-09-01 22:20:50.319 PS[84018:4547153] self.passwordAuthenticationCompletion:<AWSTaskCompletionSource: 0x7fda09c5b800>
- 2016-09-01 22:20:50.327 PS[84018:4547153] self.usernameText:(null)
- 2016-09-01 22:21:04.557 PS[84018:4547153] SignInPressed:testsamp
- 2016-09-01 14:27:31.848 CognitoYourUserPoolsSample[77236:4278261] AWSiOSSDK v2.4.7 [Debug] AWSURLSessionManager.m line:526 | -[AWSURLSessionManager printHTTPHeadersAndBodyForRequest:] | Request headers:
- {
- "Content-Type" = "application/x-amz-json-1.1";
- Host = "cognito-idp.us-east-1.amazonaws.com";
- "User-Agent" = "aws-sdk-iOS/2.4.7 iPhone-OS/9.3 en_US";
- "X-Amz-Date" = 20160901T182731Z;
- "X-Amz-Target" = "AWSCognitoIdentityProviderService.InitiateAuth";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement