Send sms using core telophony?

别说谁变了你拦得住时间么 提交于 2019-12-09 01:26:24

问题


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.


回答1:


try this code;

[[CTMessageCenter sharedMessageCenter] sendSMSWithText:@"Your Message here" 
                                  serviceCenter:nil 
                                      toAddress:@"Receiver's Phone Number here"];



回答2:


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.



来源:https://stackoverflow.com/questions/6281837/send-sms-using-core-telophony

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!