iphone 4.0 以编程方式发送短信

发布于 2024-09-24 06:33:37 字数 542 浏览 0 评论 0原文

我正在开发一个简单的应用程序,在其中我需要以编程方式向我的朋友发送短信。 所以编写下面的代码来发送短信。

MFMessageComposeViewController *picker = [[[MFMessageComposeViewController alloc] init]autorelease];
if([MFMessageComposeViewController canSendText])
{
    picker.messageComposeDelegate = self;   
    picker.recipients =[NSArray arrayWithObject:@"123"]; 
    picker.body=@"hello";   
    [self presentModalViewController:picker animated:YES];
}

但我不想加载消息选择器并向朋友发送短信。 // [selfpresentModalViewController:pickeranimated:YES];
是否可以在不单击发送按钮的情况下发送短信?

I am working on a simple application in which I need send sms programmatically to my friends.
so write below code for sending sms .

MFMessageComposeViewController *picker = [[[MFMessageComposeViewController alloc] init]autorelease];
if([MFMessageComposeViewController canSendText])
{
    picker.messageComposeDelegate = self;   
    picker.recipients =[NSArray arrayWithObject:@"123"]; 
    picker.body=@"hello";   
    [self presentModalViewController:picker animated:YES];
}

but I do not want to load message picker and send sms to friends.
// [self presentModalViewController:picker animated:YES];
is it possible to send sms without click in send button.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

千年*琉璃梦 2024-10-01 06:33:37

iOS API 中可用的两个选项是:

  • MFMessageComposeViewController - 需要用户确认
  • sms:// URL - 需要用户确认

如果您想做其他事情,您需要与 SMS 网关提供商建立基于网络的服务并通过该服务发送消息。我曾经与这样一个具有 HTTP POST 接口的提供商合作,该接口使用起来非常简单。这有几个重要的区别:

  • 短信实际上是由网关服务器发送的,而不是手机(尽管您通常可以重写发件人 ID 并向手机所有者收取消息费用),
  • 您需要付费才能访问该服务可能包括按消息付费(或更可能是按 1,000 条消息付费)

另请注意,在审核您的应用程序时,代表用户发送短信而不进行确认可能会遭到反对,尤其是在付费的情况下。

The two options available in the iOS API are:

  • MFMessageComposeViewController - requires user confirmation
  • sms:// URLs - requires user confirmation

If you want to do something else, you'll need to set up a network-based service with an SMS gateway provider and send messages via that. I used to work with such a provider that had an HTTP POST interface, which would be simple enough to use. That comes with a couple of important differences:

  • the SMS is actually sent by the gateway server, not the handset (though you can usually rewrite the sender ID and get the message billed to the handset owner)
  • you'll need to pay for access to the service, which might include paying per message (or more likely per 1,000 messages)

Also note that sending SMS on your users' behalf without confirmation might be frowned upon when your app is reviewed, especially if they're billed for.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文