Simperium, getting delegate notifications of AuthManager

88 Views Asked by At

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

2

There are 2 best solutions below

0
On BEST ANSWER

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

0
On

Just wanted to let you know that we've just added a brand new 'login cancelled' delegate method (Commit here: https://github.com/Simperium/simperium-ios/commit/5cae8a157786a48ffe1cc649f898341eb9cf51bf in develop branch).

Thanks for helping us improve Simperium!