objective-cxcodecocoasimperium

Simperium, getting delegate notifications of AuthManager


Ok, i am totally stuck and was wondering is anyone could point out what must be the obvious mistake i am making.

I am using Simperium (dev branch) in a project, and want to get a notification in my main AppDelegate if the user dismisses the authentication window.

Now in the SPAutheticationManager.m file is the following code:

- (void)cancel {
    DDLogVerbose(@"Simperium authentication cancelled");

    if ([delegate respondsToSelector:@selector(authenticationDidCancel)])
        [delegate authenticationDidCancel];
}

I have set a breakpoint and this is definitely being called when the window is dismissed.

Now, i have added SPAuthenticationDelegate to my implementation in my AppDelegate, and then added the following code to AppDelegate.m

-(void)authenticationDidCancel {
    NSLog(@"Authetication Cancelled");

}

But, this isn't getting called, and i can't work out why???

Anyone have any idea what i'm missing here?

Thanks

Gareth


Solution

  • In case anyone else hits this, there is no way to do this without implementing a custom delegate method in simperium.h and making your AppDelegate.h a delegate of it.

    In simperium.h

    - (void)didCancelAuth;
    

    Then in simperium.m authenticationDidCancel method add:

    if ([delegate respondsToSelector:@selector(didCancelAuth)]) {
        [delegate didCancelAuth];
    }
    

    Then set your appDelegate as simperium's delegate and add:

    - (void)didCancelAuth
    {
        //auth has been cancelled
    }
    

    you also need to make sure your appdelegate is a delegate by doing something like

    self.simperium.delegate = self;
    

    Cheers

    Gareth