Launching iMessage on Spotify

Leave a comment

This week, a project me and my friends here in San Francisco have been working on finally went live. The Spotify iMessage App Extension.

Screen Shot 2017-08-04 at 1.25.07 PM.png

This app extension let’s you search for songs, send them to friends, and then play short 30 sec clips.

Sep-15-2017 08-14-06.gif

I know it doesn’t look like much – but it was a lot of work! You’ve got just the basic functionality of the App itself. You’ve got error handling. How to handle going off line. Analytics. Authorization. The expand and collapse interaction of iMessage. Nasty bugs. And the requirement to support both portrait and landscape orientations too (thank you UIStackView).

Sep-15-2017 08-18-08.gif

You don’t launch something like this without a lot of help. And I want to thank:

And my partner in crime, with whom this all started as a Spotify hackweek project, Joseph Baena.

Without them none of this would have worked.
So thank you team.
Onwards and upwards.
Looking forward to iterating more on this great platform!

Oh. And we are hiring! So if you are a mobile iOS or Android engineer, and have always wanted to work a great team in the great San Francisco Bay area, go checkout our job listings here and see if you’d like to join the band.

Links

Advertisements

How to keep you tests non-flakey

Leave a comment

Something I am always striving to avoid in my unit tests is flakiness. That’s why when I needed to deal with a UINavigation bar in the previous version of iMessage, I ended up writing a method that looked like this:

Screen Shot 2017-09-13 at 10.19.35 AM.png

This method puts the responsibility on the client to figure out the runtime of the device, so this method is relatively straight forward and doesn’t suffer from any of the shenanigans that come with embedding lines of code like this, in classes you want to test.

Screen Shot 2017-09-13 at 10.25.54 AM.png

The power of overriding – or always asking for more

A colleague and I in a code review where debating the merits of this approach. The ugliness of exposing these details versus the desire to keep the code clean and testable. Together we came upon the following solution.

Make a public API that is easy and another one that is testable. Then have the public API call the more testable one

So that’s what we did.

Screen Shot 2017-09-13 at 10.30.17 AM.png

The lesson for me here is to always remember you can do anything with software. Got an interface you don’t like? Create a new one. Software is the one disciple where you can have your cake and eat it to. Just create whatever you need, and implement behind the scenes however your like.

A nice macro for designated initializers

2 Comments

Define a macro like this

#define FOO_DESIGNATED_INITIALIZER NS_DESIGNATED_INITIALIZER; \
    /** Unavailable. Use the designated initializer instead */ \
    + (instancetype)new NS_UNAVAILABLE; \
    /** Unavailable. Use the designated initializer instead */ \
    - (instancetype)init NS_UNAVAILABLE; \

So you can do this

- (instancetype)initWithBar:(Bar *)bar FOO_DESIGNATED_INITIALIZER;

How to fix iMessage orientation crash

Leave a comment

iMessage will crash in mysterious ways if you start in portrait, change to landscape, and then select something from your conversation.

My buddy kevski figured out that you can fix this by dismissing yourself every time you send a message.

MSMessageViewController.m

- (void)didStartSendingMessage:(MSMessage *)message conversation:(MSConversation *)conversation
{
[self dismiss];
}

Just another weird iMessage thing. But this seems to be what most apps do and it fixed an annoying bug I had. Merci kevski!

How to add a border to a UIImageView

Leave a comment

#import <QuartzCore/QuartzCore.h>
    _imageView.layer.borderColor = [UIColor colorWithWhite:0.0 alpha:0.1].CGColor;

Just change the CALayer on the UIImageView as shown above.

Screen Shot 2017-08-01 at 1.31.51 PM.png

How to preserve a button’s height and width in a UIStackView with distribution fill

Leave a comment

Not sure if there is a simpler way to do this, but if you have a button and you don’t want it to fill the entire StackView width and height, place it inside another view within the stackView and set leading/trailing/top/bottom constraints on it it.

Screen Shot 2017-07-09 at 7.34.40 PM.png

StackView element heights respected

Leave a comment

If you are having your UI elements fill your StackView more than you’d like

Screen Shot 2017-06-29 at 3.50.31 PM.png

Change the alignment from fill to center

Screen Shot 2017-06-29 at 3.51.03 PM.png

Screen Shot 2017-06-29 at 3.48.33 PM.png

Older Entries

%d bloggers like this: