Mac Developer Tip: Programmatically Starting a Search on the Mac App Store

Working on Transloader 3, I wanted to re-implement the Finder’s Open With… contextual menu:

The Finder's Open With contextual menu

Getting the apps in there turned out to be the easy part. What took some effort was the “App Store…” menu item, as I wanted to precisely replicate its functionality.

Transloader 3's Open With contextual menu

Right-click a file in Finder, select Open With -> App Store…, and it will launch the Mac App Store with a UTI search, for example: uti:public.zip-archive.
This will give you a list of all apps available in the Mac App Store that can handle that file type. Neat!

The ‘macappstores’ URL scheme

The Mac App Store app luckily offers a URL scheme:

  • macappstores://
    Launches the Mac App Store
  • macappstores://showUpdatesPage
    Launches the Mac App Store and takes you directly to your Updates page
  • macappstores://showPurchasesPage
    Launches the Mac App Store and takes you directly to your Purchased page
  • macappstores://itunes.apple.com/app/idYOURAPPID
    Launches the Mac App Store and takes you directly to the product page, identified by the product ID

That’s very practical, but not what I was looking for. I was in need of a way to start a search the way Finder does.

In order to find out the URL Finder uses, I wrote a quick throwaway-app that would overtake the Mac App Store’s URL schemes (using LSSetDefaultHandlerForURLScheme) and print out the URL that was opened.
Alas – no dice. Apparently, Finder uses Apple Events or some other magic that “can not be used in a third-party sandboxed app anyway”™ to do its bidding.

After googling the issue, I found a URL that supposedly worked: macappstores://ax.search.itunes.apple.com/WebObjects/MZSearch.woa/wa/search?q=searchterm, but just to pour more salt into an already wide-open wound, it only worked on pre-10.9 systems:

The search URL in 10.9-and-beyond systems

Another dead end. Or was it?
I guess I should have experimented with that URL a little, because Jan Vitturi (@jan4843 on twitter) had the answer: just remove “ax.” from the URL, and it works (on both pre-10.9 and post-10.9 systems)!

Using this URL:
macappstores://search.itunes.apple.com/WebObjects/MZSearch.woa/wa/search?q=searchterm
I was able to get a search going on the Mac App Store, right from within my app.

Sadly, there’s a caveat.
I can’t do a UTI search this way. When I pass (even a percent-escaped) search term along the lines of ‘uti:public.zip-archive’, the Mac App Store tells me there are no results. Reloading that very same page then does show the results – weird and annoying, but nothing I was able to work around.
Using extension:zip seemed to work a little better, but still didn’t return all results a reload would.

Jan Vitturi to the rescue again – the URL’s a little different for UTI or extension searches:
macappstores://search.itunes.apple.com/WebObjects/MZSearch.woa/wa/docTypeLookup?uti=youruti

Alternatively, instead of uti=…, you can use extension=… to search by file path extensions.

My sincere thanks go to Jan Vitturi!

 

Eternal Storms Software Logo

– – – Do you enjoy my blog and/or my software? – – –
Stay up-to-date on all things Eternal Storms Software and join my low-frequency newsletter (one mail a month at most).
Thank you :)

Mac Developer Tip: NSTouchBar in a Share Extension

You’re working on your Share extension with support for MacBook Pro’s Touch Bar, but it’s empty and doesn’t appear when your extension is loaded?

NSTouchBar Empty

The solution is simple:

Solution for showing NSTouchBar from within a Share extension

Call [self.view.window makeFirstResponder:self.view]; and it will push your glorious NSTouchBar onto the stack:

NSTouchBar working in a Share extension

Hope it helps – it would have saved me 20 minutes if I’d known ;)

Eternal Storms Software Logo

– – – Do you enjoy my blog and/or my software? – – –
Stay up-to-date on all things Eternal Storms Software and join my low-frequency newsletter (one mail a month at most).
Thank you :)

What I… (November 2016 – January 2017)

In  “What I…”, a monthly column, I take a look back at what went down over the course of the passed month.

As you can tell by the title of this blog post, I missed the last two months – my apologies.
It’s partly that I’ve been busy and partly that I couldn’t really get into my blogging mood and -mindset.
But now I forced myself to finally get down to it, so here’s what I…

… Did

Touch Bar Support for Glimpses (website, mac app store)

On a hunch that Apple would show-case apps that adopted the new MacBook Pro’s Touch Bar on the Mac App Store, I set out to add support for it to my still motion video app, Glimpses.
The API is lovely, so I made progress fast – implementing and testing took about 2 days altogether.
Touch Bar in Glimpses allows you to import photos from flickr or Instagram, sort your photos and adjust your project’s settings and more – all without having to look up from the Touch Bar.

Glimpses Touch Bar Support - Import from Flickr

Sadly, it didn’t make the cut for Apple’s “Enhanced for Touch Bar” Mac App Store-feature – even begging didn’t help, like, at all…
I wish Apple would give some feedback to developers as to why an app was (or wasn’t) chosen – does the app just suck? Does it not sell enough? Is the rating too low? Does the Touch Bar implementation suck?
Nonetheless, now I know about the Touch Bar APIs and I can put that knowledge to good use in some of my other apps for sure.

Released Yoink v3.2.1 (website, mac app store)

A simple bugfix update, version 3.2.1 fixes a bug with “private” dragging pasteboards, reacts to memory pressure events and cleans up stuff it doesn’t need and fixes a nasty bug where the video in the preferences’ “Behavior” tab would play, even if the preferences window was closed.

Worked on Transloader 3 (website, mac app store, ios app store)

Right after implementing Touch Bar support in Glimpses, I took to Transloader to see how (and if) it would work there, and I think can make things more accessible, like when switching between different views (these GIFs are of a software that’s still in development, so things might change before release) :

Touch Bar support in Transloader 3

or when assigning a download to different Macs:

Touch Bar Support in Transloader 3

Other than that, I’ve been spending a lot of time on the “backend” (read: CloudKit) side of the app – the stuff that should just work and the user never gets to see. I’m finally happy with the approach I’m taking (which I wrote about here), so now I can polish it up.
I’m also working on the UI of course and am playing around with alternate progress bars instead of Apple’s standard progress bar UI:

Transloader Progress Bars

It’s very easy to see if a download has succeed, failed or was cancelled, or how far a running download has progressed without having to read the status below.
Transloader 3 is progressing slowly but nicely, and I hope to be able to make an announcement in the first half of 2017 (yes, that’s very vague, but I’m not good at keeping my own deadlines and I don’t want to commit to a date too early).

Worked on someone else’s code base

For someone else’s iOS app (which I can’t talk about), I had to work on a very complex code base I was completely unfamiliar with.
One part of the complexity comes from its very extensive sync API (basically anything you do in the app is synced back to the server) and knowing the current state of data in the app, the other part is that it uses Core Data, which I only ever read about but never actually used.
Naturally, I had to go through a pretty steep learning curve (including Core Data), and it didn’t help that the initial coding was outsourced to a seemingly unexperienced developer from India, as some parts of it are very, very confusing and sometimes implemented twice or more.
Incidentally, for Christmas, my brother gave me the book “Your Code as a Crime Scene”, which helped identifying parts that needed attention and belonged together – I can wholeheartedly recommend that book.
The app is a very compelling and interesting project and gets me to think about another app besides my own – a break can do wonders on how you view certain problems or issues.

… Thought About

Yoink Removed from the Mac App Store’s ‘Invaluable Utilities’ Feature

After having been featured in ‘New Year, New Habits’, a front-page feature of the Mac App Store all through January 2017, Yoink was (silently) removed by the Mac App Store’s Editorial team from its ‘Invaluable Utilities’ feature.
I noticed by chance, and this pretty much sums up how I reacted when I saw it:

The Simpsons, Ralph gets his Heart broken by Lisa

Of course I went on to iTunes Connect to see if everything was in order with the app – it was – so I decided to write Apple directly (I don’t have any contacts in their editorial team – does anybody besides the big guys? I just used iTunes Connect’s ‘Contact Us’ form).
Unsurprisingly, they couldn’t tell me anything. I thought perhaps they could tell me the app was not updated frequently enough (which I doubt, since other apps in that feature were last updated earlier than Yoink) or that it didn’t receive enough ratings, but I got the standard “the editorial team giveth, the editorial team taketh away” response. I really wish Apple were more transparent here – it would only do the developer economy good, knowing where you’d do well to improve.
Anyway, the feature has been removed from the Mac App Store entirely now, so perhaps a new Utility-promotion is coming our way on the Mac App Store soon?

… Downloaded

Oceanhorn IconOceanhorn (app store)

A great game I’m playing on my Apple TV – always reminds me of playing the Zelda games with my cousin. Good times.
At first I thought using the Apple TV Siri Remote to play it would be clumsy and a turn-off, but it works surprisingly well. I’m not quite done with the game yet, but I’m very close to the end. 

Stardew Valley IconStardew Valley (gog)

If you don’t have time to spare (which I don’t) or accidentally spend way too much time on that particular game you just can’t get enough of (which I do), do not – I repeat: do not – get this game.
It’s awesome and will make hours seem like minutes. Seriously.

Water Minder IconWaterMinder (app store)

I’m notoriously under-hydrated. I drink some coffee in the morning and maybe one, or two glasses of water over the course of a day. Now, that might be enough, as some say, and it might be way too little, as say others.
I’m giving it a try and so that I can keep track of things, I’m using WaterMinder – an app very well designed to take care of these water-intake-tracking-needs. 

… Read

The Andromeda StrainThe Andromeda Strain (ibooks store)

“Five prominent biophysicists have warned the United States government that sterilization procedures for returning space probes may be inadequate to guarantee uncontaminated re-entry to the atmosphere.”
Michael Crichton sure was a genius.

Ancient Aliens Book CoverAncient Aliens – The Official Companion Book (amazon)

I gave this book to my girlfriend Britta for Christmas and somehow wound up reading it before her – even though I’m quite skeptic about these things (aliens being the ones who created us thousands of years ago), I still enjoyed reading it a lot – it gives you a different perspective on things.
“Transporting readers around the globe, Ancient Aliens® explores the fascinating enigmas and mysterious artifacts our ancestors left behind, from incredible objects to amazingly accurate ancient maps; from the Great Pyramid of Giza and stone megaliths at Gobekli Tepe to the Nazca Plains and mysterious structures of Puma Punku.”

Your Code as a Crime Scene Book CoverYour Code as a Crime Scene (pragmatic programmer)

As I stated before, I received this book from my brother for Christmas and read it in about two evenings.
“In this book, you’ll learn forensic psychology techniques to successfully maintain your software. You’ll create a geographic profile from your commit data to find hotspots, and apply temporal coupling concepts to uncover hidden relationships between unrelated areas in your code.”

Designed for Use Book CoverDesigned for Use (pragmatic programmer)

“Expert developer and user interface designer Lukas Mathis gives you a deep dive into research, design, and implementation – the essential stages in designing usable interfaces for applications and websites.”
I’m still reading it, but already I feel like I know a lot more about how I should go about future projects – BEFORE writing code ;)

The Murder of Roger AckroydThe Murder of Roger Ackroyd (ibook store)

Having read “Death on the Nile” (after having seen the movie like a gazillion times), my mind is now set on reading all books featuring one Monsieur Hercule Poirot by Agatha Christie.
“Village rumor hints that Mrs. Ferrars poisoned her husband, but no one is sure. Then there’s another victim in a chain of death. Unfortunately for the killer, master sleuth Hercule Poirot takes over the investigation.”

… Ate

Nachos with self-made Salsa

Nachos with self-made Salsa

… Went to See

Mariazell, Austria

Mariazell, Austria

Eternal Storms Software Logo

– – – Do you enjoy my blog and/or my software? – – –
Stay up-to-date on all things Eternal Storms Software and join my low-frequency newsletter (one mail a month at most).
Thank you :)