2015-10-17 73 views
2

我遵循Evernote github教程“https://github.com/evernote/evernote-cloud-sdk-ios/blob/master/Getting_Started.md”将我的iOS应用程序中的笔记上传到evernote中。运行和构建后,我无法在我的沙盒帐户中创建注释。Evernote SDK:无法将笔记上传到我的沙盒帐户

//AppDelegate.m 
#import <ENSDK/ENSDK.h> 
@implementation AppDelegate 

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

// Initial development is done on the sandbox service 
// When you want to connect to production, just pass "nil" for "optionalHost" 
NSString *SANDBOX_HOST = ENSessionHostSandbox; 

// Fill in the consumer key and secret with the values that you received from Evernote 
// To get an API key, visit http://dev.evernote.com/documentation/cloud/ 
NSString *CONSUMER_KEY = @"my_consumerkey"; 
NSString *CONSUMER_SECRET = @"my_consumer_secret"; 

[ENSession setSharedSessionConsumerKey:CONSUMER_KEY 
         consumerSecret:CONSUMER_SECRET 
          optionalHost:SANDBOX_HOST]; 
} 

//My EditTextController 
#import "EditTextController.h" 
#import <ENSDK/ENSDK.h> 
@implementation EditTextController 

- (void)viewDidLoad { 
[super viewDidLoad]; 
// Do any additional setup after loading the view. 
[self.textEditor setText:self.textstring]; 
_textEditor.font = [UIFont fontWithName:@"HelveticaNeue" size:24]; 
_textEditor.textColor = [UIColor blueColor]; 

//Initializing and creating ENNote and assigning a note content 
ENNote * note = [[ENNote alloc] init]; 
note.content = [ENNoteContent noteContentWithString:self.textstring]; 
note.title = @"My First Note"; 
[[ENSession sharedSession] uploadNote:note notebook:nil completion:^(ENNoteRef * noteRef, NSError * uploadNoteError) { 
     if (uploadNoteError==nil) { 
     NSLog(@"Upload successful"); 
    } 
    else 
     NSLog(@"Error%@",uploadNoteError); 
}]; 
} 

//错误是域名= ENErrorDomain代码= 2“(空)”

回答

2

您似乎没有实际验证任何用户在这里。在调用-uploadNote:..方法之前,您需要对用户进行身份验证,以便SDK在调用服务时成功连接到特定用户的帐户。

Details are here在Github的入门指南文档中,但基本上你需要在你的用户界面中拥有某种“连接Evernote”按钮并从那里调用-authenticateWithViewController...方法等。

(如果你只是黑客周围对其进行测试,尝试在-viewDidLoad(或-viewDidAppear)方法把它扔,并调用上传注意到的东西,在其完成块。)

0

我的肢体,走出去,承担错误代码对应于这里定义的ENErrorCode枚举:

https://github.com/evernote/evernote-cloud-sdk-ios/blob/master/evernote-sdk-ios/ENSDK/ENError.h#L36

“2”将是重头戏部分,即,ENErrorCodeAuthExpired,这将表明有什么东西不对您的身份验证凭据。

+0

与证书没有问题。我刚刚生成了新的API密钥并重复了相同的过程。 – WasimSafdar

+0

什么在你的'ENSession'实例上调用'isAuthenticated'产出?看起来像[这是检查](https://github.com/evernote/evernote-cloud-sdk-ios/blob/master/evernote-sdk-ios/ENSDK/ENSession.m#L852),引发'ENErrorCodeAuthExpired '错误。 – heypiotr

+0

错误不在isAuthenticated。我把断点并检查。这意味着它是验证。 – WasimSafdar

相关问题