We Want to Hear From You! What Do You Want to See on the Community? Tell us here!

Forum Discussion

timeflying's avatar
timeflying
New member | Level 2
9 years ago

checkAndPerformV1TokenMigration

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

  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Community Moderator rankDropbox Community Moderator
    9 years ago
    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.

About Dropbox API Support & Feedback

Node avatar for Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.6,036 PostsLatest Activity: 2 days ago
411 Following

The Dropbox Community team is active from Monday to Friday. We try to respond to you as soon as we can, usually within 2 hours.

If 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!