J_D J_D - 5 months ago 17
iOS Question

Dropbox SDK for iOS - Detecting a login cancel

I am starting to use the DropBox SDK for iOS, and I saw that the code to detect if the login was successful or not is something like this:

in AppDelegate:

- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url
{
if ([[DBSession sharedSession] isLinked])
{
// Success
}
else
{
// Failed
}
return YES;
}


In the case of a failure, how can I identify the cause? I would like to at least distinguish between an error and a cancel.

Answer

To identify the Cancel

- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url {

    NSArray *components = [[url path] pathComponents];
    NSString *methodName = [components count] > 1 ? [components objectAtIndex:1] : nil;
    if ([methodName isEqual:@"cancel"]) {
        NSLog(@"Dropbox link Cancelled");
    }
}