dotnet / maui

.NET MAUI is the .NET Multi-platform App UI, a framework for building native device applications spanning mobile, tablet, and desktop.
https://dot.net/maui
MIT License
22.21k stars 1.75k forks source link

AppLinks in iOS return "No IAppIndexingProvider" #12295

Open edgiardina opened 1 year ago

edgiardina commented 1 year ago

Description

In Xamarin Forms, Using the AppLinks nuget package was straightforward in iOS and required no initialization.

In .NET MAUI, on iOS, AppLinks is built in, but throws an initialization error. It isn't clear from the documentation how to resolve this. This is the case whether an Entitlements.plist declaration is given or not.

Steps to Reproduce

  1. create file new .net maui project
  2. Add code to create applinks
  3. Witness exception on invocation
var url = $"https://en.wikipedia.org/wiki/Steve_Jobs";

        var entry = new AppLinkEntry
        {
            Title = "Steve Jobs",
            Description = "President",
            AppLinkUri = new Uri(url, UriKind.RelativeOrAbsolute),
            IsLinkActive = true,
            Thumbnail = ImageSource.FromUri(new Uri("https://cdn.dribbble.com/users/160522/screenshots/1179084/stevejobs-01.jpg", UriKind.RelativeOrAbsolute))
        };

        entry.KeyValues.Add("contentType", "Employee");
        entry.KeyValues.Add("appName", "MauiBug_AppLinks");
        try
        {
            Application.Current.AppLinks.RegisterLink(entry);
        }
        catch (ArgumentException ex)
        {
            //TODO: resolve "No IAppIndexingProvider was provided" exception
            DisplayAlert("Error", ex.Message, "Cancel");
        }

Link to public reproduction project repository

https://github.com/edgiardina/MauiBug_AppLinks_NoIAppIndexing

Version with bug

7.0 (current)

Last version that worked well

Unknown/Other

Affected platforms

iOS

Affected platform versions

iOS 16.1 (but appears to affect all iOS versions)

Did you find any workaround?

No response

Relevant log output

No response

edgiardina commented 1 year ago

Just following up, this hasn't been categorized, or reviewed, or even put on the backlog.

ghost commented 1 year ago

We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.

davidortinau commented 1 year ago

Looks like the provider isn't being set in maui. I was able to address this by adding the code originally found in the Forms.Init to my App.cs

#if IOS
(Application.Current as IApplicationController)?.SetAppIndexingProvider(new IOSAppIndexingProvider());
#endif

Similar may also need to be done for Android.

https://github.com/search?q=repo%3Adotnet%2Fmaui%20SetAppIndexingProvider&type=code

I also think it needs things from the Compat namespace, so in MauiProgram.cs:

public static MauiApp CreateMauiApp()
{
    var builder = MauiApp.CreateBuilder();
    builder
        .UseMauiCompatibility()
        .UseMauiApp<App>();

    return builder.Build();
}
davidortinau commented 1 year ago

Upgraded Xamarin.Forms sample of DeepLinking. For me right now I'm not getting the iOS links that have been registered to appear in the spotlight search.

DeepLinking.zip

Zhanglirong-Winnie commented 1 year ago

Verified this issue with Visual Studio Enterprise 17.7.0 Preview 2.0. Can repro on iOS platform with sample project. MauiBugAppLinks.zip Screenshot 2023-07-10 144314