我按照Evernote github教程“https://github.com/evernote/evernote-cloud-sdk-ios/blob/master/Getting_Started.md”将我的iOS应用程序中的注释上传到evernote。运行和构建后,我无法在我的沙箱帐户中创建备注。
//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);
}];
}
//错误是Domain = ENErrorDomain Code = 2“(null)”
答案 0 :(得分:2)
您似乎并未在此处对任何用户进行身份验证。在调用-uploadNote:..
方法之前,您需要对用户进行身份验证,以便SDK在拨打服务时成功连接到特定用户的帐户。
Details are here,但基本上你需要在你的用户界面中有一个地方可以连接到Evernote&#34;按钮并从那里调用-authenticateWithViewController...
方法等。
(如果您只是在进行测试,请尝试将其投放到-viewDidLoad
(或-viewDidAppear
)方法中,并在其完成块中调用上传注释内容。)< / p>
答案 1 :(得分:0)
我会走出困境,并假设错误代码对应于此处定义的ENErrorCode
枚举:
https://github.com/evernote/evernote-cloud-sdk-ios/blob/master/evernote-sdk-ios/ENSDK/ENError.h#L36
&#34; 2&#34;将是突出部分,即ENErrorCodeAuthExpired
,这表明您的身份证明存在问题。