{"record":{"id":"4813be8762b0d50f","repo":"dotnet/maui","slug":"poptorootasync-is-not-supported-globally-on-ios-p","errorCode":null,"errorMessage":"PopToRootAsync is not supported globally on iOS, please use a NavigationPage.","messagePattern":"PopToRootAsync is not supported globally on iOS, please use a NavigationPage\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Compatibility/Core/src/iOS/Platform.cs","lineNumber":152,"sourceCode":"\t\t\telse\n\t\t\t\tawait _renderer.DismissViewControllerAsync(animated);\n\n\t\t\tmodal.DisposeModalAndChildRenderers();\n\n\t\t\tif (!IsModalPresentedFullScreen(modal))\n\t\t\t\tPage.GetCurrentPage()?.SendAppearing();\n\n\t\t\treturn modal;\n\t\t}\n\n\t\tTask INavigation.PopToRootAsync()\n\t\t{\n\t\t\treturn ((INavigation)this).PopToRootAsync(true);\n\t\t}\n\n\t\tTask INavigation.PopToRootAsync(bool animated)\n\t\t{\n\t\t\tthrow new InvalidOperationException(\"PopToRootAsync is not supported globally on iOS, please use a NavigationPage.\");\n\t\t}\n\n\t\tTask INavigation.PushAsync(Page root)\n\t\t{\n\t\t\treturn ((INavigation)this).PushAsync(root, true);\n\t\t}\n\n\t\tTask INavigation.PushAsync(Page root, bool animated)\n\t\t{\n\t\t\tthrow new InvalidOperationException(\"PushAsync is not supported globally on iOS, please use a NavigationPage.\");\n\t\t}\n\n\t\tTask INavigation.PushModalAsync(Page modal)\n\t\t{\n\t\t\treturn ((INavigation)this).PushModalAsync(modal, true);\n\t\t}\n\n\t\tTask INavigation.PushModalAsync(Page modal, bool animated)","sourceCodeStart":134,"sourceCodeEnd":170,"githubUrl":"https://github.com/dotnet/maui/blob/f377ff1c5ee04d334d8a925f50c83a6b7afddf03/src/Compatibility/Core/src/iOS/Platform.cs#L134-L170","documentation":"Platform.cs throws InvalidOperationException for INavigation.PopToRootAsync. Same iOS restriction: global PopToRoot requires a NavigationPage-managed stack, since the global Platform only tracks modals.","triggerScenarios":"Calling MainPage.Navigation.PopToRootAsync() when MainPage is not a NavigationPage.","commonSituations":"Shared navigation code targeting the global Navigation interface on iOS; replacing NavigationPage with a TabbedPage or Shell and still calling PopToRootAsync.","solutions":["Ensure the root is a NavigationPage and call PopToRootAsync on its Navigation property.","If using Shell, use Shell navigation APIs instead.","If using modals only, dismiss modals manually with PopModalAsync."],"exampleFix":"// before\nawait Application.Current.MainPage.Navigation.PopToRootAsync();\n// after\n// wrap root: new NavigationPage(root)\nawait Application.Current.MainPage.Navigation.PopToRootAsync();","handlingStrategy":"validation","validationCode":"if (!(Application.Current.MainPage is NavigationPage))\n    Application.Current.MainPage = new NavigationPage(Application.Current.MainPage);\nawait Application.Current.MainPage.Navigation.PopToRootAsync();","typeGuard":"static bool SupportsStackNavigation(Page p) => p is NavigationPage;","tryCatchPattern":null,"preventionTips":["Use NavigationPage for PopToRootAsync on iOS.","Switch to Shell navigation if using Shell.","Dismiss modals with PopModalAsync when not using a navigation stack."],"tags":["maui","xamarin-forms","ios","navigation","navigationpage","invalidoperation"],"backgroundTag":null,"analyzedSha":"f377ff1c5ee04d334d8a925f50c83a6b7afddf03","analyzedAt":"2026-08-13T14:26:18.069Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}