adospace / reactorui-maui

MauiReactor is a MVU UI framework built on top of .NET MAUI
MIT License
555 stars 46 forks source link

How to override Application.OnAppLinkRequestReceived? #173

Closed Mithgroth closed 8 months ago

Mithgroth commented 8 months ago

Greetings @adospace mate, Came a long way since my previous ticket (#167) with my MVP, we are hopefully sailing for a RC.

I implemented a FIDO2 authentication with in-app tabs, app starts the process with a button, in-app tab opens and FIDO2 operations are carried out, then on successful login, I need to deep-link back to my application. (per w3 spec)

Normally you could override OnAppLinkRequestReceived in a typical MAUI Application, similarly to overriding OnStart() or OnResume():

protected override async void OnAppLinkRequestReceived(Uri uri)
{
    if (uri.Host == "somepage")
    {
        // Logic to navigate to the specific page or handle the link
    }
    base.OnAppLinkRequestReceived(uri);
}

In Reactor, our entry point is not UseMauiApp<App>() but UseMauiReactorApp<T>(), where T is a Component. While this is somewhat cool, Application is not exposed, so I'm not sure how I can override its OnAppLinkRequestReceived to handle deep-links. I can access the underlying Application by UseMauiReactorApp's action parameter, but I don't think I can override the method that way.

Any suggestions?

adospace commented 8 months ago

Yes, it's not possible, or at least not easy. Please download the new version 1.0.149 where I've added a new way to subscribe to the AppLinkRequestReceived callback as shown below:

var builder = MauiApp.CreateBuilder();
builder
    .UseMauiReactorApp<HomePage>(app =>
    {
        app.AppLinkRequestReceived = uri =>
        {
            //handle AppLinkRequest ...
        };
    })

Out of curiosity, are you planning to move to .net 8?

Mithgroth commented 8 months ago

Yes, it's not possible, or at least not easy. Please download the new version 1.0.149 where I've added a new way to subscribe to the AppLinkRequestReceived callback as shown below:

var builder = MauiApp.CreateBuilder();
builder
    .UseMauiReactorApp<HomePage>(app =>
    {
        app.AppLinkRequestReceived = uri =>
        {
            //handle AppLinkRequest ...
        };
    })

Super, I'll check it out, thanks!

Out of curiosity, are you planning to move to .net 8?

Yep, on a countdown now. Currently I'm working on a MVP on career-break, a start-up founded by an ex-colleague. So, it's easy to bump the version and check the goodies. It's also exciting for a backend developer.

Came a long way in weeks, but it wouldn't be the same if it wasn't for your library. Maybe I'll start contributing in some near future if contributors are welcome - right now I'm only just advocating for it :)