0

I'm building SDK for my product and there will be no app delegate class. I used Dropbox Integration in my SDK, so I'm bound to use following method.

- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url {
    NSString *stringUrl = [url absoluteString];
    if ([stringUrl containsString:@"cancel"]) {

        // Handle if user cancelled the login
        [[NSNotificationCenter defaultCenter] postNotificationName:@"dropboxRegistrationCancel" object:self];
        return NO;
    }

    if ([[DBSession sharedSession] handleOpenURL:url]) {
        if ([[DBSession sharedSession] isLinked]) {
            NSLog(@"App linked successfully!");
            // At this point you can start making API calls
             [[NSNotificationCenter defaultCenter] postNotificationName:ApplicationComeBackFromDropBoxLoginPage object:self];
        }
        return YES;
    }
    // Add whatever other url handling code your app requires here
    return NO;
}

So Issue is there is no app delegate than how can use above method? Or any alternate solution for this to use this in another class (like to inherit UIResponder class). Looking for help.

Aleem
  • 3,173
  • 5
  • 33
  • 71

1 Answers1

0

If you are building a SDK with no appDelegate, then well, you have nothing to do. It will be in your project where you will be using your sdk that you will have to add this line. By the way, the line NSString *stringUrl = [url absoluteString]; is absolutly useless since you are not using stringUrl later on, and the

- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url {
// NSString *stringUrl = [url absoluteString];
return YES;
}

just means: yes you can quit my app to open another app when the user click on a link. No biggy....

Florian Burel
  • 3,408
  • 1
  • 19
  • 20
  • Thanks Florian, Kindly see my updated question in which I complete shown method. I am using this method for differentiation either user click on cancel button or login successfully. – Aleem Aug 15 '16 at 12:55
  • Plus this is part of SDK instead of app, user can pick file from dropbox – Aleem Aug 15 '16 at 12:56
  • As you mentioned "It will be in your project where you will be using your sdk" I want to add this my SDK, I know I can add this in project and can mention in SDK documentation but first I want to solve this if this can handle within SDK. Can I achieve my task without mentioned this method ? – Aleem Aug 15 '16 at 12:58
  • I would extract the logic in a class of my sdk so in the appDelegate, the end user wouold have only to write something like return [MySDKHandler should0penUrl:url] but it doen't change the fact that only in the AppDelegate of the final product can the method application:handleOpenURL: go. – Florian Burel Aug 15 '16 at 13:01
  • You are develloping a SDK, meaning you have no AppDelegate, so you have nothing to do about the AppDelegate handleOpenURL method. It will be in your final product, the one in which you will use your sdk, which will have an App delegate that you will have to rewrite this bit of code ou paste in your question. – Florian Burel Aug 15 '16 at 13:13