gpt4 book ai didi

ios - Dropbox sdk 401 Error getting for iPhone 5 but not in iPhone 6 for the same app in Xcode 6

转载 作者:行者123 更新时间:2023-11-29 10:35:28 25 4
gpt4 key购买 nike

我引用了下面的 url 并尝试解决问题,但仍然无法解决问题。请帮帮我。

Dropbox SDK 401 Error

我的应用程序在 iPhone 6 上运行,但在 iPhone 5 或 5s 上运行相同的应用程序时显示错误:

[WARNING] DropboxSDK: error making request to /1/metadata/dropbox/ALLCREW.TXT - (401)           No auth method found.
2014-12-11 16:58:14.628 user_schedule_3[2331:112832] Error loading metadata: Error Domain=dropbox.com Code=401 "The operation couldn’t be completed. (dropbox.com error 401.)" UserInfo=0x7fbb50d851c0 {path=/ALLCREW.TXT, error=No auth method found.}.

代码如下:AppDelegate.m:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:  (NSDictionary *)launchOptions
{
// Override point for customization after application launch.
DBSession *dbSession = [[DBSession alloc]
initWithAppKey:@"******h4xl9l4o"
appSecret:@"*******1ujh8"
root:kDBRootDropbox]; // either kDBRootAppFolder or kDBRootDropbox
[DBSession setSharedSession:dbSession];
// NSString *listValue = @"NAME";
return YES;
}


- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url
sourceApplication:(NSString *)source annotation:(id)annotation {
if ([[DBSession sharedSession] handleOpenURL:url]) {
if ([[DBSession sharedSession] isLinked]) {
NSLog(@"dropbox linked successfully!");
[[NSNotificationCenter defaultCenter] postNotificationName:@"updateRoot" object:nil];
NSLog(@"came out");
// At this point you can start making API calls
}
return YES;
}
// Add whatever other url handling code your app requires here
return NO;
}

View Controller :

   - (IBAction)didPressLink {
if (![[DBSession sharedSession] isLinked]) {
[[DBSession sharedSession] linkFromController:self];
NSLog(@"did press link is linked");
} else {
NSLog(@"did press link is reached");
}
}



NSString *filename = @"ALLCREW.TXT";
NSString *localDir = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)[0];
NSString *localPath = [localDir stringByAppendingPathComponent:filename];
[self.restClient loadMetadata:@"/ALLCREW.TXT"];
//[self.restClient loadFile:@"/ALLCREW.TXT" intoPath:localPath];
NSString *contentOfFile = [NSString stringWithContentsOfFile:localPath encoding:NSUTF8StringEncoding error:nil];
NSArray *stringWithEnter = [contentOfFile componentsSeparatedByString: @"\n"];



- (void)restClient:(DBRestClient *)client
loadMetadataFailedWithError:(NSError *)error {
NSLog(@"Error loading metadata: %@", error);
}



- (void)restClient:(DBRestClient *)client loadedFile:(NSString *)localPath
contentType:(NSString *)contentType metadata:(DBMetadata *)metadata {
NSLog(@"File loaded into path: %@", localPath);
[self getEntry ];
[self.tableView reloadData];
[spinner stopAnimating];
self.navigationItem.rightBarButtonItem.enabled = true;
}



- (void)restClient:(DBRestClient *)client loadFileFailedWithError:(NSError *)error {
NSLog(@"There was an error loading the file: %@", error);
}

最佳答案

我遇到了同样的问题。解决方案最终是您必须添加:

- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url {
if ([[DBSession sharedSession] handleOpenURL:url]) {
if ([[DBSession sharedSession] isLinked]) {
NSLog(@"App linked successfully!");
// At this point you can start making API calls
}
return YES;
}
// Add whatever other url handling code your app requires here
return NO;
}

你似乎有这段代码:

 - (BOOL)application:(UIApplication *)app openURL:(NSURL *)url sourceApplication:(NSString *)source annotation:(id)annotation;

将代码移动到 handleOpenURL: 应该可以解决这个问题。

还要确保链接 Security.framework!

来源:http://innofied.com/integration-of-dropbox-in-ios-applications/

关于ios - Dropbox sdk 401 Error getting for iPhone 5 but not in iPhone 6 for the same app in Xcode 6,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27425268/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com