Ben Dodson

Freelance iOS, Apple Watch, and Apple TV Developer

Sporta 2.0

I’m pleased to announce the release of a new client app I worked on late last year: Sporta.

Sporta is an app to keep football fans up to date with the latest matches via local notifications in advance of a game. You simply select which teams you are interested in from the Premier League, Sky Bet Championship, The FA Cup, the Scottish Premiership, or international matches featuring England, Scotland, Wales, or Ireland. You can then choose a reminder time prior to the match (from 5 minutes up to 1 week) and the app will automatically send you a local notification to remind you about the match with details of kick off time, the teams involved, and the venue.

I was originally contacted by the creator to update the existing version of Sporta but I found that the code wasn’t suitable for me to work with due to a combination of out-dated code and offshore developers with poor documentation. Instead, I proposed that re-building the app from scratch with Swift 3 and modern iOS updates (such as AutoLayout to work on all sizes of iPhone and the new permissions systems for notifications introduced in iOS 10) would actually be faster than trying to untangle what was there. I was quickly able to recreate the app and scale it for different iPhone sizes whilst adding an intelligent system for keeping the app constantly up to date; the API for the match updates is called periodically using a combination of Background App Refresh and silent push notifications to ensure that data is always up to date and notifications will always fire at the right time even if the phone happens to be offline1. Finally, I used the Realm mobile database in order to store the match data and be able to quickly execute queries such as “fetch all fixtures that contain teams x, y, and z as either the home or away team”.

This was a really fun project to work on and I’m particularly pleased with how reliable the notifications are. If you are a football fan, you can download Sporta on the App Store.

  1. The naïve way of doing this would have been to use standard push notifications from a server at the appropriate times but these are not guaranteed to be delivered quickly or at all. Also, you’d need to send data from the phone if you changed your team selection or notification period whereas with the local database system I created you can do that entirely offline and it’ll just work (as I store all upcoming fixtures locally on the device). ↩︎

Booktrim for iPhone

I’m very pleased to announce the launch of a recent client app I developed; Booktrim.

Booktrim is a hassle-free app that allows customers to quickly browse barbershops, book a haircut, and pay right from their iPhone. I built the app in Swift and made use of AutoLayout to ensure that everything scales beautifully across the various iPhone Sizes and I worked closely with Trim Ventures’ API developer in order to ensure best practices. I was also instrumental in the design of the application and making sure that the user experience was optimised for making quick appointments on the go.

Once the app was completed, I was asked to build TRIMbook, an app for barbers which allows them to manage their appointments and availability. Once again, the app was built with Swift and I was key in both designing the UI and ensuring the API was being used efficiently. I worked closely with the Trim Ventures team to publish both apps on the App Store and also to run wider beta tests via TestFlight prior to launch.

This was an interesting project to work on and I think the end product works well. You can download Booktrim from the App Store or learn more on their website.

Don't be the idea person

I’ve been a fan of Dilbert since the mid-‘90s1 and this week a lot of my friends (and some clients) sent me this strip from November 13th:

Like most things, it’s funny because it’s true. I get several of these types of pitches per week and they never fail to amuse me. I’ve written about this in detail previously but I still get people who believe they have the next big idea and that it is worth something.

Ideas are worth nothing. Absolutely nothing. It is implementation that is worth something.

The analogy that I always like to use is that of an architect and a builder. Most software developers are builders that take some detailed plans and create to that specification. The “idea person” should be an architect with a clear vision and enough knowledge to know what can and can’t be done. Unfortunately this is rarely the case. Your typical “build my app idea” guy will have no knowledge of what can and can’t be done and therefore no understanding of the time and complexity there is in turning it into a reality. They just assume that they were the first person to think of a life changing idea and that it will be easy money for whoever builds it. It would be like delivering your kids drawing of a house to a builder and expecting them to have it built, for free, by next week2.

If you want to be taken seriously, do your research. Speak to developers and find out what is and what isn’t possible as the vast number of ideas I receive just aren’t possible given the constraints of software on iOS3. Then, once you’ve understood the process, either pay a developer for a basic MVP4 or pitch to investors to get enough funding to build one.

