maui icon indicating copy to clipboard operation
maui copied to clipboard

AppLinks in iOS return "No IAppIndexingProvider"

Open edgiardina opened this issue 3 years ago • 4 comments

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 avatar Dec 25 '22 17:12 edgiardina

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

edgiardina avatar Feb 09 '23 19:02 edgiardina

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.

ghost avatar Feb 14 '23 13:02 ghost

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 avatar Mar 10 '23 17:03 davidortinau

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

davidortinau avatar Mar 10 '23 18:03 davidortinau

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

Zhanglirong-Winnie avatar Jul 10 '23 06:07 Zhanglirong-Winnie