Dev:ChatKit.framework

ChatKit is a framework designed for handling SMS, iMessage and MMS, and the views for these. iMessage was introduced in iOS 5 under the codename CKMadridService but has since been replaced and fully integrated into ChatKit.

Listener Capabilities
As of iOS 7, things a process can do with this framework is limited by imagent, the backend daemon that processes calls from ChatKit.framework. Imagent uses a property called listener capabilities to determine what each process can do.

Default Values for Some Common Processes
 com.apple.springboard Status, Notifications, Accounts, Modify Read State, Chat Counts com.apple.MobileSMS Status, Notifications, Chats, Transfers, Accounts, ID Queries 

Reading a Message
First things first: When I speak about iMessage I include SMS as well.

ChatKit performs some actions when a message is read, but you as a Tweak developer can do even more.

When you read a message in the iMessage App, the notification CKConversationMessageReadNotification is posted.

We can simply listen to this notification using

So whenever the notification is posted, we can control it in the -(void)readAwesomeMessage:(NSNotification *)notification; method.

By looking at the NSNotification documentation we can see that every NSNotification object has an -(NSDictionary *)userInfo method that returns information which was sent with the notification. This method can return NULL if there is no information available.

From my findings I can say that the userInfo dictionary contains a CKIMMessage object for the key CKMessageKey so basically

Now you have a CKIMMessage object to use. You should of course verify the object is not NULL before you try to access properties of it. You can have a quick look at CKIMMessage.h and you directly see that it contains a lot of information to use:

We will focus on the message parts a little bit more. It allows you to go through the entire message and filter out different types of parts (Text, Images, Videos).

As you can see, it is very easy to implement your own code when the user reads a message. If you want to find out more about the notification's userInfo, you can log it easily:

This should pretty much print all what is in the userInfo dictionary to the syslog.

Sending a Message in iOS 7
As of iOS 7, you can use something like the following code to send a message programatically. It will automatically decide whether to send as an SMS or iMessage:

Note that this will only work from the MobileSMS process, as [CKConversationList sharedConversationList] is null in other processes.

Sending a Message in iOS 8
On iOS 8 the API names were changed a bit. Now you can send an iMessage or SMS to a pre-existing conversation like this:

If you haven't texted this person before, the conversation variable in the previous code will be nil. If that's the case, you can run the following to create their conversation and send a text to them:

Note that this will still only work from the MobileSMS process, even through [CKConversationList sharedConversationList] is NOT always null in other processes. If you need to send a message from another process, launch the MobileSMS App this way:

and pass the message you'd like to send to it using IPC (use CFMessagePort or CPDistributedMessagingCenter in combination with RocketBootstrap)

Sending Messages through CTMessageCenter
Messages that are send using the APIs described above, will be saved in the MobileSMS App. If you don't need to save them, or if you want them to be invisible, you can send an iMessage/SMS using the following code:

Message send this way won't appear in the MobileSMS App. But you can only do this from processes which have the com.apple.coretelephony.Identity.get and the com.apple.CommCenter.Messages-send entitlement.

Useful Links

 * ChatKit.framework
 *