Xamarin表单消息传递插件 [英] Xamarin forms messaging plugin

查看:75
本文介绍了Xamarin表单消息传递插件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚测试了新" Xamarin表单跨平台插件.它可以正常工作,并且在您要发送消息时,您可以导航到电话消息传递应用程序.据我所知,它受操作系统的限制,不允许您直接从应用程序内发送短信,如果您全部使用iOS上的NS API,这是否一样?如果您不希望启用短信应用程序,那么一个解决方案是拥有一个后端/api,但是它不仅需要该应用程序和一个单独的短信网关,还需要更多功能.所以我的问题是要知道是否有一个自定义解决方法,如果用户允许,可以直接从应用程序发送短信?

I've just tested the "new" Xamarin forms cross platform plugin. It works as it should and you get navigation to the phones messaging app when you are about to send a message. As I could read it is restricted by the OS to not let you send sms from within the app directly, is this the same if you go all native to the NS api on iOS? A solution if you don't want to have the sms app enabled is to have a backend/api, but then it also requires more than just the app and a separate sms gateway. So my question is to know if there is a custom workaround to just send a sms if the user allowed it, directly from the app?

推荐答案

在Android中,您可以使用SmsManager类发送短信. Xamarin的文档中有一个示例.需要添加SEND_SMS权限.这是该站点的代码段

In Android, you can use SmsManager class to send an Sms. There is an example in Xamarin's Documentation on how to do it.You need to add SEND_SMS permission. Here is the code snippet from the site

SmsManager.Default.SendTextMessage ("1234567890", null,"Hello from Xamarin.Android", null, null);

iOS不允许我们仅使用API​​直接发送短信.这是Apple施加的限制.推荐的方法是使用iPhone中安装的默认应用程序.我们可以从App内发送消息的最佳方法是使用MFMessageComposeViewController类.通过此操作,我们可以在应用程序内显示一个UI(由iOS提供),用户可以在其中填充正文"和收件人"字段并发送短信.

iOS does not allow us to Send an sms directly using an API alone. This is a restriction imposed by Apple. Recommended approach is use the default application installed in the iPhone. Best approach we can take to send message from within the App is to use the MFMessageComposeViewController class. With this we can present a UI (provided by iOS) within the App in which user can populate "Body" and "Recipient" fields and send Sms.

博客文章举例说明了如何在Xamarin中使用MFMessageComposeViewController

This blog post has an example of how to use MFMessageComposeViewController in Xamarin

这篇关于Xamarin表单消息传递插件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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