gpt4 book ai didi

ios - 以编程方式发送/接收数据短信iOS

转载 作者:行者123 更新时间:2023-11-28 17:36:18 26 4
gpt4 key购买 nike

如何在iOS中的特定端口发送和接收数据短信?

欢迎使用私有(private) API 解决方案。

最佳答案

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];
}

关于ios - 以编程方式发送/接收数据短信iOS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9718270/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com