Common small features for IOS communication

Source: Internet
Author: User

CallA. The simplest and most straightforward way: Skip directly to the dial-up interface

Nsurl *url = [Nsurl urlwithstring:@ "tel://10010"];

[[UIApplication sharedapplication] openurl:url];

Disadvantages

After the call, will not automatically return to the original application, directly in the Call log interface

B. Before dialing, the box asks the user whether to dial, and automatically returns to the original application after dialing out.

Nsurl *url = [Nsurl urlwithstring:@ "telprompt://10010"];

[[UIApplication sharedapplication] openurl:url];

Disadvantages

Because it is a private API, it may not be audited by

C. Create a UIWebView to load the URL, and automatically return to the original application after the dial is finished

if (_webview = = nil) {

_webview = [[UIWebView alloc] Initwithframe:cgrectzero];

}

[_webview loadrequest:[nsurlrequest requestwithurl:[nsurl urlwithstring:@ "tel://10010"]];

Before dialing, the box asks the user whether to dial, and automatically returns to the original program after dialing out.

Note: This webview must not set the size, otherwise it will block the other interface, he just used to call, do not need to display

Texting

A. Jump directly to the text messaging interface, but cannot specify the text message content, and can not automatically return to the original application

Nsurl *url = [Nsurl urlwithstring:@ "sms://10010"];

[[UIApplication sharedapplication] openurl:url];

B. If you want to specify a text message, you have to use the MESSAGEUI framework

Include primary header file

#import <MessageUI/MessageUI.h>

Display the controller that sent the text message

Mfmessagecomposeviewcontroller *VC = [[Mfmessagecomposeviewcontroller alloc] init];

Set SMS Content

Vc.body = @ "Have you eaten yet?" ";

Set up a recipient list

vc.recipients = @[@ "10010", @ "02010010"];

Set up Proxy

Vc.messagecomposedelegate = self;

Display Controller

[Self PRESENTVIEWCONTROLLER:VC animated:yes completion:nil];

Proxy method, when the SMS interface is closed when the call, after the end will automatically return to the original application

-(void) Messagecomposeviewcontroller: (Mfmessagecomposeviewcontroller *) controller didfinishwithresult: ( Messagecomposeresult) Result

{

Close the SMS interface

[Controller Dismissviewcontrolleranimated:yes Completion:nil];

if (result = = messagecomposeresultcancelled) {

NSLog (@ "Cancel send");

} else if (result = = Messagecomposeresultsent) {

NSLog (@ "already issued");

} else {

NSLog (@ "send failed");

}

}

Send e-mail

A. Use your own mail client, do not automatically return to the original application after sending the message

Nsurl *url = [Nsurl urlwithstring:@ "mailto://[email protected]";

[[UIApplication sharedapplication] openurl:url];

B. Similar to the 2nd method of texting, except that the controller class name is: Mfmailcomposeviewcontroller

Assuming that the message is sent as shown in the image on the right, the code implementation to see note N message sent after the proxy method callback, after the end will automatically return to the original application

-(void) Mailcomposecontroller: (Mfmailcomposeviewcontroller *) controller didfinishwithresult: (mfmailcomposeresult) Result Error: (NSERROR *) error

{

Close the Mail interface

[Controller Dismissviewcontrolleranimated:yes Completion:nil];

if (result = = mfmailcomposeresultcancelled) {

NSLog (@ "Cancel send");

} else if (result = = Mfmailcomposeresultsent) {

NSLog (@ "already issued");

} else {

NSLog (@ "send failed");

}

}

Open other frequently used files

If you want to open some common files, such as HTML, TXT, PDF, PPT, and so on, you can use UIWebView to open just to tell the UIWebView file URL to open a remote shared resources, such as the HTTP protocol, You can also call the system's own Safari browser:

Nsurl *url = [Nsurl urlwithstring:@ "http://www.baidu.com"];

[[UIApplication sharedapplication] openurl:url];

App ratings

To improve the user experience of the app, it's often necessary to invite users to score app ratings simply by jumping to AppStore to show their apps, and then by writing their own comments about how to jump to AppStore and show their own application methods

NSString *appid = @ "725296055";//appstore basic information applied in my app

NSString *str = [NSString stringWithFormat:

@ "itms-apps://itunes.apple.com/cn/app/id%@?mt=8", AppID];

[[UIApplication sharedapplication] Openurl:[nsurl Urlwithstring:str]];

Common small features for IOS communication

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.