react-native-share-menu icon indicating copy to clipboard operation
react-native-share-menu copied to clipboard

ios shareData.data is an array rather than object

Open xavax31 opened this issue 3 years ago • 2 comments
trafficstars

Hi, on ios I get {data:[{data:..., mimeType:...}]} rather than {data:..., mimeType:...} like on android.

my extension info.plist contains: NSExtensionActivationRule SUBQUERY ( extensionItems, $extensionItem, SUBQUERY ( $extensionItem.attachments, $attachment, ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "com.adobe.pdf" || ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.jpeg" || ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.png" ).@count == $extensionItem.attachments.@count ).@count == 1

I tried different ways to write NSExtensionActivationRule, but I always get an array. Is it normal? none doc, exemple and issues here don't seem talk about that.

xavax31 avatar Aug 18 '22 15:08 xavax31

nobody has this problem? I'm surprised to be the only one. Same problem on example provided in this repository

xavax31 avatar Sep 07 '22 09:09 xavax31

I'm also seeing this issue. The typing is incorrect for ShareMenuReactView. It's currently typed as follows:

interface ShareMenuReactView {
    dismissExtension(error?: string): void;
    openApp(): void;
    continueInApp(extraData?: object): void;
    data(): Promise<{mimeType: string, data: string}>;
}

But what the data call returns corresponds to this:

data(): Promise<{ data: [{ data: string; mimeType: string }] }>;

A simple (though not pretty) workaround is to just cast to the right type:

ShareMenuReactView.data()
  .then(({ data: shareData }) => {
    // Typing is wrong on data argument - cast to workaround
    const [{ data, mimeType }] = shareData as unknown as ShareData;
   });

type ShareData = [{ data: string; mimeType: string }];

azcarraga avatar Sep 19 '22 14:09 azcarraga

Facing the same issue

harshtomar6 avatar Oct 23 '22 16:10 harshtomar6

nobody has this problem? I'm surprised to be the only one. Same problem on example provided in this repository

I have the same problem. Just code a workaround: check and to convert array to object. Will wait till proper solution.

brusenskiy avatar Nov 11 '22 13:11 brusenskiy