gpt4 book ai didi

ios - 在 iPhone 上发送短信

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

我一直致力于在我的应用中实现 SMS 消息传递。不幸的是,每当我测试它时,我总是得到默认结果,即使它确实发送了消息并且我在另一端收到了它。我做错了什么,我比较了其他例子,我的看起来一样。这适用于 iMessage 吗???现在我总是收到已发送的邮件,即使我发送短信时它会说失败。

// feedback message field with the result of the operation.
- (void)messageComposeViewController:(MFMessageComposeViewController *)controller
didFinishWithResult:(MessageComposeResult)result {

switch (result)
{
case MFMailComposeResultCancelled:

[self displayStickieUniversalViewControllerTitleString:@"Cancelled" bodyString:@"You cancelled sending the SMS.The event will be saved in the calendar." buttonString:@"Ok, Save Event" bodyTextSize:12.0f buttonTextLines:3];

break;
case MFMailComposeResultSent:

[self displayStickieUniversalViewControllerTitleString:@"SMS sent" bodyString:@"Your SMS was sent. The event will be saved in the calendar." buttonString:@"Ok, Save Event" bodyTextSize:12.0f buttonTextLines:3];

break;
case MFMailComposeResultFailed:
[self displayStickieUniversalViewControllerTitleString:@"Failed" bodyString:@"Failed to send SMS. The event will be saved in the calendar." buttonString:@"Ok, Save Event" bodyTextSize:12.0f buttonTextLines:3];

break;
default:
[self displayStickieUniversalViewControllerTitleString:@"Failed" bodyString:@"Failed to send SMS. The event will be saved in the calendar." buttonString:@"Ok, Save Event" bodyTextSize:12.0f buttonTextLines:3];
break;
}
[self dismissModalViewControllerAnimated:YES];
}

/////

 if (actionClicked == @"smsEvent") {
if ([attendeesArray count]!=0) {
NSLog(@"Yes clicked, will send sms confirmation");
Class messageClass = (NSClassFromString(@"MFMessageComposeViewController"));

if (messageClass != nil) {
if ([messageClass canSendText]) {
[self displaySMSComposerSheet];
}
else {

[self displayStickieUniversalViewControllerTitleString:@"Device not configured to send SMS." bodyString:@"The event will be saved in the calendar." buttonString:@"Save Event" bodyTextSize:14.0f buttonTextLines:2];

}
}
else {

[self displayStickieUniversalViewControllerTitleString:@"Device not configured to send SMS." bodyString:@"The event will be saved in the calendar." buttonString:@"Save Event" bodyTextSize:14.0f buttonTextLines:2];
}
}
}

最佳答案

看起来你使用了错误的枚举可能与我的枚举有关:

switch (result)
{
case MessageComposeResultCancelled:
break;
case MessageComposeResultSent:
break;
case MessageComposeResultFailed:
break;
default:
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"SMS" message:@"Sending Failed - Unknown Error :-("
delegate:self cancelButtonTitle:@"OK" otherButtonTitles: nil];
[alert show];
[alert release];
}

break;
}

关于ios - 在 iPhone 上发送短信,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7860542/

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