本文介绍了使用私有框架以编程方式发送iMessage的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人知道是否可以使用私有框架直接发送iMessage吗?

Does anyone know if it's possible to directly send an iMessage using a private framework?

我尝试使用CoreTelephony中的CTMessageCenter,但是即使我的手机可以发送iMessage,它也会发送一条短信.

I tried using CTMessageCenter from CoreTelephony but it'll send an SMS even though my phone can send iMessages.

推荐答案

我还没有测试过,但是请看在此处发布的代码中.如果您查看httpResponseForMethod:URI:,则会看到他/她向何处发送消息(似乎是硬代码,以支持 iOS 5或iOS 4 ):

I haven't tested this, but look at the code posted here. If you look at httpResponseForMethod:URI:, you see where he/she sends a message (appears to be hardcode to support iOS 5 or iOS 4):

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);

}

该代码使用普通的SMS,但是您可以看到以下注释掉的代码:

The code uses normal SMS, but you can see the following commented out code:

//CKMadridService *madridService = [CKMadridService sharedMadridService];

马德里"服务可能是可以发送iMessage的服务. 在此处查看私有标头.

The "Madrid" service is probably what can send iMessages. See the private header here.

SMS和iMessage专用API都在 ChatKit.framework 中.

Both SMS and iMessage private APIs are in the ChatKit.framework.

这篇关于使用私有框架以编程方式发送iMessage的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-23 08:36