I’ve got an SFAuthoizationView I’m using in my app and I’m trying to call the authorize method from my code to prompt the user to authorize if they currently are not authorized.
My issue is that this method does not seem to work!
My code is as follows, where authView is the SFAuthorizationView and authorizeMe is the method that gets called when a button is clicked (and the log message does show, so I know it’s getting called).
If the lock is locked the authorize message just returns false and does not seem to prompt the user for a password.
Does anybody know what’s up with this?
- (void) mainViewDidLoad {
[authView setDelegate:self];
[authView setString:"Test String"];
[authView setAutoupdate:YES];
}
- (IBAction)authorizeMe:(id)sender {
NSLog(@"Authorizing...");
[authView authorize:authView];
}
- (void)authorizationViewDidAuthorize:(SFAuthorizationView *)view {
self.enabled = YES;
}
- (void)authorizationViewDidDeauthorize:(SFAuthorizationView *)view {
self.enabled = NO;
}
I had this same problem and I’ve noticed a few things.
In order for the SFAuthorizationView authorize method to interact with the user you MUST set BOTH of these flags when initializing the SFAuthorizationView:
However, I don’t think the SFAuthorizationView was designed to be used this way.
After setting these flags calls to [m_authView updateStatus:m_authView]; cause the user to be prompted for Admin credentials, and if you set [m_authView setAutoupdate:YES]; the user will be randomly prompted for a password and the prompt will not go away when the user click cancel!
I believe the SFAuthorizationView authorize method suppresses user interaction on purpose.
It seems as though there is another method you can call instead of authorize: (void)buttonPressed:(id)sender. This method isn’t documented and it will generate compilation warnings, but it does work on 10.6.