xamarin / Essentials

Xamarin.Essentials is no longer supported. Migrate your apps to .NET MAUI, which includes Maui.Essentials.
https://aka.ms/xamarin-upgrade
Other
1.53k stars 505 forks source link

[Bug] Share plugin shows warning of future failure when used in IOS #1924

Open danlfarnell opened 3 years ago

danlfarnell commented 3 years ago

Description

When using the share plugin to share a file the following warning is logged to the debug console which warns that the request will fail in the future.

2021-11-15 16:14:54.142159-0500 testing123.iOS[5427:673207] [NSExtension] Extension request contains input items but the extension point does not specify a set of allowed payload classes. The extension point's NSExtensionContext subclass must implement +_allowedItemPayloadClasses. This must return the set of allowed NSExtensionItem payload classes. In future, this request will fail with an error. Extension: <EXConcreteExtension: 0x600000e7f3c0> {id = com.apple.reminders.sharingextension} Items: ( "<NSExtensionItem: 0x60000394f6b0> - userInfo: {\n NSExtensionItemAttachmentsKey = (\n \"<NSItemProvider: 0x60000103d810> {types = (\n \\"public.plain-text\\",\n \\"public.file-url\\"\n)}\"\n );\n \"com.apple.UIKit.NSExtensionItemUserInfoIsContentManagedKey\" = 0;\n}" )

Steps to Reproduce

  1. Create a new app with one button that launches the Share window using the following code.

  2. var fileName = "testFile.txt"; File.WriteAllText("Testing", fileName);

        await Share.RequestAsync(new ShareFileRequest()
        {
            Title = $"Report",
            File = new ShareFile(fileName),
        });
  3. The warning will be logged to console.

Expected Behavior

It works as expected but there is concern that it will fail in the future.

Actual Behavior

It works as expected but there is concern that it will fail in the future.

Basic Information

Screenshots

Reproduction Link

danlfarnell commented 3 years ago

The following has also been set in info.plist as per instructions from https://docs.microsoft.com/en-us/xamarin/essentials/share?context=xamarin%2Fxamarin-forms&tabs=ios

NSPhotoLibraryAddUsageDescription This app needs access to the photo gallery for saving photos and videos. NSPhotoLibraryUsageDescription This app needs access to photos gallery for saving photos and videos.
frank-1992 commented 2 years ago

you should add an extension file and use UIActivityViewController extension ARResultController { func presentShareSheet(for url: URL) { let objectsToShare: [Any] = [url] let activityVC = UIActivityViewController(activityItems: objectsToShare, applicationActivities: nil) activityVC.popoverPresentationController?.sourceView = view present(activityVC, animated: true, completion: nil) } }