Don’t ever be “the idea person” and don’t ever expect other people to work for you for free. The world does not work that way.

  1. I have around 14 compendium books of the strips; my favourite is entitled “Still Pumped From Using The Mouse” (a reference to a calendar they were making about software developers). ↩︎

  2. “Oh, and by the way, there is a pool at the back and another floor but I didn’t draw that part” ↩︎

  3. “Can you give me the details for Apple then as this should really be installed by default on every phone - it’s a billion dollar idea”. Genuine email I received when I pointed out an idea wasn’t possible. ↩︎

  4. “Minimum Viable Product”, basically a step above a prototype that you can use to gauge interest from consumers and investors. The bare minimum you need to launch. ↩︎

Updates to iTunes Artwork Finder

Last week, my iTunes Artwork Finder script stopped working due to some changes by Apple with regards to rate limiting. In the past, searching for something on my site would cause my server to send a request to Apple and get the data back but with so many people using it my server would get blocked within a few seconds.

After a brief shutdown1, I’m happy to say that my iTunes Artwork Finder is now back up and running again thanks to a few tweaks. Now, instead of sending all requests from my server, it works like this:

  1. When you enter a search term (i.e. “Fall out boy” albums in United Kingdom), that is sent to my server where I’ll generate the correct URL that is needed for Apple’s servers
  2. Your browser then takes that URL to make the request directly to Apple
  3. When the data is returned from Apple, the browser then sends it to my server for processing
  4. Results are then displayed!

This means that there are now 3 network requests instead of 1 but the crucial part is that all requests to Apple’s servers are now made from your own browser so the rate limiting shouldn’t be a problem2.

Whilst not an ideal solution, it does work and means I can keep everything running for a bit longer. I’m hopeful that Apple will alter how their rate limiting works as at the moment it seems a bit broken, especially with it being required for several apps with the new Apple Music APIs.

The code for the artwork finder is available on GitHub although this uses the old PHP request system rather than my new version as that should be more than good enough for personal usage3.

If you run into any problems, please get in touch.

  1. During which I received around 80 emails hoping that it would come back online - thanks! It’s nice to know that so many people use the site; I have no analytics on my website so seeing so many people get in touch made me realise how big it has become. ↩︎

  2. Unless you try and do around 50 searches in short succession in which case you’ll need to wait a bit before you can make more requests. ↩︎

  3. And if you want to do more than just personal usage you should speak to me first as I don’t really want people to create entire duplicates of my own project. ↩︎

Vortech

Update (9th Nov 2016): I’ve updated this article to reflect the new name for the app, Vortech. Whilst submitting a v1.0.1 update (adding support for some extra figures), Apple took issue with the name Dimensions so I had to change it…

I’m very happy to announce that my latest self-published app, Vortech, is now available on the App Store.

Vortech is a character and ability tracker for the videogame LEGO Dimensions. It allows you to easily see all 52 currently available characters (waves 1-6) and 73 abilities and track them in your own collection. Whilst there are other tracking apps available (namely the official LEGO Dimensions app), these tend not to be as easy to use and they don’t allow you to cross-reference the special abilities and powers of characters.

I built the app as I would occassionally come across something that required a special ability and the game might show me a character with that ability. However, as I have a fairly large collection already, it is likely I have a character with the ability and just need to look up which one has it. For example, I might find an area in a level which requires the Sonar Smash ability and the game might show me the character Benny (from The LEGO Movie) as someone with this ability; with my app, I can quickly see who else has that abilty and find I have Marty McFly (from Back To The Future) who will do just as well!

The entire app is built using Swift 3.0 and I use Realm as a mobile database containing all of the character information that I scraped from the official LEGO Dimensions website1. I added a few nice touches such as Peek & Pop support for 3D Touch enabled devices and taptic feedback for the iPhone 7 models. The app is completely free and contains no in-app purchases, adverts, or analytics tracking – it doesn’t even require an internet connection!

You can download Vortech on the App Store and learn more about it on my Dodo Apps website.

If you find Vortech useful, I’m always grateful for a review on the App Store. If you run into any issues or have feature requests, you can contact me directly.

  1. I built a custom scraper using PHP to periodically check the LEGO website and extract the image, abilities, and other information about each character. This then sends me a Slack notification at which point I can regenerate a JSON file and image bundle which I then include within the app. I’d thought about doing push notifications and remote updates for the app but as this is just a free hobby app (and the information only updates every few months) I figured doing it through the App Store will be fine for now. ↩︎

