使用Linking.openURL('mailto:')与expo链接打开邮件应用程序与'撰写邮件'屏幕,我如何打开邮件应用程序直接在收件箱选项卡?
Linking.openURL('mailto:')
vwoqyblh1#
受this stack overflow post的启发,你可以在iOS上使用message:// url方案来实现这一点,如果没有提供内容,则默认为iOS上的电子邮件收件箱。对于android来说,事情有点棘手。你需要expo-intent-launcher和一些额外的参数来完成交接。一个完整的解决方案可能如下所示:
message://
import { startActivityAsync, ActivityAction } from 'expo-intent-launcher'; [...] if (Platform.OS === "android") { const activityAction = "android.intent.action.MAIN"; const intentParams: IntentLauncher.IntentLauncherParams = { category: "android.intent.category.APP_EMAIL", }; IntentLauncher.startActivityAsync(activityAction, intentParams); } else if (Platform.OS === "ios") { Linking.openURL('message://'); }
由于iPhone模拟器没有安装邮件客户端,因此请尽可能在真实的设备上进行测试。List of URL schemes on wikipedia
1条答案
按热度按时间vwoqyblh1#
受this stack overflow post的启发,你可以在iOS上使用
message://
url方案来实现这一点,如果没有提供内容,则默认为iOS上的电子邮件收件箱。对于android来说,事情有点棘手。你需要expo-intent-launcher和一些额外的参数来完成交接。一个完整的解决方案可能如下所示:
由于iPhone模拟器没有安装邮件客户端,因此请尽可能在真实的设备上进行测试。
List of URL schemes on wikipedia