Skip to content

Commit

Permalink
Update CDVWKInAppBrowser.m
Browse files Browse the repository at this point in the history
  • Loading branch information
jainsuneet committed Sep 2, 2024
1 parent e2d8429 commit ef0ae64
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions src/ios/CDVWKInAppBrowser.m
Original file line number Diff line number Diff line change
Expand Up @@ -303,13 +303,22 @@ - (void)openInCordovaWebView:(NSURL*)url withOptions:(NSString*)options
[self.webViewEngine loadRequest:request];
}

- (void)openInSystem:(NSURL*)url
- (void)openInSystem:(NSURL *)url
{
[[UIApplication sharedApplication] openURL:url options:@{} completionHandler:^(BOOL success) {
if (!success) {
[[NSNotificationCenter defaultCenter] postNotification:[NSNotification notificationWithName:CDVPluginHandleOpenURLNotification object:url]];
}
}];
// Check if the URL can be opened
if ([[UIApplication sharedApplication] canOpenURL:url]) {

// Use the new method to open the URL with completion handler
[[UIApplication sharedApplication] openURL:url options:@{} completionHandler:^(BOOL success) {
if (!success) {
// Post a notification if the URL could not be opened
[[NSNotificationCenter defaultCenter] postNotification:[NSNotification notificationWithName:CDVPluginHandleOpenURLNotification object:url]];
}
}];
} else {
// Post a notification if the URL can't be opened
[[NSNotificationCenter defaultCenter] postNotification:[NSNotification notificationWithName:CDVPluginHandleOpenURLNotification object:url]];
}
}

- (void)loadAfterBeforeload:(CDVInvokedUrlCommand*)command
Expand Down

0 comments on commit ef0ae64

Please sign in to comment.