Kylo Ben

I have three main hobbies; coding, video games, and LEGO. With the first, I’m fortunate to have a flexible job that allows me to code on tons of different and varied projects every day. With the last, I’ve literally run out of space for the models I already have (most of which are over 2000 bricks in size). Video games, then, are really my main hobby. In the last year I’ve started a podcast on co-operative gaming, built a powerful gaming PC, and spent somewhere in the region of 900 hours playing games. Today I’m happy to announce a new website I’ve been working on dedicated to my gaming hobby; it’s called Kylo Ben:

Kylo Ben is divided into several different sections:

Articles

I’m currently varying between reviews, things I’m excited about, and general thought pieces on the industry. So far, I have published:

I’m trying to write new pieces every couple of days and it has proven to be a good way to practice my writing and get some long form thoughts out that don’t fit neatly into a 140 character tweet. It also means I can keep these game centric pieces away from my more work-oriented blog here at bendodson.com.

About

I’ve listed a few things about my current gaming setups on my about page. It details the components in my gaming PC, my current console and mobile gaming systems, and a look through the various consoles I’ve owned since I started gaming in 1991.

Games

I have a single page which lists all of the games I currently own on both Steam and my Xbox One. Each game has more details including purchase date, last played, total gaming time, and a short note about where I’m currently at with the game. I also list any articles related to that game for easy reference (and vice versa). For example, here is the entry for Mini Metro.

Gaming Time

This is perhaps my biggest achievement; a complete log of time spent on each game. The page updates daily and will list each game I’ve played over the last 2 months along with duration and a link through to more details. This is done through a combination of two custom scripts I wrote to scrape both my Steam library and Xbox Live / Windows 10 account periodically for changes. It’s been fascinating for me to see exactly how long I’ve spent on certain games (*cough* Peggle 2 *cough*) and will allow me to easily write a regular piece on games I’ve played over the previous month.

I’m really excited to be writing regularly about my biggest hobby and I’m looking forward to posting frequently for the foreseeable future. I have a few extra things to announce soon including some apps and game mods so follow me on Twitter for the latest updates. Alternatively, there is an RSS feed available for Kylo Ben which will keep you up to date on any new articles. If you have any thoughts or suggestions for improvements, please get in touch.

Working Remotely

I was recently asked by Remote.co to take part in a new Q&A section about remote workers. You can read the full Q&A on their website but I’ve put some of their questions and my answers below:

What advice would you give someone considering going remote?

Discipline. It takes a lot of discipline to work remotely as you’ll find that it is very easy to put off a piece of work when you’re sitting at home. There are no firewalls stopping you from accessing Facebook and Twitter, the Xbox might be sat saying “just one more game”, and before you know it a month has passed and you’ve done nothing.

How do you avoid becoming distracted when working remotely?

I have a pair of noise-cancelling headphones that I bought for working in an open-plan office but they work at home for me as the act of putting them on puts me into “work mode”. The only problem was that if the doorbell went (sidenote: great advantage of working from home is you never miss an Amazon delivery) I wouldn’t hear it; I fixed that by hooking it up to a Philips Hue lightbulb on my desk so I get a visual alert.

Do you have a dedicated home office?

I do have a dedicated room for work. I have a small desk with a 5k iMac and an external 1080p monitor in portrait mode (I find this better for webpages and iPhone simulators). Apart from the computer, my desk only has space for my tea and water and a Blue Yeti microphone I use for podcasting and Skype. I have lots of bookshelves (mainly full of LEGO) and a small orchid by the window.

What’s the hardest part about working with a traditional team while you’re remote? How do you overcome it?

I find the hardest thing is that traditional teams will want to have meetings all the time. They also want you to pop into the office fairly frequently for reasons unknown to me. I’m pretty good at telling prospective clients that I only work remotely and that I don’t do daily catch up calls; I get a good handle for the project and then do a week or two of work before sending over a build for feedback.

MailRoute blacklisting via email

I’ve been using MailRoute on and off for the past few years1 in an effort to reduce the amount of spam in my inbox but there is one missing feature that always drives me nuts; there is no way to blacklist an email address or domain without going to their website. Whilst you can whitelist domains easily from the daily digest of caught spam, there is no feature that lets you forward spam to them in order to have it blacklisted (despite people, including me, requesting it since 2013). After having a look at the MailRoute API, I decided it was time to fix this myself.

