Skip to content

Commit

Permalink
fix(ios): fix broken logic preventing webview to load URL
Browse files Browse the repository at this point in the history
  • Loading branch information
jwerle committed Dec 13, 2022
1 parent 8e5f13c commit 91912c6
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions src/mobile/ios.mm
Expand Up @@ -247,18 +247,25 @@ - (BOOL) application: (UIApplication*) application
[viewController.view addSubview: self.webview];

NSString* allowed = [[NSBundle mainBundle] resourcePath];

NSURL* url;
if (isDebugEnabled()) {
int port = getDevPort();

if (isDebugEnabled() && port > 0 && getDevHost() != nullptr) {
NSString* host = [NSString stringWithUTF8String:getDevHost()];
int port = getDevPort();
url = [NSURL
URLWithString:[NSString stringWithFormat:@"http://%@:%d/", host, port]];
[self.webview loadRequest:[NSURLRequest requestWithURL:url]];
URLWithString: [NSString stringWithFormat: @"http://%@:%d/", host, port]
];

[self.webview loadFileRequest: [NSURLRequest requestWithURL: url]
allowingReadAccessToURL: [NSURL fileURLWithPath: allowed]
];
} else {
url = [NSURL fileURLWithPath:[allowed stringByAppendingPathComponent:@"ui/index.html"]];
[self.webview loadFileURL:url
allowingReadAccessToURL:[NSURL fileURLWithPath:allowed]];
url = [NSURL
fileURLWithPath: [allowed stringByAppendingPathComponent:@"ui/index.html"]
];

[self.webview loadFileURL: url
allowingReadAccessToURL: [NSURL fileURLWithPath:allowed]];
}

self.webview.scrollView.delegate = self;
Expand Down

0 comments on commit 91912c6

Please sign in to comment.