Advertisement
Guest User

Untitled

a guest
Jul 26th, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. MFMessageComposeViewController *picker = [[MFMessageComposeViewController alloc] init];
  2. picker.messageComposeDelegate = self;
  3. picker.recipients = [NSArray arrayWithObjects:@"1234", @"2345", nil];
  4. picker.body = yourTextField.text
  5.  
  6. [self presentModalViewController:picker animated:YES];
  7. [picker release];
  8.  
  9. #import <UIKit/UIKit.h>
  10. #import <MessageUI/MessageUI.h>
  11.  
  12. @interface YourClass : UIViewController <MFMessageComposeViewControllerDelegate>
  13. {
  14. // ...
  15.  
  16. NSString *sms = @"sms:+1234567890&body=This is sms body.";
  17. NSString *url = [sms stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
  18. [[UIApplication sharedApplication] openURL:[NSURL URLWithString:url]];
  19.  
  20. static func sendMessageToNumber(number:String,message:String){
  21.  
  22. let sms = "sms:(number)&body=(message)"
  23. let url = URL(string:sms)!
  24. let shared = UIApplication.shared
  25.  
  26. if(shared.canOpenURL(url)){
  27. shared.openURL(url)
  28. }else{
  29. print("unable to send message")
  30. }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement