0

I am using Xamarin Essentials share service to show the share UI view in iOS in Xamarin forms app. However in iOS, the same app from which I am calling the share is also getting displayed as the suggested app. Is there any way to remove it? Below is part of the code which calls the essentials API for showing the share sheet view.

Xamarin.Essentials.Interfaces.IShare _shareService;

await _shareService.RequestAsync(new ShareTextRequest
                {
                    Uri = invitationUrl,
                });

Both will display the sheet,, but only iOS having issue with showing my main app also as suggested app

hashimks
  • 1,205
  • 2
  • 11
  • 29

2 Answers2

0

Xamarin.Essential Share can't set the suggest app so far, they can be set on ios by users though.

Also, You can post a feature request on github https://github.com/xamarin/Essentials

Adrain
  • 1,946
  • 1
  • 3
  • 7
0

Forked the essentials repo and did changes for excluding some of the apps to not to show in the share view. Exclude types included only some of the iOS SDK supported types (like messages, facebook, twitter etc) and not any third party services.

var src = new TaskCompletionSource<bool>();
var items = new List<NSObject>();
if (!string.IsNullOrWhiteSpace(request.Text))
{
    items.Add(new ShareActivityItemSource(new NSString(request.Text), request.Title));
}

if (!string.IsNullOrWhiteSpace(request.Uri))
{
    items.Add(new ShareActivityItemSource(NSUrl.FromString(request.Uri), request.Title));
}

var activityController = new UIActivityViewController(items.ToArray(), null)
{
    ExcludedActivityTypes = new NSString []
    {
        UIActivityType.Message,
        UIActivityType.PostToTwitter,
        UIActivityType.PostToFacebook
    },
    CompletionWithItemsHandler = (a, b, c, d) =>
    {
        src.TrySetResult(true);
    }
 };

 var vc = Platform.GetCurrentUIViewController();

 await vc.PresentViewControllerAsync(activityController, true);
            await src.Task;
hashimks
  • 1,205
  • 2
  • 11
  • 29