首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >EvernoteSession authenticateWithViewController:completionHandler:不会触发completionHandler

EvernoteSession authenticateWithViewController:completionHandler:不会触发completionHandler
EN

Stack Overflow用户
提问于 2013-03-25 23:41:34
回答 1查看 218关注 0票数 1

当我在调试模式下在iPhone模拟器中进行身份验证时,将运行下面代码中的第一条if语句。但是,当我在安装了Evernote客户端的iPhone上调试时,if语句看起来并未计算。相反,Evernote iOS应用程序只会出现一小段时间,然后直接返回到这个ViewController,而不会触及if下面的任何设置断点,也不会触及正在被触发的segue。

有什么想法吗?

代码语言:javascript
复制
[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);
        } ];
    }
}];
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-03-26 09:01:15

确保您正确地修改了AppDelegate。更多信息请点击此处:https://github.com/evernote/evernote-sdk-ios#modify-your-appdelegate

您需要添加:

代码语言:javascript
复制
- (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;
}

代码语言:javascript
复制
- (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];
}
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/15618946

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档