2015-10-17 71 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

相關問題