SMS, phone calls, emails inside the app

Source: Internet
Author: User

SMS, phone calls, emails inside the app

In the app development, many times need in the app to implement SMS verification, sharing, and switching calls and other functions, which will be called to the system relative to the functional system;

There are generally two modes in IOS development:

1) in the app to implement SMS and telephone dialing function, will stay in the SMS and phone interface after completion

2) in the app to achieve text messaging and telephone calls, after completion can jump to the original app interface, to do the next step.

First, send a text message

1) Direct dialing, will stay in the call log when the dial is completed

Method:

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

Advantages: Simple

Disadvantage: Cannot specify SMS content, and can not jump back to the original app interface

2) Use Mfmessagecomposeviewcontroller---------(import messageui frame)

Method: ( need to follow SMS Agent----------mfmessagecomposeviewcontrollerdelegate)

            //Invite Phone Contact person//determine if the device can send text messages            if(![Mfmessagecomposeviewcontroller Cansendtext]) {                return; }            //initializing the SMS controllerMfmessagecomposeviewcontroller *MESSAGEVC =[[Mfmessagecomposeviewcontroller alloc]init]; //Set Delegate ObjectMessagevc.messagecomposedelegate =Self ; NSString*text = [NSString stringWithFormat:@"[%@] invite you to register IBOs cool office join "%@", click Join http://www.ibos.cn/?corp=%@", Getmyinfo (). Realname, Getmyinfo (). Corpname, Getmyinfo (). Corpcode]; //SMS ContentMessagevc.body = text;//(Note: If the text message contains a post-URL, can be automatically identified, can still send text messages, the recipient can click the trigger link to achieve jump)             //set the recipient (can not be set, the SMS interface can jump to the system Address Book, choose the person by themselves)Controller.recipients = [@"10010",@"10086"]; //Display SMS Controller[Self PRESENTVIEWCONTROLLER:MESSAGEVC animated:yes completion:nil];

After the message is sent, call the proxy method to close the SMS interface

:

- (void) Messagecomposeviewcontroller: (Mfmessagecomposeviewcontroller *Controller Didfinishwithresult: (messagecomposeresult) Result {Switch(Result) { CaseMessagecomposeresultcancelled://Cancel        {             Break; }         CaseMessagecomposeresultsent://Send        {             Break; }         CaseMessagecomposeresultfailed://failed{Uialertview*ALERTV = [[Uialertview alloc]initwithtitle:@"Tips"Message@"Send SMS Error, please resend! " Delegate: Self Cancelbuttontitle:nil otherbuttontitles:@"Determine", nil];            [Alertv show];  Break; }        default:             Break; }       //Close the SMS interface[Controller Dismissviewcontrolleranimated:yes Completion:nil];}

Second, call

SMS, phone calls, emails inside the app

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.