cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Want to learn some quick and useful tips to make your day easier? Check out how Calvin uses Replay to get feedback from other teams at Dropbox here.

Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

checkAndPerformV1TokenMigration

checkAndPerformV1TokenMigration

timeflying
New member | Level 2

I add a fuction with named checkAndPerformV1TokenMigration as following :

 

-(void)performDropboxMigrationFromV1ToV2
{
  BOOL willPerformMigration = [DBClientsManager checkAndPerformV1TokenMigration:^(BOOL shouldRetry, BOOL invalidAppKeyOrSecret,
                                                                                  NSArray<NSArray<NSString *> *> *unsuccessfullyMigratedTokenData) {
    if (invalidAppKeyOrSecret) {
      // Developers should ensure that the appropriate app key and secret are being supplied.
      // If your app has multiple app keys / secrets, then run this migration method for
      // each app key / secret combination, and ignore this boolean.
    }
    
    if (shouldRetry) {
      // Store this BOOL somewhere to retry when network connection has returned
    }
    
    if ([unsuccessfullyMigratedTokenData count] != 0) {
      NSLog(@"The following tokens were unsucessfully migrated:");
      for (NSArray<NSString *> *tokenData in unsuccessfullyMigratedTokenData) {
        NSLog(@"DropboxUserID: %@, AccessToken: %@, AccessTokenSecret: %@, StoredAppKey: %@", tokenData[0],
              tokenData[1], tokenData[2], tokenData[3]);
      }
    }
    
    if (!invalidAppKeyOrSecret && !shouldRetry && [unsuccessfullyMigratedTokenData count] == 0) {
      [DBClientsManager setupWithAppKey:DROPBOX_APP_KEY];
    }
  } queue:nil appKey:DROPBOX_APP_KEY appSecret:DROPBOX_APP_SECRET];
  
  if (!willPerformMigration) {
    [DBClientsManager setupWithAppKey:DROPBOX_APP_KEY];
  }
}

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[self performDropboxMigrationFromV1ToV2];

// Do I still need add following line code:
// [DBClientsManager setupWithAppKey:@"<APP_KEY>"]; ??

return YES;
}

I perform the function  in didFinishLaunchWithOption function but after taht.

Do I still need add [DBClientsManager setupWithAppKey:@"<APP_KEY>"] indidFinishLaunchWithOption ?? 

1 Reply 1

Greg-DB
Dropbox Staff
No, looking at the code you have, you don't need to also call it in didFinishLaunchingWithOptions.

For reference, whether or not you're running the checkAndPerformV1TokenMigration method, you need to make sure you call setupWithAppKey once.

If you're not using the migration, you can just call setupWithAppKey in didFinishLaunchingWithOptions.

If you are using the migration, as you are, the code you have will already make sure setupWithAppKey is called once, either at the end of the successful or failed migration, so you don't need to additionally call elsewhere.
Need more support?
Who's talking

Top contributors to this post

  • User avatar
    Greg-DB Dropbox Staff
What do Dropbox user levels mean?