分享扩展React Native-Expo [英] Share extension react native - expo

查看:122
本文介绍了分享扩展React Native-Expo的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 expo 创建了一个本机应用程序.现在,我正在寻找该应用程序的共享扩展名,以将CSV数据从电子邮件附件导入到我的应用程序中.

I have created a react-native app using expo. Now I am looking for share-extension to the app to import CSV data from email attachment to my app.

我已经尝试过 npm软件包,但这对我不起作用(我无法使用Xcode中的npm包来构建我的项目)

I have tried npm package but that does not work for me(I was not able to build my project with that npm package in Xcode)

我认为react-native或expo没有任何共享API

I think react-native or expo does not have any share API

在这张照片中,您可以看到他如何获得将数据导入应用程序的选项.

In this picture, you can see how he got the option to import data into the app.

我了解没有共享扩展API,我认为react-native和Expo都没有用,因为您可以创建应用程序,但不能扩展它.

I understand that without share extension API, I think react-native and Expo both are useless because you can create the app but you don't expand it.

寻找解决方案或任何其他替代解决方案.

Looking for the solution or any other alternate solution.

推荐答案

恐怕世博会无法实现.

首先,您是在寻找一种创建自己的扩展程序的方法,还是只是希望您的应用程序位于右侧屏幕快照中的使用列表打开"中? (共享和打开方式"是两个不同的东西.)

First of all, are you looking for a way to create your own extension, or do you just want your app to be in the "open with list" that you have in the screenshot on the right? (Sharing and "open with" are two distinct things.)

如果您只希望将您的应用程序列在标准的使用列表打开"中,则无需使用 github.com/alinz/react-native-share-extension ,因为它具有不同的用途.引用仓库:

If you just want your app to be listed in the standard "open with list", you do not need to use github.com/alinz/react-native-share-extension since it serves a different purpose. To quote the repo:

这是一个帮助程序模块,它将react native用作引擎来为您的应用程序驱动共享扩展.

This is a helper module which brings react native as an engine to drive share extension for your app.

因此,使用该软件包,您可以使用react native来创建自己的共享扩展名

So with the package you can use react native to create your own share extension

要使您的应用进入打开列表",您需要进入目标设置并根据屏幕截图进行更改(例如MS word).在此处了解更多信息.但是,恐怕您如果不退出就无法通过Expo.

To get your app into the "open with list", you need to go to target settings and change it according to the screenshot (example for MS word). Read more about it here. However, I'm afraid you won't be able to do this with expo without ejecting.

如何在react-native中获取文件的url?您需要确保libRCTLinking.a在Xcode的Link Binary with Libraries中(可能已经在其中了).然后,您可以按照 docs 并调用Linking.getInitialURL来获取文件网址.然后,这实际上取决于您要对文件执行的操作.如果您需要复杂的东西,则可能需要编写本机代码.如果仅要将文件上传到某些服务器,则可以使用此提交.有关如何使用Blob支持的示例,请参见此处.

How to get the url of the file in react-native? You need to make sure that libRCTLinking.a is in the Link Binary with Libraries in Xcode (it'll probably be there already). And then you can follow the docs and call Linking.getInitialURL to get the file url. Then it really depends on what you want to do with the file. If you need something complicated, you'll likely need to write native code. If you just want to upload the file to some server, then you can make use of blob support that was added to RN 0.54 in this commit. An example of how to use the blob support is here.

这篇关于分享扩展React Native-Expo的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