1. Call to bring your own mail
[[UIApplication sharedapplication] Openurl:[nsurl urlwithstring:@ "Mailto://[email protected]"];
2. Call Telephone Phone
[[UIApplication sharedapplication] openurl:[nsurl urlwithstring:@ "tel://8008808888"];
3. Call SMS
[[UIApplication sharedapplication] openurl:[nsurl urlwithstring:@ "sms://800888"];
4. Call your own browser safari
[[UIApplication sharedapplication] openurl:[nsurl urlwithstring:@ "http://www.hzlzh.com"];
Call phone can pass number, call SMS can only set number, cannot initialize SMS content.
If you need to pass content, you can do the following:
Join: Messageui.framework
#import <MessageUI/MFMessageComposeViewController.h>
Implement Proxy: Mfmessagecomposeviewcontrollerdelegate
Call the Sendsms function
Content, recipient list
-(void) sendsms: (nsstring *) bodyofmessage recipientlist: (Nsarray *) recipients
{
Mfmessagecomposeviewcontroller *controller = [[[[Mfmessagecomposeviewcontroller alloc] init] autorelease];
if([Mfmessagecomposeviewcontroller cansendtext])
{
Controller. BODY = bodyofmessage;
Controller. recipients = recipients;
Controller. messagecomposedelegate = self ;
[self presentmodalviewcontroller: Controller animated:YES];
}
}
//Processing of response results sent out
-(void) Messagecomposeviewcontroller: (Mfmessagecomposeviewcontroller *) controller didfinishwithresult: ( Messagecomposeresult) Result
{
[self dismissmodalviewcontrolleranimated:yes];
if (result = = messagecomposeresultcancelled)
NSLog (@ "Message cancelled")
else if (result = = Messagecomposeresultsent)
NSLog (@ "Message sent")
Else
NSLog (@ "Message failed")
}
The message is sent as:
Import #import <MessageUI/MFMailComposeViewController.h>
Implement Proxy: Mfmailcomposeviewcontrollerdelegate
Send mail
-(void) SendMail: (nsstring *) Subject content: (nsstring *) content{
Mfmailcomposeviewcontroller *controller = [[[[Mfmailcomposeviewcontroller alloc] init] autorelease];
if([Mfmailcomposeviewcontroller cansendmail])
{
[Controller Setsubject:subject];
[Controller setmessagebody:content ishtml:NO];
Controller. mailcomposedelegate = self ;
[self presentmodalviewcontroller: Controller animated:YES];
}
}
Message completion Processing
-(void) Mailcomposecontroller: (Mfmailcomposeviewcontroller *) controller didfinishwithresult: ( Mfmailcomposeresult) Result error: (nserror *) error{
[self dismissmodalviewcontrolleranimated:YES];
if (result = = messagecomposeresultcancelled)
NSLog(@ "Message cancelled");
Else if (result = = Messagecomposeresultsent)
NSLog(@ "Message sent");
Else
NSLog(@ "Message failed");
}
IOS development, call calling, texting, opening URLs