--- /dev/null
+using Xamarin.Forms.CustomAttributes;
+using Xamarin.Forms.Internals;
+using System;
+using System.Threading.Tasks;
+
+#if UITEST
+using Xamarin.Forms.Core.UITests;
+using Xamarin.UITest;
+using NUnit.Framework;
+#endif
+
+namespace Xamarin.Forms.Controls.Issues
+{
+#if UITEST
+ [Category(UITestCategories.AppLinks)]
+#endif
+ [Preserve(AllMembers = true)]
+ [Issue(IssueTracker.Github, 5470, "ApplinkEntry Thumbnail required after upgrading to 3.5/3.6", PlatformAffected.iOS)]
+ public class Issue5470 : TestContentPage
+ {
+ protected override void Init()
+ {
+ // android needs firebase for this to work, so skip it unless iOS
+ if (Device.RuntimePlatform == Device.iOS)
+ Application.Current.AppLinks.RegisterLink(GetEntry());
+
+ // Initialize ui here instead of ctor
+ Content = new Label
+ {
+ AutomationId = "IssuePageLabel",
+ Text = "If this is iOS, I just tried to register an applink without a Thumbnail. If this did not crash, this test has succeeded."
+ };
+ }
+
+ AppLinkEntry GetEntry()
+ {
+ if (string.IsNullOrEmpty(Title))
+ Title = "ApplinkEntry Thumbnail required after upgrading to 3.5/3.6";
+
+ var type = GetType().ToString();
+ var entry = new AppLinkEntry
+ {
+ Title = Title,
+ Description = $"ApplinkEntry Thumbnail required after upgrading to 3.5/3.6",
+ AppLinkUri = new Uri($"http://blah/gallery/{type}", UriKind.RelativeOrAbsolute),
+ IsLinkActive = true,
+ Thumbnail = null
+ };
+
+ entry.KeyValues.Add("contentType", "GalleryPage");
+ entry.KeyValues.Add("appName", "blah");
+ entry.KeyValues.Add("companyName", "Xamarin");
+
+ return entry;
+ }
+
+#if UITEST && __IOS__
+ [Test]
+ public async void Issue5470Test()
+ {
+ await Task.Delay(500); // give it time to crash
+ RunningApp.WaitForElement (q => q.Marked ("IssuePageLabel"));
+ }
+#endif
+ }
+}
\ No newline at end of file
<SubType>Code</SubType>
<DependentUpon>%(Filename)</DependentUpon>
</Compile>
+ <Compile Include="$(MSBuildThisFileDirectory)Issue5470.cs" />
<Compile Include="$(MSBuildThisFileDirectory)_Template.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Bugzilla56298.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Bugzilla42620.cs" />
</EmbeddedResource>
<EmbeddedResource Include="$(MSBuildThisFileDirectory)VisualControlsPage.xaml">
<SubType>Designer</SubType>
- <Generator>MSBuild:UpdateDesignTimeXaml</Generator>
+ <Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource>
<EmbeddedResource Include="$(MSBuildThisFileDirectory)Issue4356.xaml">
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
Url = new NSUrl(deepLinkUri.AppLinkUri.ToString())
};
- using (var uiimage = await deepLinkUri.Thumbnail.GetNativeImageAsync())
+ if (deepLinkUri.Thumbnail != null)
{
- if (uiimage == null)
- throw new InvalidOperationException("AppLinkEntry Thumbnail must be set to a valid source");
+ using (var uiimage = await deepLinkUri.Thumbnail.GetNativeImageAsync())
+ {
+ if (uiimage == null)
+ throw new InvalidOperationException("AppLinkEntry Thumbnail must be set to a valid source");
- searchableAttributeSet.ThumbnailData = uiimage.AsPNG();
+ searchableAttributeSet.ThumbnailData = uiimage.AsPNG();
+ }
}
return searchableAttributeSet;