IOS call system texting and calling function
http://blog.csdn.net/lwq421336220/article/details/7818979
Let's start by introducing one of the simplest methods:
Call Call function
[[uiapplicationsharedapplication] Openurl:[nsurl urlwithstring:@ "tel://10086"];
Call to send SMS function
[[UIApplication sharedapplication]openurl:[nsurl urlwithstring:@ "sms://10000"];
The above text messaging function is to call the system interface, the following is a click to implement a button to send text messages directly, equivalent to send the background, can be on the software store, not sure. Relative recommendations, try to use the first one.
First import mfmessagecomposeviewcontrollerdelegate This agent, implement the method inside
-(void) Messagecomposeviewcontroller: (Mfmessagecomposeviewcontroller *) Controllerdidfinishwithresult: ( Messagecomposeresult) Result {
Notifies users about errors associated with the interface
Switch (Result) {
Case messagecomposeresultcancelled:
if (DEBUG) NSLog (@ "result:canceled");
Break
Case Messagecomposeresultsent:
if (DEBUG) NSLog (@ "result:sent");
Break
Case messagecomposeresultfailed:
if (DEBUG) NSLog (@ "result:failed");
Break
Default
Break
}
[Self dismissmodalviewcontrolleranimated:yes];
}
Mass SMS:
-(ibaction) sendsms {
BOOL cansendsms = [Mfmessagecomposeviewcontroller cansendtext];
NSLog (@ "Can send SMS [%d]", cansendsms);
if (cansendsms) {
Mfmessagecomposeviewcontroller *picker = [[Mfmessagecomposeviewcontroller alloc] init];
Picker.messagecomposedelegate = self;
Picker.navigationBar.tintColor = [Uicolor blackcolor];
Picker.body = @ "Test";
picker.recipients = [Nsarray arraywithobject:@ "10086"];
[Self presentmodalviewcontroller:picker animated:yes];
[Picker release];
}
}
Send a text message to a person:
Get content from a Web page
-(void) Displaysmscomposersheet
{
Mfmessagecomposeviewcontroller *picker = [[Mfmessagecomposeviewcontroller alloc] init];
Picker.messagecomposedelegate = self;
UIWebView *web = nil;
nsmutablestring* Absurl = [[Nsmutablestring alloc] initWithString:web.request.URL.absoluteString];
[Absurl replaceoccurrencesofstring:@ "http://i.aizheke.com" withstring:@ "http://m.aizheke.com" options: Nscaseinsensitivesearch range:nsmakerange (0, [absurl length])];
Picker.body=[nsstring stringwithformat:@ "I see in the Love Fold guest:%@ may be useful to you, recommend to you!" link:%@ ", [webstringbyevaluatingjavascriptfromstring:@" Document.title "],absurl];
[Absurl release];
[Self presentmodalviewcontroller:picker animated:yes];
[Picker release];
}
Event binding Send SMS
-(Ibaction) Showsmspicker: (ID) Sender {
Class MessageClass = (nsclassfromstring (@ "Mfmessagecomposeviewcontroller"));
if (MessageClass! = nil) {
if ([MessageClass Cansendtext]) {
[Self displaysmscomposersheet];
}
else {
Device does not have SMS function
}
}
else {
iOS version is too low for iOS4.0 to send SMS within the program
}
}
the above content is a part of the various sites, I add their own understanding, collation, as for the Internet from the part of the author is who, from where, I do not know now, write out for everyone to learn. If you are the author of that part, please contact me!