iphone 4.0 sending sms programmatically

依然范特西╮ 提交于 2019-12-11 02:32:57

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/3758664/iphone-4-0-sending-sms-programmatically

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!