Skip to content
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

url in ios 18+ is not working using CN.execute(url)... #3886

Open
DurankGts opened this issue Mar 19, 2025 · 1 comment
Open

url in ios 18+ is not working using CN.execute(url)... #3886

DurankGts opened this issue Mar 19, 2025 · 1 comment

Comments

@DurankGts
Copy link
Contributor

DurankGts commented Mar 19, 2025

In iOS 18, Apple has made changes to the URL Opener API, which may require the use of UIApplication.shared in combination with openURL: inside @available(iOS 10.0, *). However, if your code uses the old [[UIApplication sharedApplication] openURL:] API, it is recommended to migrate to open(_:options:completionHandler:).

Library Change
Starting with iOS 18, the use of UIApplication.shared is still valid, but Apple recommends using open(_:options:completionHandler:) inside UIApplication. If you are having trouble, check that your code is in the correct context.

If you're using openURL: directly and without migrating to the new method, you may need to explicitly import UIKit in your file:

objective
Copy
Edit
#import <UIKit/UIKit.h>
Moving to openURL: Modern
Instead of:

objective
Copy
Edit
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:ns]];
Use:

objective
Copy
Edit
NSURL *url = [NSURL URLWithString:ns];
if (@available(iOS 10.0, *)) {
[[UIApplication sharedApplication] openURL:url options:@{} completionHandler:^(BOOL success) {
if (!success) {
NSLog(@"Failed to open URL: %@", url);
}
}];
} else {
[[UIApplication sharedApplication] openURL:url];
}
Check if You Need to Import a New Library
In most cases, UIKit is still the primary library for handling URL opening. However, if you're using SwiftUI, you may need to handle URLs differently using @Environment(.openURL).

If your app uses SceneDelegate (iOS 13+), make sure your URL opening configuration is correctly implemented:

objective
Copy
Edit

  • (void)scene:(UIScene *)scene openURLContexts:(NSSet<UIOpenURLContext *> *)URLContexts;
    If you're still having trouble, check Apple's latest documentation, as iOS 18 may have introduced additional security and privacy restrictions on opening external links.

Checking your source code I see that you are using the obsolete method
Image

@shai-almog
Copy link
Collaborator

Can you edit this issue to use English and include a screenshot that can be read.
Please include the device error log you can get from the settings app.

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

2 participants