IOS phone SMS messages and more

Source: Internet
Author: User

The simplest and most straightforward way: jump directly to the dial-up interface

1

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

2

Before dialing, the box asks the user whether to dial or not 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

3

Create a UIWebView to load the URL and automatically go back to the original app when you're finished dialing

if (_webview = = nil) {

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

}

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

Note: This webview must not be added to the interface, or it will block other interfaces

Texting-Method 1

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



Texting-Method 2

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-Method 1

With your own mail client, will not automatically return to the original application after sending the message

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

[[UIApplication sharedapplication] openurl:url];

Send e-mail-Method 2

The 2nd method of texting is similar, 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 looks at the notes

The proxy method callback after the message is sent, will automatically return to the original application after sending

-(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 Common Files

If you want to open some common files, such as HTML, TXT, PDF, PPT, etc., you can use UIWebView open

Just tell the URL of the UIWebView file to

As for opening a remote shared resource, 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];

Sometimes it is necessary to open other applications in this application, such as jumping from A to B application

First, the B application has its own URL address (configured in info.plist)

b The URL address of the app is: mj://ios.itcast.cn

Then use UIApplication in a application to complete the jump

Nsurl *url = [Nsurl urlwithstring:@ "mj://ios.itcast.cn"];

[[UIApplication sharedapplication] openurl:url];

App ratings

To improve the user experience of your app, you often need to invite users to score apps

App scoring is all about jumping to AppStore to show your app and then writing a review by the user himself

How to jump to AppStore and show your app

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 messages and more

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.