There are several components in getting this working.

  1. I created a new email address with Gmail which will catch my forwarded spam2.
  2. I set up an account with Context.io and connected it to the gmail account3.
  3. I put the following code available on GitHub on a 15 minute CRON job
<?php

require_once 'OAuth.php';

define('CONTEXT_KEY', 'your-contextio-consumer-key');
define('CONTEXT_SECRET', 'your-contextio-consumer-secret');
define('CONTEXT_USER_ID', 'your-contextio-user-id');
define('CONTEXT_TRASH_NAME', '[Gmail]/Trash'); // change if not using Gmail

define('MAILROUTE_USER', 'your-mailroute-username'); // should be your email address
define('MAILROUTE_API_KEY', 'your-mailroute-api-key');
define('MAILROUTE_EMAIL_ACCOUNT_ID', 'your-mailroute-email-id'); // numeric - can be found in admin.mailroute.net network traffic

$whitelist = ['sending@example.com']; // add the email address you are forwarding from or you'll blacklist yourself...

$inbox = performOAuthRequest('GET', 'https://api.context.io/lite/users/'.CONTEXT_USER_ID.'/email_accounts/0/folders/inbox/messages');
foreach ($inbox as $message) {
    $id = $message->{'message_id'};
    $body = performOAuthRequest('GET', 'https://api.context.io/lite/users/'.CONTEXT_USER_ID.'/email_accounts/0/folders/inbox/messages/'.$id.'/body');
    $content = str_replace('<', '', str_replace('>', '', $body->bodies[0]->content));
    $emails = extractEmailAddresses($content);
    foreach ($emails as $email) {
        if (!in_array($email, $whitelist)) {
            performRequest('POST', 'https://admin.mailroute.net/api/v1/wblist/', ['email_account' => '/api/v1/email_account/'.MAILROUTE_EMAIL_ACCOUNT_ID.'/', 'email' => $email, 'wb' => 'b'], ['Authorization: ApiKey '.MAILROUTE_USER.':'.MAILROUTE_API_KEY]);
        }
    }
    performOAuthRequest('PUT', 'https://api.context.io/lite/users/'.CONTEXT_USER_ID.'/email_accounts/0/folders/inbox/messages/'.$id, ['new_folder_id' => CONTEXT_TRASH_NAME]);
}

echo 'DONE!';



// CURL

function performOAuthRequest($httpMethod, $url, $params=[], $headers=[]) {
    $signatureMethod = new OAuthSignatureMethod_HMAC_SHA1();
    $oauthConsumer = new OAuthConsumer(CONTEXT_KEY, CONTEXT_SECRET, NULL);
    $oauthRequest = OAuthRequest::from_consumer_and_token($oauthConsumer, NULL, $httpMethod, $url, $params);
    $oauthRequest->sign_request($signatureMethod, $oauthConsumer, NULL);
    return performRequest($httpMethod, $oauthRequest, $params);
}

function performRequest($httpMethod, $url, $params=[], $headers=[]) {
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_TIMEOUT, 20);

    $headers[] = 'Content-Type: application/json';
    curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

    if (!in_array($httpMethod, ['GET', 'POST'])) {
        curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $httpMethod);
    }
    if ($httpMethod != 'GET') {
        curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($params));
    }
    $output = curl_exec($ch);
    $httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    curl_close($ch);
    return json_decode($output);
}



// Email parsing

function extractEmailAddresses($string) {
   $emails = array();
   $string = str_replace("\r\n",' ',$string);
   $string = str_replace("\n",' ',$string);

   foreach(preg_split('/ /', $string) as $token) {
        $email = filter_var($token, FILTER_VALIDATE_EMAIL);
        if ($email !== false) { 
            $emails[] = $email;
        }
    }
    return array_unique($emails);
}

Now all you need to do is forward any spam you receive to the Gmail account you set up. Every 15 minutes, the CRON job will run and check the inbox for any emails. When it finds some, it will parse them for email addresses and blacklist them with MailRoute before deleting them.

