![使用react-native [Android]启动邮件应用程序,第1张 使用react-native [Android]启动邮件应用程序,第1张](/aiimages/%E4%BD%BF%E7%94%A8react-native+%5BAndroid%5D%E5%90%AF%E5%8A%A8%E9%82%AE%E4%BB%B6%E5%BA%94%E7%94%A8%E7%A8%8B%E5%BA%8F.png)
有没有办法使用Android上的链接启动邮件应用程序.
重点是方案(深层链接)消息:仅适用于iOS.
这是一个在iOS上运行但在AndroID上不运行的小例子:
linking.canopenURL('message:0').then(supported => { if (!supported) { console.log('Can\'t handle url'); } else { return linking.openURL('message:0'); }});很多帖子关于活动意图或关于计划mailto的官方/非官方会谈:但我不想写一封电子邮件.我想打开邮件应用程序,而不是用户可以查看我发送给他的电子邮件.
顺便说一下,我正在使用react-native.
解决方法:
我用RN中的Native模块解决了这个问题
首先在Js中打开邮箱的跨平台代码:
openMailApp() { if (Platform.OS === 'androID') { NativeModules.UIMailLauncher.launchMailApp(); // UIMailLauncher is the return; } linking.openURL('message:0'); // iOS return; }链接是React-Native提供的跨平台.无论如何,URL消息:0在AndroID上不起作用.
我找到的唯一解决方案是在我的应用程序中创建一个实习包装器并在Java中创建一个ReactMethod.
@ReactMethod public voID launchMailApp() { Intent intent = new Intent(Intent.ACTION_MAIN); intent.addcategory(Intent.category_APP_EMAIL); getCurrentActivity().startActivity(intent); }如果您已经使用React-Native框架开发了本机代码,那么这是一个基本的ReactMethod
private static final String REACT_MODulE = "UIMailLauncher"; @OverrIDe public String getname() { return REACT_MODulE; } 总结 以上是内存溢出为你收集整理的使用react-native [Android]启动邮件应用程序全部内容,希望文章能够帮你解决使用react-native [Android]启动邮件应用程序所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)