当我在调试模式下在iPhone模拟器中进行身份验证时,将运行下面代码中的第一条if语句。但是,当我在安装了Evernote客户端的iPhone上调试时,if语句看起来并未计算。相反,Evernote iOS应用程序只会出现一小段时间,然后直接返回到这个ViewController,而不会触及if下面的任何设置断点,也不会触及正在被触发的segue。
有什么想法吗?
[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);
} ];
}
}];发布于 2013-03-26 09:01:15
确保您正确地修改了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];
}https://stackoverflow.com/questions/15618946
复制相似问题