6

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

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

Cœur
  • 37,241
  • 25
  • 195
  • 267
Alexandre Blin
  • 270
  • 6
  • 13

2 Answers2

2

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

}

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

//CKMadridService *madridService = [CKMadridService sharedMadridService];

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

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

Nate
  • 31,017
  • 13
  • 83
  • 207
  • @Enkidu, if you look at the questions tags, you'll see that it's a jailbreak question. – Nate Sep 29 '16 at 10:32
  • i am not asking I am informing. I added the jailbreak tag :) – iosMentalist Sep 29 '16 at 10:53
  • @Enkidu, actually, my first response was incorrect. It's fine if you're identifying that this answer requires jailbreaking to work (I can't test anymore, because the APIs changed long ago). But, the tags applied to a question should reflect what the questioner is asking; they should not be a reflection of the answers. So, I'll leave your comment here as is (though I can't verify its correctness), but the jailbreak tag should not be applied to the question, as it wasn't part of what the asker asked. – Nate Sep 30 '16 at 13:54
-5

Through a non jailbreak iPhone there is absolutely no access to the iMessage CoreTelephony API

Matt Aldridge
  • 2,037
  • 16
  • 21