When the order of the below #If OBJC blocks with the Webview first then the FaceID block as second, I will generate a whole bunch of errors, with one of them being:
But if I reverse the order with the FaceID #If OBJC block being first, then the Webview block, it compiles OK.
Why is this?
B4X:
/Users/administrator/Documents/UploadedProjects/<user id>/B4iProject/b4i_b4xmainpage.m:585:32: error: property 'bi' not found on object of type 'B4IWebViewUIDelegate *'
[self.__c CallSubDelayed2:self.bi :handler :(subnamefail) :(authError.localizedDescription)];
But if I reverse the order with the FaceID #If OBJC block being first, then the Webview block, it compiles OK.
Why is this?
B4X:
'Webview code below
#if OBJC
@end
@interface B4IWebViewUIDelegate:NSObject<WKUIDelegate>
@end
@implementation B4IWebViewUIDelegate
- (void)webView:(WKWebView *)webView runJavaScriptAlertPanelWithMessage:(NSString *)message initiatedByFrame:(WKFrameInfo *)frame completionHandler:(void (^)(void))completionHandler {
[B4IObjectWrapper raiseEvent:webView :@"_alert:" :@[message]];
completionHandler();
}
- (void)webView:(WKWebView *)webView runJavaScriptConfirmPanelWithMessage:(NSString *)message initiatedByFrame:(WKFrameInfo *)frame completionHandler:(void (^)(BOOL result))completionHandler{
UIAlertController* alert = [UIAlertController alertControllerWithTitle:@"" message:message preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction* okAction = [UIAlertAction actionWithTitle: NSLocalizedString(@"OK", nil) style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {
completionHandler(true);
}];
UIAlertAction* cancelAction = [UIAlertAction actionWithTitle: NSLocalizedString(@"Cancel", nil) style:UIAlertActionStyleCancel handler:^(UIAlertAction * action) {
completionHandler(false);
}];
[alert addAction:okAction];
[alert addAction:cancelAction];
UIViewController *rootVC = [UIApplication sharedApplication].keyWindow.rootViewController;
[rootVC presentViewController:alert animated:YES completion:nil];
}
- (void)webView:(WKWebView *)webView runJavaScriptTextInputPanelWithPrompt:(NSString *)message defaultText:(NSString *)defaultText initiatedByFrame:(WKFrameInfo *)frame completionHandler:(void (^)(NSString * result))completionHandler {
UIAlertController* alert = [UIAlertController alertControllerWithTitle:@"" message:message preferredStyle:UIAlertControllerStyleAlert];
[alert addTextFieldWithConfigurationHandler:^(UITextField * _Nonnull alertTextField) {
alertTextField.keyboardType = 0;
alertTextField.textAlignment = 1;
alertTextField.text = defaultText;
}];
UIAlertAction* okAction = [UIAlertAction actionWithTitle: NSLocalizedString(@"OK", nil) style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {
completionHandler([[alert textFields][0] text]);
}];
UIAlertAction* cancelAction = [UIAlertAction actionWithTitle: NSLocalizedString(@"Cancel", nil) style:UIAlertActionStyleCancel handler:^(UIAlertAction * action) {
completionHandler(@"");
}];
[alert addAction:okAction];
[alert addAction:cancelAction];
UIViewController *rootVC = [UIApplication sharedApplication].keyWindow.rootViewController;
[rootVC presentViewController:alert animated:YES completion:nil];
}
#End If
'face id below
#If OBJC
#import <LocalAuthentication/LocalAuthentication.h>
-(void)TouchID :(NSObject*)handler :(NSString*) subnameok :(NSString*) subnamefail
{
LAContext *myContext = [[LAContext alloc] init];
NSError *authError = nil;
NSString *myLocalizedReasonString = @"Used for quick and secure access to the test app";
if ([myContext canEvaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics error:&authError]) {
[myContext evaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics
localizedReason:myLocalizedReasonString
reply:^(BOOL success, NSError *error) {
if (success) {
[self.__c CallSubDelayed:self.bi :handler :(subnameok)];
} else {
[self.__c CallSubDelayed2:self.bi :handler :(subnamefail) :(error.localizedDescription)];
}
}];
} else {
[self.__c CallSubDelayed2:self.bi :handler :(subnamefail) :(authError.localizedDescription)];
}
}
#End If
Last edited: