Skip to content

Commit

Permalink
CB-14234: Don't call handleOpenURL for system URLs
Browse files Browse the repository at this point in the history
When calling `.open()` with a target of `_system`, the InAppBrowser on iOS is both launching the URL in the system browser AND also broadcasting to open the URL within the app (calling handleOpenURL). The latter behavior is problematic in many circumstances (e.g. when you want to explicitly open a link in a browser which is a universal link handled by the app).

This commit attempts to address this by checking the return value from openURL -- if it does not open the URL successfully, then (and only then) the code falls back to broadcasting the event within the app to handleOpenURL.
  • Loading branch information
dpolivy committed Aug 22, 2018
1 parent de86501 commit 4215b9d
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/ios/CDVInAppBrowser.m
Expand Up @@ -298,8 +298,9 @@ - (void)openInCordovaWebView:(NSURL*)url withOptions:(NSString*)options

- (void)openInSystem:(NSURL*)url
{
[[NSNotificationCenter defaultCenter] postNotification:[NSNotification notificationWithName:CDVPluginHandleOpenURLNotification object:url]];
[[UIApplication sharedApplication] openURL:url];
if ([[UIApplication sharedApplication] openURL:url] == NO) {
[[NSNotificationCenter defaultCenter] postNotification:[NSNotification notificationWithName:CDVPluginHandleOpenURLNotification object:url]];
}
}

// This is a helper method for the inject{Script|Style}{Code|File} API calls, which
Expand Down

0 comments on commit 4215b9d

Please sign in to comment.