Skip to content

Commit cf58b04

Browse files
dpolivyjcesarmobile
authored andcommitted
CB-14234: Don't call handleOpenURL for system URLs (#278)
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.
1 parent dc5329d commit cf58b04

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/ios/CDVInAppBrowser.m

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -299,8 +299,9 @@ - (void)openInCordovaWebView:(NSURL*)url withOptions:(NSString*)options
299299

300300
- (void)openInSystem:(NSURL*)url
301301
{
302-
[[NSNotificationCenter defaultCenter] postNotification:[NSNotification notificationWithName:CDVPluginHandleOpenURLNotification object:url]];
303-
[[UIApplication sharedApplication] openURL:url];
302+
if ([[UIApplication sharedApplication] openURL:url] == NO) {
303+
[[NSNotificationCenter defaultCenter] postNotification:[NSNotification notificationWithName:CDVPluginHandleOpenURLNotification object:url]];
304+
}
304305
}
305306

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

0 commit comments

Comments
 (0)