Skip to content

Can't open an external link when running on iOS 18 (e.g. with '_system' as target) #1080

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
3 tasks done
kenguest opened this issue Feb 18, 2025 · 5 comments
Open
3 tasks done

Comments

@kenguest
Copy link

Bug Report

Problem

External links won't open on iOS 18. They do open on iOS 17. I upgraded to iOS 18 and it does not any more. e.g.
<a target="_system" href="https://google.com">Click me</a>

iOS 18 is now on 68% of iOS devices - https://uk.pcmag.com/operating-systems/156441/ios-18-adoption-hits-68-among-iphone-users - so it's rather important this gets fixed.

This is described in apache/cordova-ios#1511 which apparently was closed with no code change made. (I looked at the repo for cordova-plugin-inappbrowser and did a "git blame" - couldn't find any relevant code changes)

What is expected to happen?

The link should open in an external browser, most likely Safari.

What does actually happen?

Nothing - no message, no log entry (apart from below in xcode) and no crash. A great absence of the link not opening :(

Information

Logs in Xcode when this happens :

BUG IN CLIENT OF UIKIT: The caller of UIApplication.openURL(_:) needs to migrate to the non-deprecated UIApplication.open(_:options:completionHandler:). Force returning false (NO).

Command or Code

Build an app with the code below on iOS 18 and click the link :

<a target="_system" href="https://google.com">Click me</a>

Or use code like:
cordova.InAppBrowser.open('https://google.com/', '_system');

Environment, Platform, Device

An iPad or iPhone running iOS 18.

Version information

iOS 18.2
cordova-ios 7.1.0
cordova-plugin-inappbrowser 6.0.0
cordova 12.0.0

Checklist

  • I searched for existing GitHub issues
  • I updated all Cordova tooling to most recent version
  • I included all the necessary information above
@guilhermoMetaway
Copy link

I'm also having this problem with IOS 18.0.3.

However, I'm using it with Ionic:
`
import {InAppBrowser} from '@awesome-cordova-plugins/in-app-browser/ngx'

const ref = this.iab.create(_url, '_system', options);
ref.show();
`
No page opens and no errors or exceptions are thrown.

@AlexDonn19
Copy link

See this link:
https://discussions.unity.com/t/application-openurl-doesnt-work-on-ios-18/1553960/12
You can change CDVWKInAppBrowser.m , string 364 to something like this:
// [[UIApplication sharedApplication] openURL:url];
if (@available(iOS 10.0, *)) {
[[UIApplication sharedApplication] openURL:url options:@{} completionHandler:^(BOOL success) {
if (!success) {
NSLog(@"Failed to open URL: %@", url);
}
}];
} else {
BOOL success = [[UIApplication sharedApplication] openURL:url];
if (!success) {
NSLog(@"Failed to open URL: %@", url);
}
}

@FabioFerrua
Copy link

@kenguest
I was in the exact same situation as you, encountering the same errors. Upon examining the CDVWKInAppBrowser.m file, I noticed that Xcode was displaying a warning:

Image

I realized that the code in this file differed from the version 6.0 of the plugin.
To resolve the issue, I simply uninstalled and reinstalled the plugin using the following commands:

cordova plugin remove cordova-plugin-inappbrowser
cordova plugin add cordova-plugin-inappbrowser

After performing these steps, the method's code changed, and Xcode no longer displayed any warnings:

Image

Now, the system browser (Safari) opens and loads the website correctly.

@guilhermoMetaway
Copy link

@kenguest I was in the exact same situation as you, encountering the same errors. Upon examining the CDVWKInAppBrowser.m file, I noticed that Xcode was displaying a warning:

Image

I realized that the code in this file differed from the version 6.0 of the plugin. To resolve the issue, I simply uninstalled and reinstalled the plugin using the following commands:

cordova plugin remove cordova-plugin-inappbrowser cordova plugin add cordova-plugin-inappbrowser

After performing these steps, the method's code changed, and Xcode no longer displayed any warnings:

Image

Now, the system browser (Safari) opens and loads the website correctly.

I'll try that

@blancaster94
Copy link

Hi, I fixed this on our enterprise app. Obj-c openUrl function syntax was changed. Just fork the repo, and update the Obj-c code that's showing the warning. If you're not familiar with forking plugins, you'll need to look into that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants