{"record":{"id":"9091d8d3c237d527","repo":"dotnet/maui","slug":"popasync-is-not-supported-globally-on-ios-please","errorCode":null,"errorMessage":"PopAsync is not supported globally on iOS, please use a NavigationPage.","messagePattern":"PopAsync 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":116,"sourceCode":"\t\t\t\t\treturn new List<Page>();\n\n\t\t\t\treturn _modals;\n\t\t\t}\n\t\t}\n\n\t\tIReadOnlyList<Page> INavigation.NavigationStack\n\t\t{\n\t\t\tget { return new List<Page>(); }\n\t\t}\n\n\t\tTask<Page> INavigation.PopAsync()\n\t\t{\n\t\t\treturn ((INavigation)this).PopAsync(true);\n\t\t}\n\n\t\tTask<Page> INavigation.PopAsync(bool animated)\n\t\t{\n\t\t\tthrow new InvalidOperationException(\"PopAsync is not supported globally on iOS, please use a NavigationPage.\");\n\t\t}\n\n\t\tTask<Page> INavigation.PopModalAsync()\n\t\t{\n\t\t\treturn ((INavigation)this).PopModalAsync(true);\n\t\t}\n\n\t\tasync Task<Page> INavigation.PopModalAsync(bool animated)\n\t\t{\n\t\t\tvar modal = _modals.Last();\n\t\t\t_modals.Remove(modal);\n\t\t\tmodal.DescendantRemoved -= HandleChildRemoved;\n\n\t\t\tvar controller = GetRenderer(modal) as UIViewController;\n\n\t\t\tif (_modals.Count >= 1 && controller != null)\n\t\t\t\tawait controller.DismissViewControllerAsync(animated);\n\t\t\telse","sourceCodeStart":98,"sourceCodeEnd":134,"githubUrl":"https://github.com/dotnet/maui/blob/f377ff1c5ee04d334d8a925f50c83a6b7afddf03/src/Compatibility/Core/src/iOS/Platform.cs#L98-L134","documentation":"Platform.cs throws InvalidOperationException for INavigation.PopAsync, mirroring iOS's restriction that global (non-NavigationPage) navigation stacks are unsupported. On iOS, the global INavigation only handles modal push/pop; PopAsync must go through a NavigationPage.","triggerScenarios":"Calling MainPage.Navigation.PopAsync() when MainPage is not a NavigationPage; shared code assuming global navigation stack semantics.","commonSituations":"Cross-platform navigation code that works on Android but is invoked on iOS without a NavigationPage root; setting MainPage to a ContentPage then calling Navigation.PopAsync.","solutions":["Use NavigationPage as the root and call PopAsync on its Navigation property.","For modal flows, use PopModalAsync instead.","Ensure the page from which PopAsync is called is hosted inside a NavigationPage."],"exampleFix":"// before\nawait Application.Current.MainPage.Navigation.PopAsync();\n// after\n// MainPage should be a NavigationPage\nawait Application.Current.MainPage.Navigation.PopAsync(); // after wrapping root in NavigationPage","handlingStrategy":"validation","validationCode":"if (!(Application.Current.MainPage is NavigationPage))\n    Application.Current.MainPage = new NavigationPage(Application.Current.MainPage);\nawait Application.Current.MainPage.Navigation.PopAsync();","typeGuard":"static bool SupportsStackNavigation(Page p) => p is NavigationPage;","tryCatchPattern":null,"preventionTips":["Host pages in NavigationPage for PushAsync/PopAsync on iOS.","Use PopModalAsync for modals.","Refactor shared navigation to be NavigationPage-rooted."],"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"}