我在下面提到了url并试图解决问题,但仍然无法解决问题。 请帮帮我。
我的应用程序在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;
}
查看控制器:
- (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);
}
答案 0 :(得分:2)
我有同样的问题。解决方案最终是您必须添加:
- (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/