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
- Use Flutter 3.38+ (which migrates to
FlutterSceneDelegate / UIScene lifecycle)
- Run the app on a device with iOS 26
- Disable Location Services system-wide (Settings > Privacy & Security > Location Services > OFF)
- 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.
UIAlertView crash on UIScene-based apps (iOS 26+)
Description
The
locationplugin crashes with a fatalNSObjectNotAvailableExceptionon iOS 26 when used in a UIScene-based Flutter app (Flutter 3.38+). The crash occurs becauseLocationPlugin.m:198uses the deprecatedUIAlertView, which is now completely unavailable for UIScene-based applications.Steps to Reproduce
FlutterSceneDelegate/ UIScene lifecycle)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:
Stacktrace
Environment
Root Cause
LocationPlugin.mat line 198 creates aUIAlertViewto prompt the user to enable location services.UIAlertViewhas been deprecated since iOS 9 and is now fully unavailable in UIScene-based apps on iOS 26. The fix is to replaceUIAlertViewwithUIAlertController.