本文介绍了如何以编程方式在iPhone上发送短信?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有人知道是否可以使用官方SDK / Cocoa Touch从 iPhone 以编程方式发送 SMS

解决方案

限制



如果您可以在程序中发送短信在iPhone上,你将能够编写游戏,垃圾邮件的人在后台。我相信你真的想有你的朋友的垃圾邮件,试试这个新游戏!它roxxers我的boxxers,你的也将太!roxxersboxxers.com !!!!如果你现在注册,你会得到3,200 RB



苹果对自动(甚至部分自动化)短信和拨号操作有限制。 (假设游戏在一天的特定时间拨打911)



最好的办法是在互联网上设置一个使用在线短信发送服务的中间服务器,并且如果您需要完全自动化,则通过该路由发送SMS。 (例如,您的程序在iPhone上发送一个UDP数据包到您的服务器,发送真实的短信)



iOS 4更新



然而,iOS 4现在提供了一个可以导入到应用程序中的视图控制器。您预填充了SMS字段,然后用户可以在控制器中启动SMS发送。与使用sms:...url格式不同,这允许您的应用程序保持打开,并允许您填充正文字段。您甚至可以指定多个收件人。



这可以防止应用程序发送自动短信,而无需用户明确感知。您仍然无法从iPhone本身发送完全自动化的短信,它需要一些用户交互。但这至少允许您填充所有内容,并避免关闭应用程序。



类已有详细记录,显示实施起来有多容易。



iOS 5更新



iOS 5包括iPod touch和iPad设备的消息传递,所以虽然我还没有自己测试,但可能是所有iOS设备将能够通过MFMessageComposeViewController发送短信。如果是这种情况,则Apple正在运行SMS服务器,代表没有蜂窝调制解调器的设备发送消息。



iOS 6更新



此类别没有任何变更。



iOS 7更新



您现在可以检查您使用的消息介质是否将接受主题或附件,以及它将接受什么类型的附件。



iOS 8更新





iOS 9更新



此课程无任何变更。



此类别的限制



请注意,这不适用于没有iOS 4的手机,在iPod touch或iPad上工作,除了iOS 5以外。您必须在使用此控制器之前检测设备和iOS限制,否则可能会将您的应用限制为最近升级的3G,3GS和4 iPhones。 p>

然而,发送短信的中间服务器将允许任何和所有这些iOS设备发送短信,只要他们有互联网访问,所以它可能仍然是一个更好的解决方案许多应用。或者,使用两者,并且仅当设备不支持在线短信服务时,才会使用它们。


Does anybody know if it's possible, and how, to programmatically send a SMS from the iPhone, with the official SDK / Cocoa Touch?

解决方案

Restrictions

If you could send an SMS within a program on the iPhone, you'll be able to write games that spam people in the background. I'm sure you really want to have spams from your friends, "Try out this new game! It roxxers my boxxers, and yours will be too! roxxersboxxers.com!!!! If you sign up now you'll get 3,200 RB points!!"

Apple has restrictions for automated (or even partially automated) SMS and dialing operations. (Imagine if the game instead dialed 911 at a particular time of day)

Your best bet is to setup an intermediate server on the internet that uses an online SMS sending service, and send the SMSs via that route if you need complete automation. (ie, your program on the iPhone sends a UDP packet to your server, which sends the real SMS)

iOS 4 Update

iOS 4, however, now provides a viewcontroller you can import into your application. You prepopulate the SMS fields, then the user can initiate the SMS send within the controller. Unlike using the "sms:..." url format, this allows your application to stay open, and allows you to populate both the to and the body fields. You can even specify multiple recipients.

This prevents applications from sending automated SMS without the user explicitly aware of it. You still cannot send fully automated SMS from the iPhone itself, it requires some user interaction. But this at least allows you to populate everything, and avoids closing the application.

The MFMessageComposeViewController class is well documented, and tutorials show how easy it is to implement.

iOS 5 Update

iOS 5 includes messaging for iPod touch and iPad devices, so while I've not yet tested this myself, it may be that all iOS devices will be able to send SMS via MFMessageComposeViewController. If this is the case, then Apple is running an SMS server that sends messages on behalf of devices that don't have a cellular modem.

iOS 6 Update

No changes to this class.

iOS 7 Update

You can now check to see if the message medium you are using will accept a subject or attachments, and what kind of attachments it will accept. You can edit the subject and add attachments to the message, where the medium allows it.

iOS 8 Update

No changes to this class.

iOS 9 Update

No changes to this class.

Limitations to this class

Keep in mind that this won't work on phones without iOS 4, and it won't work on the iPod touch or the iPad, except, perhaps, under iOS 5. You must either detect the device and iOS limitations prior to using this controller, or risk restricting your app to recently upgraded 3G, 3GS, and 4 iPhones.

However, an intermediate server that sends SMS will allow any and all of these iOS devices to send SMS as long as they have internet access, so it may still be a better solution for many applications. Alternately, use both, and only fall back to an online SMS service when the device doesn't support it.

这篇关于如何以编程方式在iPhone上发送短信?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-01 14:42