Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
【iOS】Use a modal webkit view so that the app is not paused when the w…
Browse files Browse the repository at this point in the history
…eb browser opens.
skylersaleh committed Dec 17, 2023
1 parent 2da6992 commit 187242d
Showing 1 changed file with 25 additions and 4 deletions.
29 changes: 25 additions & 4 deletions src/ios_support.m
Original file line number Diff line number Diff line change
@@ -117,11 +117,32 @@ void se_ios_get_safe_ui_padding(float *top, float* bottom,float* left, float *ri
}
}
void se_ios_open_url(const char * url){
NSString* urlString = [NSString stringWithUTF8String:url];
NSURL* nsurl = [NSURL URLWithString:urlString];
[[UIApplication sharedApplication] openURL:nsurl options:@{} completionHandler:nil];
NSDictionary *dictionary = @{@"UserAgent": @"SkyEmu Browser"};
[[NSUserDefaults standardUserDefaults] registerDefaults:dictionary];
[[NSUserDefaults standardUserDefaults] synchronize];

[[NSOperationQueue mainQueue] addOperationWithBlock:^ {
UIViewController * view = (UIViewController*)sapp_ios_get_view_ctrl();
UIWebView *webView = [[UIWebView alloc] initWithFrame:view.view.frame];

// Create a UIViewController to present modally
UIViewController *webViewController = [[UIViewController alloc] init];
[webViewController.view addSubview:webView];

// Load a URL
NSURL *nsurl = [NSURL URLWithString:[NSString stringWithUTF8String:url]];
NSURLRequest *request = [NSURLRequest requestWithURL:nsurl];
[webView loadRequest:request];

// Present the UIViewController modally
[view presentViewController:webViewController animated:YES completion:nil];
//Your code goes in here
NSLog(@"Main Thread Code");

}];
}
const char* se_ios_get_certificate_path(){
NSString* path = [[NSBundle mainBundle] pathForResource:@"cacert" ofType:@"pem"];
if(path==Nil)return "";
return [path cStringUsingEncoding:NSUTF8StringEncoding];
}
}

0 comments on commit 187242d

Please sign in to comment.