2

现在我的应用程序正在发送我想要的消息,但它一直在发送多媒体消息而不是常规短信。我想知道它为什么这样做。下面是我发送消息的代码。

-(void)sendSMS:(NSString *)bodyOfMessage recipientList:(NSMutableArray *)recipients{
MFMessageComposeViewController *controller = [[[MFMessageComposeViewController alloc]init]autorelease];
if([MFMessageComposeViewController canSendText]){
    controller.body = bodyOfMessage;
    controller.recipients = recipients;
    controller.messageComposeDelegate = self;
    [self presentModalViewController:controller animated:YES];
}
}

-(void)textMessage{
NSLog(@"%@", savedPeople);
ABAddressBookRef addressBook = ABAddressBookCreate();
NSMutableArray *phoneNumberToText = [[NSMutableArray alloc]init];
for(NSString *name in savedPeople){
    if(savedPeople != nil){
        NSArray *people = (NSArray *)ABAddressBookCopyPeopleWithName(addressBook, CFStringCreateCopy(kCFAllocatorDefault, (CFStringRef)name));
        for(int i =0;i<[people count];i++){
            ABMultiValueRef person = (ABMultiValueRef)[people objectAtIndex:i];
            ABMultiValueRef phoneNumber = (NSString *)ABRecordCopyValue(person, kABPersonPhoneProperty);
            CFStringRef phoneNumberRef = ABMultiValueCopyValueAtIndex(phoneNumber, i);
            NSString *phoneNumbers = (NSString *)phoneNumberRef;
            [phoneNumberToText addObject:phoneNumbers];
        }
    }

}
NSLog(@"%@",phoneNumberToText);
[self sendSMS:@"Testing" recipientList:phoneNumberToText];


}

-(void)messageComposeViewController:(MFMessageComposeViewController *)controller didFinishWithResult:(MessageComposeResult)result{
[self dismissModalViewControllerAnimated:YES];
if(result == MessageComposeResultCancelled)
    NSLog(@"Message Canceled");
else if(result == MessageComposeResultSent)
    NSLog(@"message sent");
else
    NSLog(@"message failed");
}
4

0 回答 0