In an ideal world, MailRoute would implement a custom email address for blacklisting but this seems to be working for now.

  1. I stopped using MailRoute a while back and was using the black hole feature of Sanebox but I’ve just stopped using them as found the free service FollowUpThen - I was getting a lot of spam after the switch off so decided to re-activate MailRoute this week. I use Fastmail for my email in case you were wondering. ↩︎

  2. As you’ll be forwarding emails to Gmail, you’ll want to disable its spam filter as otherwise your emails won’t end up in the inbox for processing by Context. To do this, you’ll need to set up a new rule which matches the email ‘@’ and ensures it never goes to spam. ↩︎

  3. Whilst I could connect Context to my personal email and just move things into a folder for blacklisting, I don’t trust services with access to my email account, certainly not services that are free and are using the data. ↩︎

Pocket Rocket for iOS 10 (now with an iMessage app)

To coincide with the release of iOS 10, I’m happy to announce a free update is available for my app Pocket Rocket which includes several new features:

First of all, I’ve added an optional tile-based interface which uses an image from the article or a random colour if one isn’t available. You can long press a tile to get options for sharing, archiving, and deleting the article and tapping will open the article up in Safari or the in-app browser as per your settings. Next, I added the ability to share articles directly from Pocket Rocket; whether you are using the old list view or the new tile-based one, just long press on an article and you’ll be given a share option which uses the standard iOS share sheet so you can transfer the URL to any compatible app.

Finally, I added an iOS 10 iMessage app so you can share articles directly within iMessage:

This was a really interesting feature for me as it let me get to grips with the new APIs that allow apps to hook into iMessage. There are a few interesting niggles for developers when writing these apps1 but on the whole it is fairly simple and includes a lot more power than I thought they would2. With Pocket Rocket, you get a list of all of your articles; you can then tap to include them in your message and send them. Once received, you can tap to have the article open up in a webview directly within iMessage.

I think iMessage apps are going to be a huge deal so I’m excited that Pocket Rocket is one of the first apps available on the iMessage store.

You can get Pocket Rocket for free on the App Store. If you have any feature requests or feedback, please get in touch.

  1. For example, there is no standard way of seeing when someone tapped a link which is… irritating. Instead you have to work out if a particular message is selected (which happens for a variety of reasons) and then be clever about what you present. ↩︎

  2. I’ve seen one app that lets you use the camera within iMessage - pretty cool! ↩︎

Generating a random colour, with a seed, in Swift 3

I’ve been working on some iOS 10 updates to Pocket Rocket1 which led me to trying to solve an interesting problem; how do you generate a random colour, with a seed, in Swift? The reason for this dilemma is that I’m going to start showing a grid view of Pocket articles and many of them do not have images associated with them. In order to break things up, I decided I’d like a random colour for the background of each article:

As each article is UICollectionViewCell, setting a random background colour is not suitable as when you scroll and the cells are re-used the backgrounds will change. Whilst that could be fixed fairly easily, I also want the colours to persist with the article between app launches and also be the same in the iPad app and the iMessage extension. This means I need to generate a random colour with a seed so that colours generated with the same seed will always be the same.

Thankfully this is fairly easy if we use the srand48 and drand48 functions:

func randomColor(seed: String) -> UIColor {
    
    var total: Int = 0
    for u in seed.unicodeScalars {
        total += Int(UInt32(u))
    }
    
    srand48(total * 200)
    let r = CGFloat(drand48())
    
    srand48(total)
    let g = CGFloat(drand48())
    
    srand48(total / 200)
    let b = CGFloat(drand48())
    
    return UIColor(red: r, green: g, blue: b, alpha: 1)
}

We start by taking a string (in my case an article title) and turning it into an integer by getting the sum of the unicode scalar values of each character. Next, we seed the drand48 function by using srand48 with our Int along with a multiplier or division so that the red, green, and blue values are all different. Finally, we compile the UIColor together.

I’ve put together a Swift Playground demonstrating this using the last few headlines from Daring Fireball:

As you can see, each article title results in a different colour; the same string will always result in the same colour being generated. Be aware that this is not collision free as it is just a basic addition of scalar values – a string such as “ben” and “neb” will result in the same colours. This isn’t an issue for my usage and still serves as an interesting way of seeding random colours.

  1. Specifically an iMessage app. ↩︎

« Older Entries Newer Entries »