首页 > 解决方案 > 如何使用 React Native 在 Android 设备上打开本机邮件,就像使用 'Linking.openURL()' iOS 完成的一样

问题描述

如何使用 react native 在 android 设备上打开本机邮件。我目前正在使用Linking.openURL(),但这仅适用于 iOS。

我正在尝试使用 React Native 在 android 设备上打开本机邮件。我目前正在使用Linking.openURL(url),这对 iOS 设备没有问题,但不适用于 android 设备。

可以的话请指教。非常感激。

标签: javascriptandroidiosreactjsreact-native

解决方案


我通过进入 android.manifest.xml 解决了这个问题,并添加了以下意图,这允许我在 android 上打开电子邮件。希望它可以帮助某人!

<intent-filter>
    <action android:name="android.intent.action.VIEW"/>
    <action android:name="android.intent.action.SENDTO"/>
    <data android:scheme="mailto"/>
    <category android:name="android.intent.category.DEFAULT"/>
    <category android:name="android.intent.category.BROWSABLE"/>
</intent-filter>
<intent-filter android:label="@string/app_name">
    <action android:name="android.intent.action.SEND"/>
    <data android:mimeType="*/*"/>
    <category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
<intent-filter android:label="@string/app_name">
    <action android:name="android.intent.action.SEND_MULTIPLE"/>
    <data android:mimeType="*/*"/>
    <category android:name="android.intent.category.DEFAULT"/>
</intent-filter>

在这里找到了答案android intent-filter to listen for sent email addresses?


推荐阅读