iOS development, call calls, text messages, open URLs and other mobile phone basic functions

Source: Internet
Author: User
<span id="Label3"></p><p><p>1. Call the <span style="color: #ff0000;">iOS system to bring your own mail</span></p></p><pre><pre>[[uiapplication sharedapplication] openurl:[nsurl urlwithstring:<span style="color: #800000;">@ "</span><span style="color: #800000;">mailto://[email protected]</span> <span style="color: #800000;"> "</span>]];</pre></pre><p><p></p></p><p><p></p></p><p><p>2. Call <span style="color: #ff0000;"></span> phone call</p></p><p><p><1> the way the phone is usually dialed in the app is that the iphone interface will stay in the telephone interface:</p></p><pre><pre>[[uiapplication sharedapplication] openurl:[nsurl urlwithstring:<span style="color: #800000;">@ "</span><span style="color: #800000;">tel://159*****334</span><span style="color: #800000;">"</span>] ;</pre></pre><p><p></p></p><p><p><2> can be used as follows to enable users to automatically return to the app after the Call:</p></p><pre><pre>Uiwebview*callwebview =<span style="color: #000000;"></span>*telurl =[nsurl urlwithstring:<span style="color: #800000;">@ "</span><span style="color: #800000;">tel://159*****334</span><span style="color: #800000;">"</span>]; <span style="color: #008000;">//</span> <span style="color: #008000;">looks like Tel:</span> <span style="color: #008000;">//</span> <span style="color: #008000;">or tel: all right.</span>  <span style="color: #000000;">[callwebview loadrequest:[nsurlrequest requestwithurl:telurl]; [self.view addsubview:callwebview];</span></pre></pre><p><p></p></p><p><p><3> There is also a private method: (may not be audited)</p></p><pre><pre>[[uiapplication sharedapplication] openurl:[nsurl urlwithstring:<span style="color: #800000;">@ "</span><span style="color: #800000;">telprompt://10086</span><span style="color: #800000;">" </span>]];</pre></pre><p><p></p></p><p><p></p></p><p><p>3. Call <span style="color: #ff0000;">SMS <em id="__mceDel" style="line-height: 1.5;">  </em> </span></p></p><pre><pre>[[uiapplication sharedapplication] openurl:[nsurl urlwithstring:<span style="color: #800000;">@ "</span><span style="color: #800000;">sms://800888</span><span style="color: #800000;">"</span>];</pre></pre><p><p></p></p><p><p></p></p><p><p>  <span style="text-decoration: underline;">Ps:</span></p></p><p><p>Call phone can pass number, call SMS can only set number, cannot initialize SMS Content.</p></p><p><p>If you need to pass content, you can do the following:<br>Join: Messageui.framework</p></p><p><p>#import <MessageUI/MFMessageComposeViewController.h></p></p><p><p>Implement Proxy: Mfmessagecomposeviewcontrollerdelegate</p></p><p><p>    </p></p><p><p>Call the Sendsms function</p></p><pre><pre>content, recipient List<br>-(<span style="color: #0000ff;">void</span>) sendsms: (nsstring *) bodyofmessage recipientlist: (nsarray *<span style="color: #000000;">) recipients { </span>*controller =< c3> [[[mfmessagecomposeviewcontroller alloc] init] autorelease]; <span style="color: #0000ff;">if</span>     <span style="color: #000000;">([mfmessagecomposeviewcontroller cansendtext]) {     </span>=<span style="color: #000000;"> bodyofmessage ;     </span> =<span style="color: #000000;"> recipients;     </span> = self<span style="color: #000000;"> ; [self Presentmodalviewcontroller:controller animated:yes]; } }    </span></pre></pre><p><p></p></p><pre><span style="color: #008000;"><span style="color: #008000;">//</span></span><span style="color: #008000;"><span style="color: #008000;">processing the results of a response sent out</span></span>- (<span style="color: #0000ff;"><span style="color: #0000ff;">void</span></span>) Messagecomposeviewcontroller: (mfmessagecomposeviewcontroller *<span style="color: #000000;"><span style="color: #000000;">controller didfinishwithresult: (messagecomposeresult) result{[self dismissmodalviewcontrolleranimated:yes]; </span></span><span style="color: #0000ff;"><span style="color: #0000ff;">if</span></span>(result = =<span style="color: #000000;"><span style="color: #000000;">Messagecomposeresultcancelled) NSLog (</span></span><span style="color: #800000;"><span style="color: #800000;">@"</span></span><span style="color: #800000;"><span style="color: #800000;">Message cancelled</span></span><span style="color: #800000;"><span style="color: #800000;">"</span></span><span style="color: #000000;"><span style="color: #000000;">) </span></span><span style="color: #0000ff;"><span style="color: #0000ff;">Else</span></span> <span style="color: #0000ff;"><span style="color: #0000ff;">if</span></span>(result = =<span style="color: #000000;"><span style="color: #000000;">Messagecomposeresultsent) NSLog (</span></span><span style="color: #800000;"><span style="color: #800000;">@"</span></span><span style="color: #800000;"><span style="color: #800000;">Message sent</span></span><span style="color: #800000;"><span style="color: #800000;">"</span></span><span style="color: #000000;"><span style="color: #000000;">) </span></span><span style="color: #0000ff;"><span style="color: #0000ff;">Else</span></span><span style="color: #000000;"><span style="color: #000000;">NSLog (</span></span><span style="color: #800000;"><span style="color: #800000;">@"</span></span><span style="color: #800000;"><span style="color: #800000;">Message failed</span></span><span style="color: #800000;"><span style="color: #800000;">"</span></span><span style="color: #000000;"><span style="color: #000000;">) }</span></span></pre><p><p>The default text messaging interface is in english, the solution is:<br>Add a group of Chinese to the localization in. xib It's ok.</p></p><p><p></p></p><p><p>4, 4, Call iOS system <span style="color: #ff0000;">comes with browser Safari</span></p></p><pre><pre>[[uiapplication sharedapplication] openurl:[nsurl urlwithstring:<span style="color: #800000;">@ "</span><span style="color: #800000;">http://www.baidu.com</span> <span style="color: #800000;"> "</span>]];</pre></pre><p><p></p></p><p><p>iOS development, call calls, text messages, open URLs and other mobile phone basic functions</p></p></span>

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.