2013-03-25 2 views
1

Когда я аутентифицируюсь в iPhone Simulater в режиме отладки, запускается первый оператор в приведенном ниже коде. Однако, когда я отлаживаю iPhone, на котором установлен клиент Evernote, оператор if не отображается. Вместо этого приложение iNon Evernote появляется на мгновение, а затем прямо возвращается к этому ViewController, не нажимая на какие-либо установочные точки останова ниже if или segue.EvernoteSession authenticateWithViewController: completeHandler: не запускает завершениеHandler

Любые идеи?

[session authenticateWithViewController:self completionHandler:^(NSError *error) { 
    if (error || !session.isAuthenticated){ 
     if (error) { 
      NSLog(@"Error authenticating with Evernote Cloud API: %@", error); 
     } 
     if (!session.isAuthenticated) { 
      NSLog(@"Session not authenticated"); 
     } 
     UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error" 
                 message:@"Could not authenticate" 
                 delegate:nil 
               cancelButtonTitle:@"OK" 
               otherButtonTitles:nil]; 
     [alert show]; 
    } else { 
     // We're authenticated! 
     EvernoteUserStore *userStore = [EvernoteUserStore userStore]; 
     [userStore getUserWithSuccess:^(EDAMUser *user) { 
      // success 
      NSLog(@"Authenticated as %@", [user username]); 

      [self performSegueWithIdentifier:@"introductionStepOne" sender:self]; 
     } failure:^(NSError *error) { 
      // failure 
      NSLog(@"Error getting user: %@", error); 
     } ]; 
    } 
}]; 

ответ

1

Убедитесь, что вы правильно изменили свой AppDelegate. Более подробная информация здесь: https://github.com/evernote/evernote-sdk-ios#modify-your-appdelegate

Вам нужно добавить:

- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:  (NSString *)sourceApplication annotation:(id)annotation { 
BOOL canHandle = NO; 
    if ([[NSString stringWithFormat:@"en-%@", [[EvernoteSession sharedSession] consumerKey]]  isEqualToString:[url scheme]] == YES) { 
    canHandle = [[EvernoteSession sharedSession] canHandleOpenURL:url]; 
    } 
    return canHandle; 
} 

И

- (void)applicationDidBecomeActive:(UIApplication *)application 
{ 
    // Restart any tasks that were paused (or not yet started) while the application was  inactive. If the application was previously in the background, optionally refresh the user  interface. 
    [[EvernoteSession sharedSession] handleDidBecomeActive]; 
} 
Смежные вопросы