I started to learn the Dropbox API for the application that I have, where I would like the user to be able to back up the database file. The problem that I encountered is that after the user associates the application with his account (similar to logging in via Facebook), the application does not return to the foreground. When I manually return to the application, it is still on the backup screen, but the account was not connected (as far as I can tell), and the delegate method of the application handleOpenUrl is not called.
Any ideas? or maybe someone knows a good tutorial for this. The Dropbox sample application works just fine, and I'm working hard to use it as a guide, but obviously I messed up something.
Application Delegate:
In the main menu, the user clicks the backup button and opens the following controller:
#import "BackupManagerViewController.h" #import <DropboxSDK/DropboxSDK.h> #import <stdlib.h> @interface BackupManagerViewController () <DBRestClientDelegate> //@property (nonatomic, readonly) DBRestClient* restClient; @end @implementation BackupManagerViewController @synthesize itemsArray,delegate; - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; if (self) { // Custom initialization } return self; } #pragma mark - View lifecycle - (void)viewDidLoad { //[super viewDidLoad]; // Do any additional setup after loading the view from its nib. } -(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)orientation { return (orientation != UIDeviceOrientationLandscapeLeft) && (orientation != UIDeviceOrientationLandscapeRight); } - (IBAction)didPressLink { if (![[DBSession sharedSession] isLinked]) { [[DBSession sharedSession] link]; } else { [[DBSession sharedSession] unlinkAll]; [[[[UIAlertView alloc] initWithTitle:@"Account Unlinked!" message:@"Your dropbox account has been unlinked" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil] autorelease] show]; } } -(DBRestClient *)restClient{ if (restClient == nil) { restClient = [[DBRestClient alloc]initWithSession:[DBSession sharedSession]]; restClient.delegate = self; } return restClient; } -(IBAction) closeButtonPressed { [delegate closeBackupManager]; } @end
source share