Hey wonderful guest! Please take a minute and register for an account here at codeleakers.com. It takes less than a minute and you will feel better about yourself and life in general. If you do not wish to register, you are still free to browse the site. Thanks!

Theos Tutorial: "MarkThatMessage."

This Theos tutorial will be based around the popular Cydia tweak, MarkThatMessage. This tweak is very largely downloaded and is a popular tweak, yet it's one of the simplest ones to code. The tweak modifies the Messages.app so that instead of displaying a timestamp only every few messages, it displays one for every message. Great idea, right? Let's get started writing it.

So, to write a tweak, first you need an idea. In this tutorial we have ours, the tweak that's already been made. Next, we need to decide which set of frameworks we'll need to search in to modify the method. The frameworks set, ChatKit, deals with SMS and iMessage (as well as some of the Mail.app functions, etc), so we'll start there. Next we need to find the method we want to modify. There are hundreds of files inside each folder, so for time's sake you can try searching for keywords within every file in the folder to find what you want. For example, searching for "timestamp" in the ChatKit folder reduces the number of files to search through from hundreds to just three.

In iOS, the information appended to SMS messages and iMessage messages is called bubble data, so we'll start by searching through the CKTranscriptBubbleData.h file. Since we're modifying a simple yes/no (also known as a (BOOL in Objective C), it will reduce our search time even more to press CTRL + F and type in what data type we're looking for, a BOOL. Or, you could type CTRL + F, "timestamp." With just a little bit of searching, you should be able to locate the method that sounds close to what we're looking for.

The method is "(BOOL)shouldShowTimestampForDate". Now that we've found it, we can modify it using Theos.

Open a new terminal window, export THEOS as /opt/theos as shown in the previous tutorial, then type THEOS/bin/nic.pl. This will start the Theos Template maker. Next choose what we're making, a tweak (five) and name it and add your own name and such. Now we're ready to begin coding this (very) simple tweak. Open your tweak.xm file and type in the following code:

So what does that mean? First we imported the class file we're using, CKTranscriptBubbleData.h. Then we used "%hook CKTranscriptBubbleData" to tell Theos which class we want it to hook into. Next we define what we're working with, a boolean value with an id (basically a placeholder for data) of date. We then tell Theos we want it to always return YES, overriding anything iOS will do. We finish by using "%end" to tell Theos that we're done hooking into this class. And that's it. Open your terminal, type "make package install" and the tweak will be built, packaged into a .deb, and installed on your iDevice. After it reboots, you should go into the Messages.app, and you'll realize that every message now has a timestamp accompanying it.