We are aware of the issue with the badge emails resending to everyone, we apologise for the inconvenience - learn more here.
Forum Discussion
purringpigeon
8 years agoExplorer | Level 4
Help migrating from v1 to v2 Objective C
Hello,
I am not very familiar with Dropbox API, though I got version 1 working just fine on my app. But I am not really following the path from V1 to V2 all that well.
I am attempting to do some very simple things, but find this new API hard to digest I thought I would ask.
App Delegate Code went from this:
DBSession *dbSession = [[DBSession alloc] initWithAppKey:@"my key" appSecret:@"my secret" root:kDBRootAppFolder]; // either kDBRootAppFolder or kDBRootDropbox [DBSession setSharedSession:dbSession];
To This:
[DropboxClientsManager setupWithAppKey:@"my key"];
Initially I did the following:
if ([[DBSession sharedSession] isLinked]) { [self.restClient loadMetadata:@"/"]; }
I replaced with this:
if([DropboxClientsManager authorizedClient] != nil ) { [[client.filesRoutes getMetadata:@"/"]response:^(DBFILESMetadata * _Nullable result, DBFILESGetMetadataError * _Nullable routeError, DBRequestError * _Nullable error) {}
I am not sure if I missed anything, but I can't seem to get back from that, it it always thinks it's not approved in the ios simulator.
My original calls are this:
[restClient loadMetadata:@"/"]; [restClient uploadFile:fileName toPath:destDir withParentRev:rev fromPath:path]; [restClient loadFile:@"" into:localpath];
However after the first link, it doesn't seem to stick...
- Greg-DBDropbox Staff
Did you follow all of the instructions for setting up the app authorization flow?
https://github.com/dropbox/dropbox-sdk-obj-c#handling-the-authorization-flow
If so, what error(s) are you getting?
A few notes from what you shared so far though:
- In API v2, the Dropbox root folder is identified by the empty string "", not "/".
- The getMetadata method doesn't supported the root folder. In API v2, you should use listFolder[Continue] to list the contents of folders.
- You can use reauthorizeClient to retrieve a previously authorized client.
- purringpigeonExplorer | Level 4
From what I can tell - yes....
This is the exception being thrown.
2017-01-03 13:59:38.192 ServiceReport[14621:705002] -canOpenURL: failed for URL: "dbapi-8-emm://1/connect" - error: "The operation couldn’t be completed. (OSStatus error -10814.)"
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { //Set up dropbox link [DropboxClientsManager setupWithAppKey:@"mykey"]; return YES; }
- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options { DBOAuthResult *authResult = [DropboxClientsManager handleRedirectURL:url]; if (authResult != nil) { if ([authResult isSuccess]) { NSLog(@"Success! User is logged into Dropbox."); } else if ([authResult isCancel]) { NSLog(@"Authorization flow was manually canceled by user!"); } else if ([authResult isError]) { NSLog(@"Error: %@", authResult); } } return NO; }
I get the window to log in and get success but then it doesn't remember it next time I launch.
My baisc use case is pretty simple
1) Check to see if I am linked to dropbox.
2) Check to see if 3 specific files exsit (if not I assume no backup was done)
3) Provide an option to link to DB
4) Provide an option to perform a back up - this just copies three files up
5) Provide an option to restore from a backup - this just copies the three files down.
It was pretty straight forward before, but I am getting lost in the translation to the new API.
- Greg-DBDropbox Staff
The canOpenURL error would just indicate that the application being looked for (i.e., the official Dropbox app in this case) isn't found. That's expected on the simulator, or on a device without the official device installed. This error is safe to ignore, as the SDK will fall back to using the browser.
Can you share the steps to reproduce, code, and output/error for the isue with it not remembering the user?
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
5,877 PostsLatest Activity: 12 months agoIf you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X or Facebook.
For more info on available support options for your Dropbox plan, see this article.
If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!