Application.OpenURL doesnt work on iOS 18+

Hi there,
we noticed that Application.OpenURL doesn’t work on iOS 18+. It seems a similar issue was already fixed in LTS 2022. Is there an ETA for when this will be fixed in 2023? We are currently using version 2023.2.20, where this issue still occurs.

Thanks a lot for your response!

Console log from xcode 16.1 (16B40), macOS 15.0.1 (24A348):
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).

Unity 2023 has become Unity 6, upgrade to that.

We cannot simply update to a completely new version of Unity (especially in this case). Our project is large, and regression tests are complex and time-consuming. Unity 6 is still in its early stages of production.

Were did you get that info?
Unity 6 is LTS version of 2023. We did a version rename.

Please help me understand the situation. Regardless of the versioning name, all the improvements and updates mentioned here (Unity 6 is here: See what's new) are specific to Unity 6, correct? So, moving from Unity 2023.2.20 to Unity 6 would likely be a significant leap, introducing a lot of new functionality that could pose potential risks. If we are currently on version 2023.2.20, is migrating to Unity 6 with all those changes the only option to get a simple fix for openURL?

What was originally supposed to be Unity 2023.3 (LTS) has been delayed and renamed to Unity 6. The differences are supposed to be minor between the two, the same as you had when 2022.2 became 2022.3 LTS.

Hmm, so it seems the only option is to try it. Honestly, though, considering the big announcements about all these “minor” differences, it’s a bit confusing. :wink:
But thanks a lot for the quick response! :man_bowing:

don’t forget to back up everything

Sure, that’s good advice in fact. Everything is in the repositories :slight_smile: However, we resolved it with a custom iOS plugin using the latest UIKit openURL for now. Unity 6 seems promising, but at the moment, it’s not the most efficient solution for us to adopt overnight just for this small fix. We were just curious if there are any plans to extend the 2023.2.x version with the appropriate fix. But anyway - Thank you guys, you’re creating an amazing product, no doubt about it!

probably impossible because the 2023 version is gone from unity hub.

Thnx a lot for all the info. At least we can better plan our next steps.

To fix this write custom open url plugin for IOS. Create OpenURLPlugin.m And put it in Assets/Plguins/iOS (should auto mark to only be usable on iOS platform but double check).
Paste this code:

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>

#ifdef __cplusplus
extern "C" {
#endif

    void _OpenURL(const char* url) {
        NSString* urlString = [NSString stringWithUTF8String:url];
        NSURL* nsUrl = [NSURL URLWithString:urlString];

        if (@available(iOS 10.0, *)) {
            [[UIApplication sharedApplication] openURL:nsUrl options:@{} completionHandler:^(BOOL success) {
                if (!success) {
                    NSLog(@"Failed to open URL: %@", urlString);
                }
            }];
        } else {
            BOOL success = [[UIApplication sharedApplication] openURL:nsUrl];
            if (!success) {
                NSLog(@"Failed to open URL: %@", urlString);
            }
        }
    }

#ifdef __cplusplus
}
#endif

In unity script paste this as a method with UNITY_IOS define

#if UNITY_IOS
        [DllImport("__Internal")]
        private static extern void _OpenURL(string url);
#endif

and call it where you need it with

#if UNITY_IOS
	_OpenURL(url);
#endif

Perfect!
It really save me!

I’m stuck on Unity 2020 and this is exactly what I needed thanks for sharing!

You are life savior! Thanks mate, everything is working as expected! :heart:

That is what I had to do, you can make it a bool returning call:

#import <UIKit/UIKit.h>

extern "C" {

bool OpenURL(const char* url) {
    NSString* nsUrl = [NSString stringWithUTF8String:url];
    NSURL* nsNSURL = [NSURL URLWithString:nsUrl];
    
    if ([[UIApplication sharedApplication] canOpenURL:nsNSURL]) {
        [[UIApplication sharedApplication] openURL:nsNSURL options:@{} completionHandler:nil];
        return true;
    }
    return false;
}

}

I had to chat gpt it so YMMV

Still happens in Unity 6000.1.11f1:

  • Built from ‘6000.1/staging’ branch, Version ‘6000.1.11f1 (9b156bbbd4df)’, Build type ‘Release’, Scripting Backend ‘il2cpp’
  • iOS version: 18.5
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).

Looking at source code we already use completionHandler. Can it be from a plugin? Could you submit a bug report?

Thanks for the reply.
I’m only using:

  • AWS SDK for .NET version 4.0.29.1
  • Google Mobile Ads Unity version 10.3.0 (iOS SDK version 12.6.0)
  • com.unity.purchasing package version 4.13.0

u save my day~
Thank you !