[英]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. 我希望我的本机应用程序可以从Whatsapp,Skype,Photos中分享。我尝试使用react-native-share-extension,但它只显示Safari浏览器中的扩展名。
How to implement the sharing feature in applications other than Safari in react-native for iOS? 如何在iOS中的react-native中实现Safari之外的应用程序中的共享功能?
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. 您需要更改/扩展/重写
NSExtensionActivationRule
在Config.plist
您的共享扩展的和留在反应本地股扩展包。 Read more about this key from author and in Apple docs directly. 从作者和Apple文档中直接阅读有关此密钥的更多信息。
So you can rewrite entirely rule to apply eg pdf files (as said in apple docs): 因此,您可以完全重写规则以应用例如pdf文件(如Apple文档中所述):
<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 . 可以在此处找到
NSExtensionActivationRule
所有键。
I fixed it by adding this in info plist 我通过在信息plist中添加它来修复它
<dict>
<key>NSExtensionActivationRule</key>
<dict>
<key>NSExtensionActivationSupportsImageWithMaxCount</key>
<integer>1</integer>
</dict>
</dict>
By default, react-native-share-extension only allows the sharing of urls from browsers. 默认情况下, react-native-share-extension仅允许从浏览器共享URL。 There is some extra configuration to add if you want to tell the system to show your extension when sharing a url that you seem to have missed.
如果您想在分享您似乎错过的网址时告诉系统显示您的扩展程序,可以添加一些额外的配置。
For iOS, you simply need to update the Info.plist
file and add the following: 对于iOS,您只需更新
Info.plist
文件并添加以下内容:
<key>NSExtensionAttributes</key>
<dict>
<key>NSExtensionActivationRule</key>
<dict>
<key>NSExtensionActivationSupportsWebURLWithMaxCount</key>
<integer>1</integer>
</dict>
</dict>
To confirm it's done correctly, this setting should then be displayed in XCode and allow a successful build: 要确认它已正确完成,此设置应显示在XCode中并允许成功构建:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.