Send sms using core telophony?
I want to develop an application like biteSMS (for jailbroken iPhone). I have tried to compile an开发者_运维知识库 open source application iPhone-Delivery-Report but unable to compile it. Does some one knows anything related to core-telephony sms sending for jailbroken iPhone? A sample code would be very helpful.
UPDATE
Thanks to joshua Son for the great help.
Here is the screenshot of the warnings.
try this code;
[[CTMessageCenter sharedMessageCenter] sendSMSWithText:@"Your Message here"
serviceCenter:nil
toAddress:@"Receiver's Phone Number here"];
I'm not saying the CTMessageCenter
implementation doesn't work, but this is another option, taken from the code found here:
CKSMSService *smsService = [CKSMSService sharedSMSService];
//id ct = CTTelephonyCenterGetDefault();
CKConversationList *conversationList = nil;
NSString *value =[[UIDevice currentDevice] systemVersion];
if([value hasPrefix:@"5"])
{
//CKMadridService *madridService = [CKMadridService sharedMadridService];
//NSString *foo = [madridService _temporaryFileURLforGUID:@"A5F70DCD-F145-4D02-B308-B7EA6C248BB2"];
NSLog(@"Sending SMS");
conversationList = [CKConversationList sharedConversationList];
CKSMSEntity *ckEntity = [smsService copyEntityForAddressString:Phone];
CKConversation *conversation = [conversationList conversationForRecipients:[NSArray arrayWithObject:ckEntity] create:TRUE service:smsService];
NSString *groupID = [conversation groupID];
CKSMSMessage *ckMsg = [smsService _newSMSMessageWithText:msg forConversation:conversation];
[smsService sendMessage:ckMsg];
[ckMsg release];
} else {
//4.0
id ct = CTTelephonyCenterGetDefault();
void* address = CKSMSAddressCreateWithString(pid);
int group = [grp intValue];
if (group <= 0) {
group = CKSMSRecordCreateGroupWithMembers([NSArray arrayWithObject:address]);
}
void *msg_to_send = _CKSMSRecordCreateWithGroupAndAssociation(NULL, address, msg, group, 0);
CKSMSRecordSend(ct, msg_to_send);
}
In order to use the CKSMSService
class, link against the private ChatKit.framework in your project, and #import
the CKSMSService.h header. The compiler might tell you that you need some other headers from ChatKit, which you can find in the same place (as my link). Just copy those header files into the source directory for your application and
#import "CKSMSService.h"
before using them.
精彩评论