android - 如何将导出的 whatsapp 文档共享到 react-native 应用程序
问题描述
我是 React native 的新手,我想导出我的 whatsapp 聊天并将其分享到我的 react native 应用程序。
有两个软件包可以提供帮助:
https://www.npmjs.com/package/react-native-file-share-intent
https://github.com/meedan/react-native-share-menu。
我尝试使用第二个包,因为如果我们使用 react-navigation,第一个包不起作用,所以我安装了第二个包,它工作得非常好,但是在我遇到两个问题之后:
- 如果我使用这个包,主屏幕图标没有创建,我不知道为什么图标没有在主屏幕中创建,而是放在共享缩进中
- 当我尝试从文件管理器共享文本文档时,反应本机应用程序图标被放置在共享缩进中,并且它运行良好。但是我在什么应用程序中尝试过的同样的事情意味着它不起作用。我认为当我从 WhatsApp 导出时,它最初是作为临时文件创建的。这就是为什么我的应用程序没有显示在该共享缩进中的原因。
我在 GitHub 存储库中推送了我的代码,存储库的链接是:
https ://github.com/BalaRajendran/sharemenu-reactnative
App.js - https://github.com/BalaRajendran/sharemenu-reactnative/blob/master/App.js
export default class App extends Component {
constructor(props) {
super(props);
this.state = {
fileUrl: null,
};
}
componentDidMount() {
if (RNFileShareIntent) {
RNFileShareIntent.getFilepath((url) => {
this.setState({ fileUrl: url });
})
}
}
AndroidManifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.sharemenu">
<uses-permission android:name="android.permission.INTERNET" />
<application
android:name=".MainApplication"
android:label="@string/app_name"
android:icon="@mipmap/ic_launcher"
android:roundIcon="@mipmap/ic_launcher_round"
android:allowBackup="false"
android:theme="@style/AppTheme">
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
android:windowSoftInputMode="adjustResize"
>
<intent-filter>
///changed code according to react-native-share-menu
<action android:name="android.intent.action.PICK"/>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="text/*" />
<data android:mimeType="image/*" />
<data android:mimeType="file/*" />
<data android:mimeType="application/*" />
//
</intent-filter>
</activity>
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
</application>
</manifest>
所以你能帮我解决我的问题吗?
解决方案
推荐阅读
- flutter - 使用热重载保留嵌套的 Navigator 路线
- php - Woocommerce 预订 - 以编程方式调整可用性
- docker-compose - 如何注册 gitlab runner?
- node.js - 如何在不触及其他必需属性的情况下更新一个特定的必需属性?
- php - 从 AWS S3 GetObject() 获取 blob 的 PHP readfile()
- typescript - 如何收集特定令牌以向特定设备发送推送通知
- azure - 为什么 IoTHubMessages 是 Azure Functions 中的一个数组
- java - 使用 JDK 14 制作的应用程序能否在安装了 Java 版本 8 的机器上运行?
- javascript - Function.prototype() 到底是什么?它是一个合适的默认值吗?
- python - 如何在 pandas 中创建一个新列迭代现有列而不会出现下一个错误?