step-up-labs / firebase-authentication-dotnet

C# library for Firebase Authentication
MIT License
376 stars 129 forks source link

Added initial code for Auth.UI.WinUI3 and WinUI3 sample #202

Closed anovik closed 1 year ago

anovik commented 1 year ago

UWP is officially still supported by Microsoft but they don't make any new changes since 2016. So it is quite outdated.

WinUI3 is a new native Windows user interface platform, that goes with Windows App SDK. So it is a new alternative to WPF, I would say.

bezysoftware commented 1 year ago

I am not able to run the sample on VS 2022. There are several issues:

bezysoftware commented 1 year ago

Also we should probably note somewhere that 'Single-project MSIX Packaging Tools for VS 2022' needs to be installed to run the sample, I'll add it to readme once this is merged

anovik commented 1 year ago

@bezysoftware I fixed the issues with resources and the dispatcher queue. Also updated message boxes.

Also we should probably note somewhere that 'Single-project MSIX Packaging Tools for VS 2022' needs to be installed to run the sample, I'll add it to readme once this is merged

That's correct.

anovik commented 1 year ago

The two issues which are still here for WinUI3:

  1. I had to comment ProgressBar, there is some problem with it not in the code but in WinUI3. Adding it to XAML leads to an exception.
  2. For Google WebAuthenticationBroker.AuthenticateAsync doesn't display any window as it should.
bezysoftware commented 1 year ago

It seem neither of the auth providers which use WebAuthenticationBroker work - no window is displayed. Seems WAB is only supported on UWP, nowhere else: https://github.com/microsoft/WindowsAppSDK/issues/441 so a different solution needs to be used - see a "fake" WAB in the WPF implementation - it uses a custom Window with WebView2

anovik commented 1 year ago

@bezysoftware I've added the initial implementation of custom WebAuthenticationBroker for WinUI3. For now, I have some initialization problems with WebView.EnsureCoreWebView2Async() on my machine, it throws a catastrophic failure COM exception. If you have time, could you please check it also? Will continue investigating this also.

bezysoftware commented 1 year ago

It doesn't crash on my machine, but the WebView control doesn't navigate anywhere - the window remains blank. Even if I set the source property directly in xaml

bezysoftware commented 1 year ago

Can you try running this gallery sample? https://github.com/microsoft/WinUI-Gallery It's also published in Microsoft Store to simply install. It contains WebView2 sample, for me it works (page loads), but in Firebase project it still doesn't load

anovik commented 1 year ago

@bezysoftware Finally, I solved the problem with the stupid WebView2 (I hate it!) Added full-trust permission to winui3 sample and it works. Could you please check it from your side? Everything should be now functional.

bezysoftware commented 1 year ago

@bezysoftware Finally, I solved the problem with the stupid WebView2 (I hate it!) Added full-trust permission to winui3 sample and it works. Could you please check it from your side? Everything should be now functional.

runFullTrust sounds harsh, but ok. I added a few final comments, there is also the stuff for nuget package which is missing in csproj, you can either add it yourself (see the WPF csproj for example) or I'll add it after merge.

anovik commented 1 year ago

there is also the stuff for nuget package which is missing in csproj, you can either add it yourself (see the WPF csproj for example) or I'll add it after merge.

I've added nuget information for winui3.

anovik commented 1 year ago

@bezysoftware It seems the failure doesn't refer to the WinUI3 part, just tests require NET Core 3.1 and it is absent in the environment build. It is probably worth upgrading tests to NET 6.

bezysoftware commented 1 year ago

@bezysoftware It seems the failure doesn't refer to the WinUI3 part, just tests require NET Core 3.1 and it is absent in the environment build. It is probably worth upgrading tests to NET 6.

Thx I'll have a look next week when I'm back from vacation

anovik commented 1 year ago

@bezysoftware Any update regarding this PR?

bezysoftware commented 1 year ago

I've been busy with other stuff, I should hopefully have some time next week

bezysoftware commented 1 year ago

I upgraded the tests, merged your PR and made a few finishing touches, looks like the solution is building now. I'll test a bit tomorrow and deploy to nuget after that, will let you know here. Thanks for the PR!

bezysoftware commented 1 year ago

Nuget is published: https://www.nuget.org/packages/FirebaseAuthentication.WinUI3 🎉 Thanks again! @anovik