skip to Main Content

I am developing a Flutter app and using the url_launcher package to open URLs. The app works fine on Android and older versions of iOS, but when I test it on iOS 18 using the simulator, the app hangs after launching the URL.

Here’s the code I’m using to launch the URL:

Future<void> _launchURL(Uri url) async {
  if (await canLaunchUrl(url)) {
    await launchUrl(url);
  } else {
    throw 'Could not launch $url';
  }
}

The URL launches correctly, but immediately afterward, the app becomes unresponsive, and I have to stop the simulator to continue. This issue only occurs on iOS 18; it works fine on older versions.

Steps to Reproduce:

1.  Install the url_launcher package in the Flutter app.
2.  Use the code above to launch a URL.
3.  Run the app on an iOS 18 simulator.
4.  Attempt to launch a URL.

Expected Behavior:
The URL should open, and the app should remain responsive.

Actual Behavior:
The URL launches, but the app hangs afterward and becomes unresponsive.

Environment:

•   Flutter: 3.24.3 (Stable branch)
•   iOS Simulator: iOS 18
•   url_launcher: ^6.3.0

Has anyone else encountered this issue? Any suggestions for resolving it would be greatly appreciated!

PS: The app also hangs when I use the sign with Google functionality (also launching an in App browser) and Stripe checkout with PayPal functionality.

2

Answers


  1. Update the url_launcher package,

    Future<void> _launchURL(Uri url) async {
      if (await canLaunchUrl(url)) {
        await launchUrl(
          url,
          mode: LaunchMode.externalApplication,
        );
      } else {
        throw 'Could not launch $url';
      }
    }
    

    Try this,

    Login or Signup to reply.
  2. import 'package:flutter_custom_tabs/flutter_custom_tabs.dart';
    
    Future<void> _launchURL(String url) async {
      try {
        await launch(
          url,
          option: CustomTabsOption(
            toolbarColor: Theme.of(context).primaryColor,
            enableDefaultShare: true,
            enableUrlBarHiding: true,
            showPageTitle: true,
            animation: CustomTabsAnimation.slideIn(),
          ),
        );
      } catch (e) {
        // Handle error
      }
    }
    

    Try this for google and paypal checkout

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search