Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Page.DisplayAlert and Page.DisplayActionSheet do not work in MAUI Embedded Use Case #19843

Open
nau-dwb opened this issue Jan 11, 2024 · 1 comment
Labels
area-controls-dialogalert DisplayAlert, dialog migration-compatibility Xamarin.Forms to .NET MAUI Migration, Upgrade Assistant, Try-Convert platform/android 🤖 platform/iOS 🍎 s/triaged Issue has been reviewed s/verified Verified / Reproducible Issue ready for Engineering Triage t/bug Something isn't working t/native-embedding
Milestone

Comments

@nau-dwb
Copy link

nau-dwb commented Jan 11, 2024

Description

When using MAUI under the embedded use case within a native .NET Android or .NET iOS application, the Page.DisplayAlert and Page.DisplayActionSheet methods do not work in either iOS or Android. I have not tried Page.DisplayPromptAsync but suspect that would not work either.

This worked fine in the Xamarin realm when using Xamarin Forms embedded in Xamarin Android or Xamarin iOS.

This also works fine if using "pure" MAUI and not the embedded use case.

Looking in the MAUI source code, it looks like the underlying implementation of these methods use the MessagingCenter to send a message. I suspect when using MAUI embedded, the applicable subscriptions to these messages are not being registered like they are in "pure" MAUI.

Steps to Reproduce

  1. Create a new .NET 7 Android or iOS project using embedded MAUI. Does not matter if it's a single project structure or separate projects for the Android\iOS and MAUI code.
  2. Create a MAUI page with a button or label with a tap gesture recognizer - anything you can tap and fire a command with.
  3. Implement the command to await DisplayAlert or DisplayActionSheet
  4. Do something with the variable holding the result from the prior call (even just a console writeline with it) and place a break point here.
  5. Run the app, tap the button\label\etc.

Note: You can run the simple-maui-embedded sample application under the provided repo to reproduce this issue.

Expected: the alert or action sheet display to the user and the user can make a selection - breakpoint dealing with the result from the dialog is hit.

Actual: No dialog or action sheet is displayed. Breakpoint after is never hit. No exception is thrown but the alert never appears.

Link to public reproduction project repository

https://github.com/nau-dwb/maui-embedded-use-issues/tree/main

Version with bug

Unknown/Other

Is this a regression from previous behavior?

Yes, this used to work in Xamarin.Forms

Last version that worked well

Unknown/Other

Affected platforms

iOS, Android, I was not able test on other platforms

Affected platform versions

Android 26+ and iOS 14.2+ with .NET 7

Did you find any workaround?

Working around this currently by using the native Android and iOS options for alert dialogs\prompts\action sheets. We have an interface defining methods to invoke a dialog\prompt\action sheet that the MAUI code interacts with and then an Android and iOS implementation using the native code that we register with the DI container on start up.

Note the provided repo is solely for simple repro purposes and does NOT contain an example of this workaround.

Relevant log output

No response

@nau-dwb nau-dwb added the t/bug Something isn't working label Jan 11, 2024
@samhouts samhouts added the migration-compatibility Xamarin.Forms to .NET MAUI Migration, Upgrade Assistant, Try-Convert label Jan 12, 2024
@ninachen03
Copy link

Verified this issue with Visual Studio 17.10.0 Preview 3 ( 8.0.20 & 8.0.0-rc.1.9171),I can repro it.

@ninachen03 ninachen03 added s/verified Verified / Reproducible Issue ready for Engineering Triage s/triaged Issue has been reviewed labels Apr 17, 2024
@Eilon Eilon added the area-controls-dialogalert DisplayAlert, dialog label May 10, 2024
@jsuarezruiz jsuarezruiz added this to the Backlog milestone Jun 5, 2024
@samhouts samhouts removed s/verified Verified / Reproducible Issue ready for Engineering Triage s/triaged Issue has been reviewed labels Jul 3, 2024
@samhouts samhouts added s/verified Verified / Reproducible Issue ready for Engineering Triage s/triaged Issue has been reviewed labels Jul 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-controls-dialogalert DisplayAlert, dialog migration-compatibility Xamarin.Forms to .NET MAUI Migration, Upgrade Assistant, Try-Convert platform/android 🤖 platform/iOS 🍎 s/triaged Issue has been reviewed s/verified Verified / Reproducible Issue ready for Engineering Triage t/bug Something isn't working t/native-embedding
Projects
None yet
Development

No branches or pull requests

5 participants