<span id="Label3"></p><p><p>The SMS function of the iOS call system can be divided into two kinds: 1, the system sends the text message in the outgoing Program. 2, within the program calls the system to send text Messages. The second benefit is that users can return to the app after Texting. This is very important for the app.</p></p>Send text message to the system by the program<p><p>This method is actually very simple, call OpenURL directly:</p></p><p><p></p></p><pre code_snippet_id="654166" snippet_file_name="blog_20150427_1_4446441" name="code" class="html"><pre code_snippet_id="654166" snippet_file_name="blog_20150427_1_4446441" name="code" class="html">[[uiapplication Sharedapplication]openurl:[nsurl urlwithstring:@ "sms://13888888888"];</pre></pre><br><p><p></p></p>Call system within the program to send SMS 1) import messageui.framework, and introduce the header file:<pre code_snippet_id="654166" snippet_file_name="blog_20150427_2_2555705" name="code" class="html"><pre code_snippet_id="654166" snippet_file_name="blog_20150427_2_2555705" name="code" class="html">#import <MessageUI/MessageUI.h></pre></pre><br>2) Implement Proxy Method Mfmessagecomposeviewcontrollerdelegate<pre code_snippet_id="654166" snippet_file_name="blog_20150427_3_523266" name="code" class="html"><pre code_snippet_id="654166" snippet_file_name="blog_20150427_3_523266" name="code" class="html"> -(void) messagecomposeviewcontroller: (mfmessagecomposeviewcontroller *) Controller didfinishwithresult: ( Messagecomposeresult) result{ [self dismissviewcontrolleranimated:yes completion:nil]; Switch (result) {case messagecomposeresultsent: //message transfer succeeded break ; Case Messagecomposeresultfailed: //message delivery failed break ; Case Messagecomposeresultcancelled: //message cancelled by user ; Default: Break ; }}</pre></pre><br>3) Send SMS<pre code_snippet_id="654166" snippet_file_name="blog_20150427_4_6746721" name="code" class="html"> -(void) showmessageview: (nsarray *) phones title: (nsstring *) title body: (nsstring *) body{if ([mfmessagecomposeviewcont Roller cansendtext]) {mfmessagecomposeviewcontroller * controller = [[mfmessagecomposeviewcontroller alloc] in it]; Controller.recipients = phones; Controller.navigationBar.tintColor = [uicolor redcolor]; Controller.body = body; Controller.messagecomposedelegate = self; [self Presentviewcontroller:controller Animated:yes completion:nil]; [[[controller viewcontrollers] lastobject] navigationitem] settitle:title];//modify SMS interface title} Else {uialertvie W *alert = [[uialertview alloc] initwithtitle:@ "message" message:@ "the Device SMS feature not supported "delegate:nil C ancelbuttontitle:@ "ok" otherbuttontitles:nil, nil]; [alert show]; }} </pre><br><p><p></p></p><p><p>Parameter phones: an array of mobile phone numbers for texting, in which the array is a single-shot, multiple-mass.</p></p>4) call the method of sending text messages<pre code_snippet_id="654166" snippet_file_name="blog_20150427_5_810588" name="code" class="html"><pre code_snippet_id="654166" snippet_file_name="blog_20150427_5_810588" name="code" class="html"> [self showmessageview:[nsarray arraywithobjects:@ "13888888888", @ "13999999999", nil] title:@ "test" body:@ "are You local tyrants, are you da?" ];</pre></pre><br><p><p>My iOS development: Iosdevtip</p></p><p><p>Code: Sendmsgmaster</p></p><br><p><p>iOS call system text message function detailed</p></p></span>
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service