Dropbox SDK - linkFromController: delegate or callback?

前端 未结 2 1514
有刺的猬
有刺的猬 2021-01-04 13:48

I\'m adding Dropbox to my app using the SDK available on their site. Is there any way of calling some method once [[DBSession sharedSession] linkFromController:self];<

2条回答
  •  半阙折子戏
    2021-01-04 14:25

    in App delegate add:

    - (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url { 
        if ([[DBSession sharedSession] handleOpenURL:url]) {
    
            [[NSNotificationCenter defaultCenter]
             postNotificationName:@"isDropboxLinked"
             object:[NSNumber numberWithBool:[[DBSession sharedSession] isLinked]]];
    
            return YES;
        }
    
        return NO;
    }
    

    and in you custom class:

    - (void)viewDidLoad {
        [super viewDidLoad];
    
        //Add observer to see the changes
        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(isDropboxLinkedHandle:) name:@"isDropboxLinked" object:nil];
    
    }
    

    and

      - (void)isDropboxLinkedHandle:(id)sender
    {
        if ([[sender object] intValue]) {
           //is linked.
        }
        else {
           //is not linked
        }
    }
    

提交回复
热议问题