iOS Question Webview Basic authentication


Well-Known Member
Licensed User
Longtime User
i try to open a website wich has a basic http authentication.
While in B4A i use WebView_UserAndPasswordRequired with success, this doesnt exist in B4i.
So i switched to WKWebView and use:

#if ObjC

@interface B4IWKWebViewDelegate:NSObject <WKNavigationDelegate, WKUIDelegate>

@implementation B4IWKWebViewDelegate (new)
    - (void)webView:(WKWebView *)webView
        didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge
        completionHandler:(void (^)(NSURLSessionAuthChallengeDisposition disposition, NSURLCredential *credential))completionHandler{
        B4IArray* B4ICred = [B4IObjectWrapper raiseEvent:webView :@"_userandpasswordrequired:" :@[webView.URL.absoluteString]];
        NSArray* Cred = B4ICred.objectsData;
        NSURLCredential *UrlCred = [NSURLCredential credentialWithUser:Cred[0] password:Cred[1] persistence:NSURLCredentialPersistenceForSession];
#End If

unfortunally WebView1_userandpasswordrequired(Url As String) never raises.
i think it works once (not sure), but after that never again.

How to solve this?

I also read that Erel wants to add this option, but this was 3 years ago :-(
Last edited: