Indie iOS development has had a bit of a tough time of it recently what with all the ex post facto rejections. It has tarnished the excitement about the innovation that has been made possible by iOS 8. However, one gem has managed to escape the app review chopping block: Workflow.
If you haven’t downloaded it yet, get it now! Workflow is an immensely powerful tool that lets you string actions together into workflows that run on your iOS device. It’s the best demonstration I’ve seen of the power of iOS 8 since it launched 3 months ago. One of my favourite features is that you can create workflows as Action Extensions that can be accessed from the standard iOS share sheet, allowing you to fill gaps left by other developers.
My first attempt was to create an Action Extension workflow for generating iTunes Affiliate links that could be triggered from the share sheet in the App Store app. It took me a while. Like working with many proper programming or scripting languages, getting Workflow to do exactly what you want can be a little challenging. This is probably partly due to the limitations of iOS 8, but may also be because this is only version 1.0 – I’m sure many more features and improvements are in the works.
I went through a few iterations. My first problem was that links shared from the App Store app are shortened versions that need to be expanded before the affiliate query string can be added. I first tried using the Clean Links app, but bouncing out to a separate app returned to the Workflow app instead of the extension running in the App Store. My second attempt tried loading the URL using the ‘Get Contents of URLs’ action but I had issues with frame load interruption errors, probably caused by iOS’s desire to open the link in the App Store app.
Finally, with a little help from Dr. Drang, this is the end result. You can trigger it from the App Store share sheet, it expands the short URLs using longurl.org, and it creates a complete affiliate link ready to be shared however you wish.