Open Message app (SMS app) with a button and a Text field/View (iPhone)
Would this be possible?
The app will have a button and a Text Field or a Text View.
The user types in the phone number in the Text Field or Text View. when the user is done the user presses the button which will open the Message or SMS app in the iPhone.
How would I do this? If possible please provide some code! :)
Thank you in advance!
iphone objective-c sms message
add a comment |
Would this be possible?
The app will have a button and a Text Field or a Text View.
The user types in the phone number in the Text Field or Text View. when the user is done the user presses the button which will open the Message or SMS app in the iPhone.
How would I do this? If possible please provide some code! :)
Thank you in advance!
iphone objective-c sms message
add a comment |
Would this be possible?
The app will have a button and a Text Field or a Text View.
The user types in the phone number in the Text Field or Text View. when the user is done the user presses the button which will open the Message or SMS app in the iPhone.
How would I do this? If possible please provide some code! :)
Thank you in advance!
iphone objective-c sms message
Would this be possible?
The app will have a button and a Text Field or a Text View.
The user types in the phone number in the Text Field or Text View. when the user is done the user presses the button which will open the Message or SMS app in the iPhone.
How would I do this? If possible please provide some code! :)
Thank you in advance!
iphone objective-c sms message
iphone objective-c sms message
asked Feb 1 '11 at 14:08
TapyTapy
66851328
66851328
add a comment |
add a comment |
3 Answers
3
active
oldest
votes
Take a look at the MessageComposer Sample App and the MFMessageComposeViewController Class.
You then do something like this, though you should first check whether the MFMessageComposeViewController
is actually available on your device (See the MessageComposer Sample):
MFMessageComposeViewController *picker = [[MFMessageComposeViewController alloc] init];
picker.messageComposeDelegate = self;
picker.recipients = [NSArray arrayWithObjects:@"1234", @"2345", nil];
picker.body = yourTextField.text
[self presentModalViewController:picker animated:YES];
[picker release];
You need to first import the MessageUI.framework
(see this answer).
Import it into your classes via #import <MessageUI/MessageUI.h>
and add <MFMessageComposeViewControllerDelegate>
in the .h file, e.g. like so:
#import <UIKit/UIKit.h>
#import <MessageUI/MessageUI.h>
@interface YourClass : UIViewController <MFMessageComposeViewControllerDelegate>
{
// ...
Thank you! I'll try that
– Tapy
Feb 1 '11 at 19:59
add a comment |
Another short way, may help anyone much better :)
NSString *sms = @"sms:+1234567890&body=This is sms body.";
NSString *url = [sms stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:url]];
add a comment |
In Swift 3.0
static func sendMessageToNumber(number:String,message:String){
let sms = "sms:(number)&body=(message)"
let url = URL(string:sms)!
let shared = UIApplication.shared
if(shared.canOpenURL(url)){
shared.openURL(url)
}else{
print("unable to send message")
}
}
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f4863535%2fopen-message-app-sms-app-with-a-button-and-a-text-field-view-iphone%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
Take a look at the MessageComposer Sample App and the MFMessageComposeViewController Class.
You then do something like this, though you should first check whether the MFMessageComposeViewController
is actually available on your device (See the MessageComposer Sample):
MFMessageComposeViewController *picker = [[MFMessageComposeViewController alloc] init];
picker.messageComposeDelegate = self;
picker.recipients = [NSArray arrayWithObjects:@"1234", @"2345", nil];
picker.body = yourTextField.text
[self presentModalViewController:picker animated:YES];
[picker release];
You need to first import the MessageUI.framework
(see this answer).
Import it into your classes via #import <MessageUI/MessageUI.h>
and add <MFMessageComposeViewControllerDelegate>
in the .h file, e.g. like so:
#import <UIKit/UIKit.h>
#import <MessageUI/MessageUI.h>
@interface YourClass : UIViewController <MFMessageComposeViewControllerDelegate>
{
// ...
Thank you! I'll try that
– Tapy
Feb 1 '11 at 19:59
add a comment |
Take a look at the MessageComposer Sample App and the MFMessageComposeViewController Class.
You then do something like this, though you should first check whether the MFMessageComposeViewController
is actually available on your device (See the MessageComposer Sample):
MFMessageComposeViewController *picker = [[MFMessageComposeViewController alloc] init];
picker.messageComposeDelegate = self;
picker.recipients = [NSArray arrayWithObjects:@"1234", @"2345", nil];
picker.body = yourTextField.text
[self presentModalViewController:picker animated:YES];
[picker release];
You need to first import the MessageUI.framework
(see this answer).
Import it into your classes via #import <MessageUI/MessageUI.h>
and add <MFMessageComposeViewControllerDelegate>
in the .h file, e.g. like so:
#import <UIKit/UIKit.h>
#import <MessageUI/MessageUI.h>
@interface YourClass : UIViewController <MFMessageComposeViewControllerDelegate>
{
// ...
Thank you! I'll try that
– Tapy
Feb 1 '11 at 19:59
add a comment |
Take a look at the MessageComposer Sample App and the MFMessageComposeViewController Class.
You then do something like this, though you should first check whether the MFMessageComposeViewController
is actually available on your device (See the MessageComposer Sample):
MFMessageComposeViewController *picker = [[MFMessageComposeViewController alloc] init];
picker.messageComposeDelegate = self;
picker.recipients = [NSArray arrayWithObjects:@"1234", @"2345", nil];
picker.body = yourTextField.text
[self presentModalViewController:picker animated:YES];
[picker release];
You need to first import the MessageUI.framework
(see this answer).
Import it into your classes via #import <MessageUI/MessageUI.h>
and add <MFMessageComposeViewControllerDelegate>
in the .h file, e.g. like so:
#import <UIKit/UIKit.h>
#import <MessageUI/MessageUI.h>
@interface YourClass : UIViewController <MFMessageComposeViewControllerDelegate>
{
// ...
Take a look at the MessageComposer Sample App and the MFMessageComposeViewController Class.
You then do something like this, though you should first check whether the MFMessageComposeViewController
is actually available on your device (See the MessageComposer Sample):
MFMessageComposeViewController *picker = [[MFMessageComposeViewController alloc] init];
picker.messageComposeDelegate = self;
picker.recipients = [NSArray arrayWithObjects:@"1234", @"2345", nil];
picker.body = yourTextField.text
[self presentModalViewController:picker animated:YES];
[picker release];
You need to first import the MessageUI.framework
(see this answer).
Import it into your classes via #import <MessageUI/MessageUI.h>
and add <MFMessageComposeViewControllerDelegate>
in the .h file, e.g. like so:
#import <UIKit/UIKit.h>
#import <MessageUI/MessageUI.h>
@interface YourClass : UIViewController <MFMessageComposeViewControllerDelegate>
{
// ...
edited May 23 '17 at 12:13
Community♦
11
11
answered Feb 1 '11 at 14:18
fabian789fabian789
5,73843683
5,73843683
Thank you! I'll try that
– Tapy
Feb 1 '11 at 19:59
add a comment |
Thank you! I'll try that
– Tapy
Feb 1 '11 at 19:59
Thank you! I'll try that
– Tapy
Feb 1 '11 at 19:59
Thank you! I'll try that
– Tapy
Feb 1 '11 at 19:59
add a comment |
Another short way, may help anyone much better :)
NSString *sms = @"sms:+1234567890&body=This is sms body.";
NSString *url = [sms stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:url]];
add a comment |
Another short way, may help anyone much better :)
NSString *sms = @"sms:+1234567890&body=This is sms body.";
NSString *url = [sms stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:url]];
add a comment |
Another short way, may help anyone much better :)
NSString *sms = @"sms:+1234567890&body=This is sms body.";
NSString *url = [sms stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:url]];
Another short way, may help anyone much better :)
NSString *sms = @"sms:+1234567890&body=This is sms body.";
NSString *url = [sms stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:url]];
edited Jun 8 '16 at 6:30
answered Jun 8 '16 at 6:25
Mohd AsimMohd Asim
7811012
7811012
add a comment |
add a comment |
In Swift 3.0
static func sendMessageToNumber(number:String,message:String){
let sms = "sms:(number)&body=(message)"
let url = URL(string:sms)!
let shared = UIApplication.shared
if(shared.canOpenURL(url)){
shared.openURL(url)
}else{
print("unable to send message")
}
}
add a comment |
In Swift 3.0
static func sendMessageToNumber(number:String,message:String){
let sms = "sms:(number)&body=(message)"
let url = URL(string:sms)!
let shared = UIApplication.shared
if(shared.canOpenURL(url)){
shared.openURL(url)
}else{
print("unable to send message")
}
}
add a comment |
In Swift 3.0
static func sendMessageToNumber(number:String,message:String){
let sms = "sms:(number)&body=(message)"
let url = URL(string:sms)!
let shared = UIApplication.shared
if(shared.canOpenURL(url)){
shared.openURL(url)
}else{
print("unable to send message")
}
}
In Swift 3.0
static func sendMessageToNumber(number:String,message:String){
let sms = "sms:(number)&body=(message)"
let url = URL(string:sms)!
let shared = UIApplication.shared
if(shared.canOpenURL(url)){
shared.openURL(url)
}else{
print("unable to send message")
}
}
answered Jul 26 '17 at 12:26
Rohit PathakRohit Pathak
319416
319416
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f4863535%2fopen-message-app-sms-app-with-a-button-and-a-text-field-view-iphone%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown