Skip to content

Commit

Permalink
CB-14234: Don't call handleOpenURL for system URLs (#278)
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 authored and jcesarmobile committed Aug 22, 2018
1 parent dc5329d commit cf58b04
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/ios/CDVInAppBrowser.m
Original file line number Diff line number Diff line change
Expand Up @@ -299,8 +299,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 cf58b04

Please sign in to comment.