From 537ccb4371fe919ed4135160a3de01bffd6c1ac5 Mon Sep 17 00:00:00 2001 From: Norman Breau Date: Wed, 15 May 2024 22:19:50 -0300 Subject: [PATCH] feat: Support for sub webviews --- BTFuse/BTFuse/BTFuseContext.h | 1 + BTFuse/src/BTFuseContext.m | 4 ++++ BTFuse/src/BTFuseViewController.m | 2 +- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/BTFuse/BTFuse/BTFuseContext.h b/BTFuse/BTFuse/BTFuseContext.h index 042bcc2..4e489b7 100644 --- a/BTFuse/BTFuse/BTFuseContext.h +++ b/BTFuse/BTFuse/BTFuseContext.h @@ -50,6 +50,7 @@ limitations under the License. - (nonnull NSString*) getAPISecret; - (nonnull BTFuseLogger*) getLogger; - (nonnull id) createWebviewNavigationDelegate; +- (nonnull NSString*) getHost; @end diff --git a/BTFuse/src/BTFuseContext.m b/BTFuse/src/BTFuseContext.m index d66cac6..89f04e6 100644 --- a/BTFuse/src/BTFuseContext.m +++ b/BTFuse/src/BTFuseContext.m @@ -121,4 +121,8 @@ - (BTFuseLogger*) getLogger { return [[BTFuseWebviewNavigationDelegate alloc] init: self keypair: [$apiServer getKeypair]]; } +- (nonnull NSString*) getHost { + return @"localhost"; +} + @end diff --git a/BTFuse/src/BTFuseViewController.m b/BTFuse/src/BTFuseViewController.m index 8fc297d..f999cf3 100644 --- a/BTFuse/src/BTFuseViewController.m +++ b/BTFuse/src/BTFuseViewController.m @@ -111,7 +111,7 @@ - (void) viewDidLoad { [self.view addSubview: self->$webview]; [self->$delegate onBeforeWebviewLoad]; - NSURL* url = [NSURL URLWithString:@"btfuse://localhost/assets/index.html"]; + NSURL* url = [NSURL URLWithString: [NSString stringWithFormat: @"btfuse://%@/assets/index.html", [self->$context getHost]]]; NSURLRequest* request = [NSURLRequest requestWithURL:url]; [self->$webview loadRequest:request]; });