achorein / expo-share-intent

🚀 Simple share intent in an Expo Native Module
MIT License
174 stars 15 forks source link

Cannot share file from Safari #104

Open m1st1ck opened 2 weeks ago

m1st1ck commented 2 weeks ago

Describe the bug In Safari if the web page is a file and we try to share it, our app is not showing as an option. We are able to share images, videos, files, audio from Photos and Files, also regular web pages and selected text. Android works fine and so does iOS chrome.

Here is our plugin config. Maybe we are missing some activation rule, but could not find information.

 "plugins": [
      [
        "expo-share-intent",
        {
          "iosActivationRules": {
            "NSExtensionActivationSupportsText": true,
            "NSExtensionActivationSupportsWebURLWithMaxCount": 1,
            "NSExtensionActivationSupportsWebPageWithMaxCount": 1,
            "NSExtensionActivationSupportsImageWithMaxCount": 10,
            "NSExtensionActivationSupportsMovieWithMaxCount": 1,
            "NSExtensionActivationSupportsFileWithMaxCount": 1
          },
          "androidIntentFilters": [
            "text/*",
            "image/*",
            "video/*",
            "audio/*",
            "application/*"
          ],
          "androidMultiIntentFilters": [
            "image/*"
          ]
        }
      ]
    ]

https://github.com/user-attachments/assets/55b82f24-32b3-416a-b11a-24f84de63db3

To Reproduce

Additional context

achorein commented 1 week ago

When you initiate a share for a PDF in Safari, it will actually consider 2 input items: the PDF and the URL. To manage this we need a custom NSExtensionActivationRule. But it's not handle in this plugin yet.

a workaround is to use chrome on iOS to share pdf from the url

you can configure custom activation rule like this on your app.json:

    "plugins": [
      [
        "expo-share-intent",
        {
              "iosActivationRules": "SUBQUERY (\nextensionItems,\n$extensionItem,\nSUBQUERY (\n$extensionItem.attachments,\n$attachment,\nANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO \"com.adobe.pdf\"\n|| ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO \"public.file-url\"\n|| ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO \"public.url\"\n|| ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO \"public.jpeg\"\n|| ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO \"public.png\"\n).@count == $extensionItem.attachments.@count\n).@count >= 1",
         ...
        }
      ],

with this configuration (and some code update), the app appear in sharing view.

image

but the plugin doesn't handle it in the custom view

image