私はevernoteとの統合を備えたアプリケーションを開発していますが、すべて問題なく動作します。別のユーザーとして、それはまだdownlodと前のアカウントへのメモをuplode、しかし、ログインは成功です。 私は、ユーザー名とパスワードtextfiledsためNsuserDefaultを入れて、それをsyncoronizeと共有class.myログインsinglton Evernoteの中でそれを渡し、このNSUserDefaultは機能しません
のように見えます-(IBAction)_clickevernotelogin:(id)sender
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
// Keep this key private
NSString *consumerKey = [[[NSString alloc]
initWithString: @"myapp" ] autorelease];
[[NSUserDefaults standardUserDefaults] setObject:consumerKey forKey:@"consumerkeyevrnote"];
NSString *consumerSecret = [[[NSString alloc]
initWithString: @"agft5623636"] autorelease];
NSURL *userStoreUri = [[[NSURL alloc]
initWithString: @"https://www.evernote.com/edam/user"] autorelease];
NSString *noteStoreUriBase = [[[NSString alloc]
initWithString: @"https://www.evernote.com/edam/note/"] autorelease];
// These are for test purposes. At some point the user will provide his/her own.
NSString *username = [[[NSString alloc]
initWithString: _txtevernoteUsername.text] autorelease];
NSString *password = [[[NSString alloc]
initWithString: _txtevernotepasswrd.text] autorelease];
[[NSUserDefaults standardUserDefaults] setObject:_txtevernoteUsername.text forKey:@"usernameever"];
[[NSUserDefaults standardUserDefaults] setObject:_txtevernotepasswrd.text forKey:@"passwrdevernote"];
[[NSUserDefaults standardUserDefaults]synchronize];
THTTPClient *userStoreHttpClient = [[[THTTPClient alloc]
initWithURL:userStoreUri] autorelease];
TBinaryProtocol *userStoreProtocol = [[[TBinaryProtocol alloc]
initWithTransport:userStoreHttpClient] autorelease];
EDAMUserStoreClient *userStore = [[[EDAMUserStoreClient alloc]
initWithProtocol:userStoreProtocol] autorelease];
EDAMNotebook* defaultNotebook = NULL;
BOOL versionOk = [userStore checkVersion:@"Cocoa EDAMTest" :
[EDAMUserStoreConstants EDAM_VERSION_MAJOR] :
[EDAMUserStoreConstants EDAM_VERSION_MINOR]];
if (versionOk == YES)
{
@try {
NSError *error = nil;
NSString *unameever = _txtevernoteUsername.text;
NSString *pwdever = _txtevernotepasswrd.text;
[[NSUserDefaults standardUserDefaults] setObject:unameever forKey:@"usernameever"];
BOOL flag = [SFHFKeychainUtils storeUsername:unameever andPassword:pwdever forServiceName:@"mybibleappever" updateExisting:TRUE error:&error];
EDAMAuthenticationResult* authResult =
[userStore authenticate:username :password
:consumerKey :consumerSecret];
EDAMUser *user = [authResult user];
NSString *authToken = [authResult authenticationToken];
NSLog(@"Authentication was successful for: %@", [user username]);
NSLog(@"Authentication token: %@", authToken);
[[NSUserDefaults standardUserDefaults] setObject:authToken forKey:@"usernameevernotetocken"];
[[NSUserDefaults standardUserDefaults] setObject:[user username] forKey:@"usernameevernoteshow"];
NSURL *noteStoreUri = [[[NSURL alloc]
initWithString:[NSString stringWithFormat:@"%@%@",
noteStoreUriBase, [user shardId]] ]autorelease];
}
@catch (EDAMUserException * e) {
NSString * errorMessage = [NSString stringWithFormat:@"Please enter valid username & password", [e errorCode]];
UIAlertView *alertDone = [[UIAlertView alloc] initWithTitle: @"Evernote" message: errorMessage delegate: self cancelButtonTitle: @"Ok" otherButtonTitles: nil];
_acteverloginimage.hidden = YES;
_acteverlogin.hidden =YES;
[alertDone show];
[alertDone release];
return;
}
[pool drain];
}
私のログアウトがこの
[_btnusernameshow setTitle:nil forState:UIControlStateNormal];
NSError *error = nil;
NSString *usernameever = [[NSUserDefaults standardUserDefaults] objectForKey:@"usernameever"];
BOOL flag = [SFHFKeychainUtils deleteItemForUsername:usernameever andServiceName:@"mybibleappever" error:&error];
[[NSUserDefaults standardUserDefaults ]removeObjectForKey:@"usernameevernote"];
[[NSUserDefaults standardUserDefaults ]removeObjectForKey:@"passwrdevernote"];
[[NSUserDefaults standardUserDefaults ]removeObjectForKey:@"usernameevernotetocken"];
[[NSUserDefaults standardUserDefaults ]removeObjectForKey:@"usernameever"];
のように見える私のEvernote singltonクラスインスタンスを共有し、ここでこの ようになり、私はこのクラスに
- (void) connect {
if (authToken == nil)
{
// In the case we are not connected we don't have an authToken
// Instantiate the Thrift objects
NSURL * NSURLuserStoreUri = [[[NSURL alloc] initWithString: userStoreUri] autorelease];
THTTPClient *userStoreHttpClient = [[[THTTPClient alloc] initWithURL: NSURLuserStoreUri] autorelease];
TBinaryProtocol *userStoreProtocol = [[[TBinaryProtocol alloc] initWithTransport:userStoreHttpClient] autorelease];
EDAMUserStoreClient *userStore = [[[EDAMUserStoreClient alloc] initWithProtocol:userStoreProtocol] autorelease];
// Check that we can talk to the server
bool versionOk = [userStore checkVersion: applicationName :[EDAMUserStoreConstants EDAM_VERSION_MAJOR] : [EDAMUserStoreConstants EDAM_VERSION_MINOR]];
if (!versionOk) {
// Alerting the user that the note was created
UIAlertView *alertDone = [[UIAlertView alloc] initWithTitle: @"Evernote" message: @"Incompatible EDAM client protocol version" delegate: self cancelButtonTitle: @"Ok" otherButtonTitles: nil];
[alertDone show];
[alertDone release];
return;
}
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(evrloginnotif:) name:@"evrloginnotiff" object:nil];
//Checks if there is a saved User Name
NSError *error = nil;
if([defaults objectForKey:@"usernameever"]&&[defaults objectForKey:@"passwrdevernote"])
{
username = [defaults objectForKey:@"usernameever"];
password = [defaults objectForKey:@"passwrdevernote"];
//BOOL flag = [SFHFKeychainUtils storeUsername:username andPassword:password forServiceName:@"mybibleappever" updateExisting:TRUE error:&error];
// Returned result from the Evernote servers after authentication
EDAMAuthenticationResult* authResult =[userStore authenticate:username :password : consumerKey :consumerSecret];
// User object describing the account
self.user = [authResult user];
// We are going to save the authentication token
self.authToken = [authResult authenticationToken];
// and the shard id
self.shardId = [user shardId];
// Creating the user's noteStore's URL
noteStoreUri = [[[NSURL alloc] initWithString:[NSString stringWithFormat:@"%@%@", noteStoreUriBase, shardId] ] autorelease];
// Creating the User-Agent
UIDevice *device = [UIDevice currentDevice];
NSString * userAgent = [NSString stringWithFormat:@"%@/%@;%@(%@)/%@", applicationName,applicationVersion, [device systemName], [device model], [device systemVersion]];
// Initializing the NoteStore client
THTTPClient *noteStoreHttpClient = [[[THTTPClient alloc] initWithURL:noteStoreUri userAgent: userAgent timeout:15000] autorelease];
TBinaryProtocol *noteStoreProtocol = [[[TBinaryProtocol alloc] initWithTransport:noteStoreHttpClient] autorelease];
noteStore = [[[EDAMNoteStoreClient alloc] initWithProtocol:noteStoreProtocol] retain];
}
}
}
を認証情報を変更するにはnsuerdefault値を渡しています
どのようにこのバグを解決するためには,,おかげ EDIT
が、私はアプリを再構築するとき、私は多分あなたは、オブジェクトを削除しなければならない
私はこのコードをどこに置いたのですか?ログアウトには? – stackiphone
yesログアウトボタンをクリックします。 –
それはworrkinggggではありません – stackiphone