简体   繁体   English

如何创建react native ios共享扩展应用程序

[英]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. 您需要更改/扩展/重写NSExtensionActivationRuleConfig.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.

相关问题 在React Native应用和Swift Share Extension之间共享UserDefaults - Share UserDefaults between React Native app and Swift Share Extension 分享在本机 android/ios 中不起作用? - Share not working in react native android/ios? 如何使用 react-native 创建文件扩展名? - How to create a file extension using react-native? 在为发行版进行编译时,如何让React Native将JS捆绑包放入Share Extension中? - How can I get React Native to put JS bundle in Share Extension when compiling for Release? 如何防止Android操作系统在导航时关闭我的React Native共享扩展? - How to prevent Android OS from closing my React Native share extension when navigating away? 尝试共享 Android 后 react-native-share 应用程序崩溃 - react-native-share App crashing after trying to share Android 如何在 react-native (web/android/ios) 中的图像上创建链接? - How to create a link on an image in react-native (web/android/ios)? 如何修复IOS设备上的应用程序崩溃 - How to fix app crashing on IOS devices react-native 如何通过IOS上的本机响应将视频从我的应用下载到照片 - how to download video from my app to photos by react native on IOS 如何在真实设备上捆绑和部署React-Native iOS应用 - How to bundle and deploy React-Native iOS app on real device
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM