отправлять / получать данные смс iOS программно - PullRequest
1 голос
/ 15 марта 2012

Как отправлять и получать данные SMS на определенный порт в iOS?

Приветствуются частные API-решения.

1 Ответ

0 голосов
/ 30 апреля 2013
import 
#import <MessageUI/MessageUI.h>


<MFMessageComposeViewControllerDelegate,MFMailComposeViewControllerDelegate>



    -(void)send_SMS{

      Class messageClass = (NSClassFromString(@"MFMessageComposeViewController"));

            if (messageClass != nil) {
                // Check whether the current device is configured for sending SMS messages
                if ([messageClass canSendText]) {
                    [self displaySMSComposerSheet];
                }
                else {
                  //  feedbackMsg.hidden = NO;
                  //  feedbackMsg.text = @"Device not configured to send SMS.";
                    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:nil message:@"Device not configured to send SMS." delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"Call",nil];
                    //[alert setTag:5];
                    [alert show];
                }
            }
            else {
               // feedbackMsg.hidden = NO;
               // feedbackMsg.text = @"Device not configured to send SMS.";
                UIAlertView *alert = [[UIAlertView alloc] initWithTitle:nil message:@"Device not configured to send SMS." delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"Call",nil];
                //[alert setTag:5];
                [alert show];

            }


    }




// Displays an SMS composition interface inside the application.
-(void)displaySMSComposerSheet
{
    MFMessageComposeViewController *picker = [[MFMessageComposeViewController alloc] init];
    picker.messageComposeDelegate = self;
    picker.body=@"Testing";
    picker.recipients = [NSArray arrayWithObject:@"12345678"];
    [self presentModalViewController:picker animated:YES];
    }



// Dismisses the message composition interface when users tap Cancel or Send. Proceeds to update the
// feedback message field with the result of the operation.
- (void)messageComposeViewController:(MFMessageComposeViewController *)controller
                 didFinishWithResult:(MessageComposeResult)result {

    feedbackMsg.hidden = NO;
    // Notifies users about errors associated with the interface
    switch (result)
    {
        case MessageComposeResultCancelled:{
            //feedbackMsg.text = @"Result: SMS sending canceled";
            UIAlertView *alert = [[UIAlertView alloc] initWithTitle:nil message:@"SMS sending canceled" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
            [alert show];
        }
            break;
        case MessageComposeResultSent:{
            //feedbackMsg.text = @"Result: SMS sent";
            UIAlertView *alert = [[UIAlertView alloc] initWithTitle:nil message:@"SMS sent" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
            [alert show];
        }
            break;
        case MessageComposeResultFailed:{
            //feedbackMsg.text = @"Result: SMS sending failed";
            UIAlertView *alert = [[UIAlertView alloc] initWithTitle:nil message:@"SMS sending failed" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
            [alert show];
        }
            break;
        default:
        {
            //feedbackMsg.text = @"Result: SMS not sent";
            UIAlertView *alert = [[UIAlertView alloc] initWithTitle:nil message:@"SMS not sent" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
            [alert show];
        }
            break;
    }
    [self dismissModalViewControllerAnimated:YES];
}
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...