Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create a react native ios share extension app

I want my react-native app to be available for share from Whatsapp, Skype, Photos.. I tried using react-native-share-extension but it is only showing the extension in the Safari browser.

How to implement the sharing feature in applications other than Safari in react-native for iOS?

like image 696
Trinu Avatar asked Nov 03 '18 19:11

Trinu


2 Answers

This is because the default setup if this package is for sharing urls to your app.

You need to change/extend/rewrite NSExtensionActivationRule in Config.plist of your share extension and stay with react-native-share-extension package. Read more about this key from author and in Apple docs directly.

So you can rewrite entirely rule to apply e.g. pdf files (as said in apple docs):

<key>NSExtensionAttributes</key>
<dict>
    <key>NSExtensionActivationRule</key>
    <string>
        {extensionItems = ({
            attachments = ({
                registeredTypeIdentifiers = (
                    "com.adobe.pdf",
                    "public.file-url"
                );
            });
        })}
    </string>
</dict>

All keys for NSExtensionActivationRule could be found here.

like image 81
seclace Avatar answered Sep 24 '22 23:09

seclace


I fixed it by adding this in info plist

<dict>
        <key>NSExtensionActivationRule</key>
        <dict>
            <key>NSExtensionActivationSupportsImageWithMaxCount</key>
            <integer>1</integer>
        </dict>
    </dict>
like image 30
Trinu Avatar answered Sep 23 '22 23:09

Trinu