2016-06-15 15 views
0

だから私はdownloaded the attached projectです。のコードをコピーしました。これは私がやったことです。Amazon Cognitoのサインイン - サンプルコード

私は以下を正しい値に置き換えました。私はUSERPOOLをアマゾンのコグニートで作成し、これらの値を取得しました。

NSString *const CognitoIdentityUserPoolId = @"XXX"; 
NSString *const CognitoIdentityUserPoolAppClientId = @"XXX"; 
NSString *const CognitoIdentityUserPoolAppClientSecret = @"XXX"; 

私の質問はdidFinishLaunchingWithOptionsが実行されると、それは-(id<AWSCognitoIdentityPasswordAuthentication>) startPasswordAuthenticationあるデリゲートメソッドを起動しますということです。しかし、私の場合、それはどうしたら解決できますか?

AppDelegate.hは、ストーリーボードを無効にすることによって、この

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 

//setup logging 
    [AWSLogger defaultLogger].logLevel = AWSLogLevelVerbose; 

    //setup service config 
    AWSServiceConfiguration *serviceConfiguration = [[AWSServiceConfiguration alloc] initWithRegion:AWSRegionUSEast1 credentialsProvider:nil]; 

    if([@"YOUR_USER_POOL_ID" isEqualToString:CognitoIdentityUserPoolId]){ 
     [[[UIAlertView alloc] initWithTitle:@"Invalid Configuration" 
            message:@"Please configure user pool constants in Constants.m" 
            delegate:nil 
          cancelButtonTitle:nil 
          otherButtonTitles:@"Ok", nil] show]; 
    } 

    //create a pool 
    AWSCognitoIdentityUserPoolConfiguration *configuration = [[AWSCognitoIdentityUserPoolConfiguration alloc] initWithClientId:CognitoIdentityUserPoolAppClientId clientSecret:CognitoIdentityUserPoolAppClientSecret poolId:CognitoIdentityUserPoolId]; 

    [AWSCognitoIdentityUserPool registerCognitoIdentityUserPoolWithConfiguration:serviceConfiguration userPoolConfiguration:configuration forKey:@"UserPool"]; 

    AWSCognitoIdentityUserPool *pool = [AWSCognitoIdentityUserPool CognitoIdentityUserPoolForKey:@"UserPool"]; 

    //self.storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil]; 

    pool.delegate = self; 

    return YES; 


} 

-(id<AWSCognitoIdentityPasswordAuthentication>) startPasswordAuthentication{ 
    NSLog(@"Came into this method"); 
    return _signInViewController; 
} 

答えて

0

のように見えるこの

#import <UIKit/UIKit.h> 
#import <CoreData/CoreData.h> 
#import "AWSCognitoIdentityProvider.h" 

@interface AppDelegate : UIResponder <UIApplicationDelegate,AWSCognitoIdentityInteractiveAuthenticationDelegate> 

@property (strong, nonatomic) UIWindow *window; 

@property (readonly, strong, nonatomic) NSManagedObjectContext *managedObjectContext; 
@property (readonly, strong, nonatomic) NSManagedObjectModel *managedObjectModel; 
@property (readonly, strong, nonatomic) NSPersistentStoreCoordinator *persistentStoreCoordinator; 
- (void)saveContext; 
- (NSURL *)applicationDocumentsDirectory; 
@end 

AppDelegate.mように見え、あなたは認証デリゲートメソッドではないので、ユーザーのセッションを取得するための呼び出しを削除しましたと呼ばれる。そのコード行がセッションを取得し、認証フローをトリガーするこのようなコードをいくつか入れてみましょう:

[[pool currentUser] getSession];

関連する問題