iOS Question Where is WKWebview?

JohnC

Expert
Licensed User
Longtime User
After a few year pause, I am returning to B4i to do a simple website wrapper app.

So, I uninstalled my previous version of B4i and purchased and installed the latest B4i 8.10

I created a new B4xPage project (this is my first B4xpage project) and I added "webview" to a new layout in B4i's designer.

Everything seems like it is working great...Except when I click a link that is suppose to display a javascript alert pop-up dialog - nothing happens.

So, I came across this thread:


...and it looks like I am suppose to "deligate" something, but when I try to use the posted example code, it gives a "unknown type: wkwebview".

So, where is this wkwebview - I did a forum search and I found no library by that name or a view called "wkwebview" in the designer.

Any help would be appreciated.
 

JohnC

Expert
Licensed User
Longtime User
Then why am I getting that error of "unknow type"?

And if I simply change the reference of "wkwebview" to "webview" (to try to fix this unknown type error), and simply add the code from that post to the "Main" module in my project, I will get a LONG error log from the b4i cloud server starting with....

B4X:
Template version: B4i-1.0
#Region Delegates
Private Sub Application_Background
    B4XPages.Delegate.Activity_Pause
End Sub

Private Sub Application_Foreground
    B4XPages.Delegate.Activity_Resume
End Sub

Private Sub SetUIDelegate (W As WebView)
    Dim NaObj As NativeObject = W
    NaObj.SetField("UIDelegate",Me)
End Sub

#If Objc
- (void)webView:(WKWebView *)webView runJavaScriptAlertPanelWithMessage:(NSString *)message initiatedByFrame:(WKFrameInfo *)frame completionHandler:(void (^)(void))completionHandler
{
    UIAlertController *alertController = [UIAlertController alertControllerWithTitle:message
                                                                             message:nil
                                                                      preferredStyle:UIAlertControllerStyleAlert];
    [alertController addAction:[UIAlertAction actionWithTitle:@"OK"
                                                        style:UIAlertActionStyleCancel
                                                      handler:^(UIAlertAction *action) {
                                                          completionHandler();
                                                      }]];
                                                      
    [__page1.object presentViewController:alertController animated:YES completion:^{}];
}
#End If
#End Region
B4X:
Sending data to remote compiler.    Error
B4i line: 45
End Sub
use of undeclared identifier '__page1'

Out: Command line invocation:
    /Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -configuration Release PRODUCT_NAME=xxxx CONFIGURATION_BUILD_DIR=/Users/administrator/Documents/UploadedProjects/<user id>/Payload "CODE_SIGN_IDENTITY=iPhone Distribution: xxxx" "OTHER_CODE_SIGN_FLAGS=--keychain <user id>" PROVISIONING_PROFILE=xxxxx -arch arm64

User defaults from command line:
    IDEPackageSupportUseBuiltinSCM = YES

Build settings from command line:
    ARCHS = arm64
    CODE_SIGN_IDENTITY = iPhone Distribution: xxx
    CONFIGURATION_BUILD_DIR = /Users/administrator/Documents/UploadedProjects/<user id>/Payload
    OTHER_CODE_SIGN_FLAGS = --keychain <user id>
    PRODUCT_NAME = xxxx
    PROVISIONING_PROFILE = xxx

note: Using new build system
note: Using codesigning identity override: iPhone Distribution: xxx
note: Planning
Analyze workspace

Create build description
Build description signature: 3599e1f63f994bc0435df8b45e0f909f
Build description path: /Users/administrator/Documents/UploadedProjects/<user id>/build/XCBuildData/3599e1f63f994bc0435df8b45e0f909f-desc.xcbuild
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Then why am I getting that error of "unknow type"?
Because the correct name in B4i is WebView.

, I will get a LONG error log from the b4i cloud server starting with....
Something is wrong with your OBJC code. Upload the full error message as a text file (tip: search it for "error:").
 
Upvote 0

JohnC

Expert
Licensed User
Longtime User
Could the "error" you are talking about be the error of "use of undeclared identifier '__page1'" that is in the error log portion that I posted?

If so, is "_page1" something that is not available in B4xpages?

Is there a chance that the OBJC code from that other thread is meant for non-B4xpages apps and needs to be modified for B4xpages apps?
 
Last edited:
Upvote 0
Top