Skip to content

Crash on iOS when location permissions are system-wide disabled #1043

@aggeloskoutanis

Description

@aggeloskoutanis

UIAlertView crash on UIScene-based apps (iOS 26+)

Description

The location plugin crashes with a fatal NSObjectNotAvailableException on iOS 26 when used in a UIScene-based Flutter app (Flutter 3.38+). The crash occurs because LocationPlugin.m:198 uses the deprecated UIAlertView, which is now completely unavailable for UIScene-based applications.

Steps to Reproduce

  1. Use Flutter 3.38+ (which migrates to FlutterSceneDelegate / UIScene lifecycle)
  2. Run the app on a device with iOS 26
  3. Disable Location Services system-wide (Settings > Privacy & Security > Location Services > OFF)
  4. Trigger a location request that calls Location().requestService()

Expected Behavior

The plugin should display a prompt (using UIAlertController) asking the user to enable location services.

Actual Behavior

The app crashes with a fatal exception:

NSObjectNotAvailableException: UIAlertView is deprecated and unavailable for UIScene based applications, please use UIAlertController!

Stacktrace

__exceptionPreprocess
objc_exception_throw
+[NSException raise:format:]
-[UIAlertView initWithFrame:]
-[UIAlertView initWithTitle:message:delegate:cancelButtonTitle:otherButtonTitles:]
-[LocationPlugin handleMethodCall:result:] (LocationPlugin.m:198)
__45-[FlutterMethodChannel setMethodCallHandler:]_block_invoke (FlutterChannels.mm:313)
flutter::PlatformMessageHandlerIos::HandlePlatformMessage (platform_message_handler_ios.mm:70)

Environment

  • Flutter: 3.38
  • location package: 8.0.1
  • iOS: 26.3.1
  • Device: iPhone 14 Pro (iPhone14,5)

Root Cause

LocationPlugin.m at line 198 creates a UIAlertView to prompt the user to enable location services. UIAlertView has been deprecated since iOS 9 and is now fully unavailable in UIScene-based apps on iOS 26. The fix is to replace UIAlertView with UIAlertController.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions