what you can do is, first of all replace your that function(the function that you posted) by below function...(in Appdelegate.m file)
- (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
NSArray *tmp=[self.navigationController viewControllers];
for(int i=0;i<[tmp count];i++){
if([[tmp objectAtIndex:i] isKindOfClass:[YourViewController class]]){//YourViewController is a class in which you want to implement dropbox sdk...
//[self.navigationController popToViewController:[tmp objectAtIndex:i] animated:YES];
[[tmp objectAtIndex:i] uploadToDropBox];
break;
}
}
}
return YES;
}
return NO;
}
now In "YourViewController" class in which the file is present which you want to upload on dropbox..write below code in that file(.m file)
-(void)uploadToDropBox
{
NSString *strzipname=[NSString stringWithFormat:@"%@_Document.zip",strname];
NSString *path = [DOCUMENTS_FOLDER stringByAppendingPathComponent:strzipname];
NSString *destDir = @"/";
restClient = [[DBRestClient alloc] initWithSession:[DBSession sharedSession]];//DBRestClient *restClient; declare object in .h file
restClient.delegate = self;
[restClient uploadFile:strzipname toPath:destDir withParentRev:nil fromPath:path];//strzipname is a file name,"path" is path where that file is located
}
finally implement delegate method of dropbox...
- (void)restClient:(DBRestClient*)client uploadedFile:(NSString*)destPath
from:(NSString*)srcPath metadata:(DBMetadata*)metadata {
NSLog(@"File uploaded successfully to path: %@", metadata.path);
}
- (void)restClient:(DBRestClient*)client uploadFileFailedWithError:(NSError*)error {
NSLog(@"File upload failed with error - %@", error);
}
dont foreget to declare uploadToDropBox in .h file...
let me know it is working or not!!!
Happy Coding!!!!