IOS phone/sms/Mail/uiapplication

Source: Internet
Author: User

1, call the three ways:
1??
• The simplest and most direct way: Jump directly to the dialing interface?

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

[[UIApplication sharedapplication] openurl:url];
• Shortcomings when the phone is finished, it will not be automatically returned to the original should be used, directly stay in the call record field?

2??

• Do you want to check the box before dialing? Does the user dial, after the dial is done? automatically back to the original should?
Nsurl *url = [Nsurl urlwithstring:@ "telprompt://10010"];

[[UIApplication sharedapplication] openurl:url];
• Disadvantage because it is a private API, so it may not be audited by

3??
Usually with this
• Create a UIWebView to load the URL, after the dial can? automatically return to the original should?
_webview = [[UIWebView alloc] Initwithframe:cgrectzero];

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

Note: This webview should not be added to the interface, or will block other sectors?
———————————————————————————

Two ways to send text messages 2:

1??
• Jump directly to the texting field, but can't specify the content of the text message? Automatically back to the original should?
Nsurl *url = [Nsurl urlwithstring:@ "sms://10010"];
[[UIApplication sharedapplication] openurl:url];

2??

• If you want to specify a text message, you have to use the MESSAGEUI framework • Include the main header? file
#import <MessageUI/MessageUI.h>

• Display the Controller for texting

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];

To implement the Proxy method:

• Agent method, when the text messaging sector closed when the tune, after the end will be? Automatically back to the original?

-(void) Messagecomposeviewcontroller: (Mfmessagecomposeviewcontroller *) Controllerdidfinishwithresult: ( Messagecomposeresult) Result

{//Close SMS interface?

* Clicking the Cancel button will automatically call

*/

[Controller Dismissviewcontrolleranimated:yes Completion:nil];

if (result = = messagecomposeresultcancelled) {NSLog (@ "Cancel send");

} else if (result = = Messagecomposeresultsent) {NSLog (@ "already issued");

} else {NSLog (@ "send failed");
}
}
--------------------------------
3, send e-mail

• Similar to the 2nd method of texting, except for the controller class name: Mfmailcomposeviewcontroller
• Assume that the message is sent as shown in the image on the right, and the code implementation looks at the notes

Cannot send mail

if (![ Mfmailcomposeviewcontroller Cansendmail]) return;

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

Set Message subject

[VC setsubject:@ "Meeting"];

Set up message content

[VC setmessagebody:@] The meeting this afternoon "Ishtml:no";

Set up a recipient list

[VC settorecipients:@[@ "[email protected]"];

Set up a CC person list

[VC setccrecipients:@[@ "[email protected]"];

Set up a BCC list

[VC setbccrecipients:@[@ "[email protected]"];

Add an attachment (a picture)

UIImage *image = [UIImage imagenamed:@ "Lufy.png"];

NSData *data = uiimagepngrepresentation (image);

[VC addattachmentdata:data mimetype:@ "Image/png" filename:@ "Lufy.png"];

Set up Proxy

Vc.mailcomposedelegate = self;

Display Controller

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

};

• The agent after the mail is sent? method callback, after the end of the post? Automatic return to the original should?

/**

* Clicking the Cancel button will automatically call

*/

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

{

[Controller Dismissviewcontrolleranimated:yes Completion:nil];

if (result = = mfmailcomposeresultcancelled) {NSLog (@ "Cancel send");

} else if (result = = Mfmailcomposeresultsent) {NSLog (@ "already issued");

} else {NSLog (@ "send failed");

}

---------------------

4. Open another file:

Open Other common? files

• If you want to open? Some common files, such as HTML, TXT, PDF, PPT, etc., can be opened with the UIWebView

• Just tell UIWebView the URL of the file
• What about open? A remote shared resource, such as an HTTP protocol, can also be adjusted for the system? Bring your Own

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

[[UIApplication sharedapplication] openurl:url];
----------------------
5. Jump between applications:

To be used in a rating

• For the purpose of high-demand, the user experience, often need to invite?
• Should I use a score? No, it is to jump to the AppStore exhibition, the self-made, and then by the users to write their own comments

• How to jump to the AppStore, and show the "self-made"? Method 1

NSString *appid = @ "444934666";
NSString *str = [NSString stringWithFormat: @ "itms-apps://ax.itunes.apple.com/webobjects/mzstore.woa/wa/ viewcontentsuserreviews?type=purple+software&id=%@ ", AppID];
[[UIApplication sharedapplication] Openurl:[nsurl Urlwithstring:str]];

?? Method 2
NSString *str = [NSString stringWithFormat:

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

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

IOS phone/sms/Mail/uiapplication

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.