Log Actions With Just Two Taps on Your iPhone

Allergy season has just started for me, and I’ve resumed taking Claritin. I don’t have the best memory, so I am logging the date and time each instance in which I take a pill. Fortunately, with the help of four apps 1 I can literally just tap twice on my iPhone to add the time to a text file. This solution does take a few minutes to set up, but afterwards you won’t even have to open up the keyboard. This can work for any activity in which you need to log your time — not just for taking meds.

Requirements:

In this tutorial you will set up Launch Center Pro (henceforth LCP) with a Custom URL that expands a TextExpander snippet to Drafts, triggering a Dropbox (or Evernote) action to prepend a date/time configuration to a specific file or note. After setup, you will be able to open LCP, tap on an action, and immediately have text like “04/29/2013 1:06pm” added to the top of a note titled something like “TookLoratadine” (Loratadine being the generic version of Claritin). Much of the following is customizable: the date/time format, your cloud service, and the name of the file.

Step 1: Create a TextExpander Snippet

TextExpander (TE) is a service that enables you to type out a short snippet that expands automatically into a longer sequence of text — provided you are using an iOS app that supports TE. TE supports date/time snippets that allow you to customize how a date/time is written out. View their reference page. If I create a snippet called Tdate whose content is %Y-%m-%d %1I:%M %p and type out Tdate in a TE-supported app, it will expand into 2013-04-29 1:20 PM. If instead I want the date formatted like 4/29/13, I can make the content %1M/%e/%y. To set this up in TE, go to Groups, select or create a group, enter the snippet in the Abbreviation field and the date math in the Content field.

Step 2: Create a Dropbox or Evernote Action in Drafts

Drafts has long supported Dropbox actions in which you can create a note or prepend or append text to a note. Since its 3.0 update, Drafts also support Evernote actions in which you can do the same. For the purposes of this example I am using a Dropbox action in which I prepend to a note.

Dropbox action

I’ve named this action “prepend Trunk Note” because I am entering this note into my personal wiki. (Learn more about Trunk Notes.) The Dropbox path for notes in this app is /trunksync/notes/. (If you use nvAlt, just use its Dropbox path.) For the filename I have chose predefined and I am titling it [[title]] which is drawn from the first line of the entry in Drafts. For extension I have entered markdown but you can also enter txt for a regular text file. For Write, I have chosen prepend so that newer dates show up at the beginning of the note. And in the template I have entered [[body]] which is drawn from any text after the first line in Drafts. If you’re on your iPhone right now, tap on this link to import the Dropbox action into your version of Drafts. You can then edit the action as you like.

When you create an append or prepend action, Drafts creates the file the first time you run it, and thereafter it adds text to it. In my Dropbox action above, as long as the first line of my draft is always the same, whatever is in the rest of the draft will just be added to that note. In the next step, I will be creating an URL in LCP in which the first line of the draft is always TookLoratadine. That will become the title of the note in which I will be prepending the date and time that I take my next dose.

Step 3: Create a Custom URL in Launch Center Pro

Launch LCP. Go to Action Composer and create a Custom URL.

drafts://x-callback-url/create?text=TookLoratadine%0A<Tdate>&action=prepend%20Trunk%20Note

 

Custom URL in LCP

I’ve titled mine Loratadine. This action does the following:

  1. Adds the text TookLoratadine to the first line of a draft in Drafts.
  2. Using an URL-encoded line break (%0A), it expands the TE snippet Tdate (which must be within the < > brackets) and puts the date/time on the next line.
  3. It then tells Drafts to perform the action prepend Trunk Note. It includes URL-encoded spaces (%20) between each word in the action.

If you want to customize this Custom URL, enter the following into LCP and swap in the FIRSTLINE, SNIPPET and DROPBOXACTION.

drafts://x-callback-url/create?text=FIRSTLINE%0A<SNIPPET>&action=DROPBOXACTION

 
Everything else should stay the same if you want this to work. Just make sure that the action is the URL-encoded title of the Dropbox or Evernote action that you have created.

You’re All Done

Next time you need to log the time and date you’ve completed a repeating task, just open LCP, tap on your action, and you’re done.

When I do it, something like the following will shortly show up in Drafts before the action is performed. (I set this Dropbox action to delete the draft after it is completed).

Took Loratadine
2013-04-29 1:20 PM 

 
If I want to view my log, I can either open Trunk Notes and open the TookLoratadine note, or use an URL scheme for a Dropbox text editor, like Nebulous Notes:

nebulous://trunksync/notes/TookLoratadine.markdown

 
Hint: if you enter this as an URL action in LCP, then you can also do two taps to view your log.


  1. See the comments for a solution that removes the need for TextExpander. 

Comments

  1. Why do you use TextExpander in this context? Only to generate the timestamp below the text?

    You can integrate this in the Drafts action. Just add a linebreak and “[[date|%Y-%m-%d %1I:%M %p]] in the template. You eliminate one level of complexity and a source of error.

    Keep it simple and smart.

    It’s the way I solved a similar task.

    • Jeffrey Kishner says:

      Thomas, you are absolutely correct. I tried your solution by removing %0A<TDate> from the Launch Center Pro custom URL and, in the Drafts template, replacing [[body]] with “[[date|%Y-%m-%d %l:%M %p]]. Note that I had to change 1I to l (lower-case L) because strftime is slightly different than the TextExpander math.

      That’s one less app I have to use!

Leave a Reply to Jeffrey Kishner Cancel reply

*