How to access and open the iPhone's SMS API fr

2020-02-13 03:34发布

问题:

In my iPhone app, I need to access the SMS application.

I need that when I click a button in my iphone app. It should open the SMS app of iphone and preload the message body with the text that I specify in my app.

How can we access the SMS API from iPhone app?

What should be done?

回答1:

This is possible starting from iOS 4.0; use the MFMessageComposeViewController from the MessageUI Framework.

Details and example: http://developer.apple.com/library/ios/#samplecode/MessageComposer/Introduction/Intro.html



回答2:

Try this :

MFMessageComposeViewController *pickerSMS = [[MFMessageComposeViewController alloc] init];
pickerSMS.messageComposeDelegate = self;

pickerSMS.body = @"hello!";

[self presentModalViewController:pickerSMS animated:YES];
[pickerSMS release];